Skip to content

Commit

Permalink
fix PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabrisrp committed May 7, 2024
1 parent dfbb1e2 commit 192cc0d
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 7 deletions.
4 changes: 2 additions & 2 deletions inc/Engine/Common/Queue/RUCSSQueueRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public function maybe_dispatch_async_request() {
*
* @param string $context Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron'
* Generally, this should be capitalised and not localised as it's a proper noun.
* @return int The number of actions processed.
*
* @return void
*/
public function run( $context = 'WP Cron' ) {
\ActionScheduler_Compatibility::raise_memory_limit();
Expand All @@ -179,7 +180,6 @@ public function run( $context = 'WP Cron' ) {
}

do_action( 'action_scheduler_after_process_queue' );// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
return $processed_actions;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions inc/Engine/CriticalPath/ProcessorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ private function check_cpcss_job_status( $job_id, $item_path, $item_url, $is_mob
) {
return $this->on_job_success( $item_path, $item_url, $job_details->data->critical_path, $is_mobile, $item_type );
}

return $this->on_job_error( $job_details, $item_url, $is_mobile, $item_type );
}

/**
Expand Down
1 change: 1 addition & 0 deletions inc/Engine/HealthCheck/ActionSchedulerCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static function get_subscribed_events(): array {
* @return void
*/
public function activate() {
// @phpstan-ignore-next-line
add_action( 'rocket_activation', [ $this, 'maybe_recreate_as_tables' ] );
}

Expand Down
2 changes: 2 additions & 0 deletions inc/Engine/Media/ImageDimensions/ImageDimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ private function set_dimensions( string $image, array $sizes ) {

return 'width="' . $initial_width['width'] . '" height="' . (int) round( $sizes[1] * $ratio ) . '"';
}

return false;
}

/**
Expand Down
1 change: 1 addition & 0 deletions inc/ThirdParty/Hostings/Godaddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Godaddy implements Subscriber_Interface {
* @param string $vip_url Godaddy vip url.
*/
public function __construct( $vip_url = '' ) {
// @phpstan-ignore-next-line
$this->vip_url = method_exists( '\WPaas\Plugin', 'vip' ) ? \WPaas\Plugin::vip() : $vip_url;
}

Expand Down
2 changes: 2 additions & 0 deletions inc/ThirdParty/Hostings/Pressidium.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function clear_cache_after_pressidium() {
* @return void
*/
public function clean_pressidium() {
// @phpstan-ignore-next-line
$plugin = NinukisCaching::get_instance();
$plugin->purgeAllCaches();
}
Expand Down Expand Up @@ -106,6 +107,7 @@ private function get_paths( $urls ) {
* @return void
*/
private function purge_cache( $paths ) {
// @phpstan-ignore-next-line
NinukisCaching::get_instance()->purge_cache( $paths );
}

Expand Down
4 changes: 4 additions & 0 deletions inc/ThirdParty/Hostings/Savvii.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ public function varnish_addon_title( $settings ) {
public function clear_cache_after_savvii() {
if (
! (
// @phpstan-ignore-next-line
isset( $_REQUEST[ CacheFlusherPlugin::NAME_FLUSH_NOW ] )
&&
// @phpstan-ignore-next-line
check_admin_referer( CacheFlusherPlugin::NAME_FLUSH_NOW )
)
&&
! (
// @phpstan-ignore-next-line
isset( $_REQUEST[ CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW ] )
&&
// @phpstan-ignore-next-line
check_admin_referer( CacheFlusherPlugin::NAME_DOMAINFLUSH_NOW )
)
) {
Expand Down
3 changes: 3 additions & 0 deletions inc/ThirdParty/Hostings/WPEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function varnish_addon_title( $settings ) {
* @since 3.6.1
*/
public function run_rocket_bot_after_wpengine() {
// @phpstan-ignore-next-line
if ( ! wpe_param( 'purge-all' ) ) {
return;
}
Expand Down Expand Up @@ -85,10 +86,12 @@ public function run_rocket_bot_after_wpengine() {
*/
public function clean_wpengine() {
if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) {
// @phpstan-ignore-next-line
WpeCommon::purge_memcached();
}

if ( method_exists( 'WpeCommon', 'purge_varnish_cache' ) ) {
// @phpstan-ignore-next-line
WpeCommon::purge_varnish_cache();
}
}
Expand Down
1 change: 1 addition & 0 deletions inc/ThirdParty/Plugins/CDN/CloudflareFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CloudflareFacade {
* @return void
*/
private function set_hooks() {
// @phpstan-ignore-next-line
$this->hooks = new Hooks();
}

Expand Down
3 changes: 3 additions & 0 deletions inc/ThirdParty/Plugins/ContactForm7.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function conditionally_enqueue_scripts() {
return;
}
if ( did_action( 'wp_enqueue_scripts' ) ) {
// @phpstan-ignore-next-line
wpcf7_enqueue_scripts();
return;
}
Expand All @@ -84,6 +85,7 @@ public function conditionally_enqueue_styles() {
return;
}
if ( did_action( 'wp_enqueue_scripts' ) ) {
// @phpstan-ignore-next-line
wpcf7_enqueue_styles();
return;
}
Expand All @@ -100,6 +102,7 @@ public function load_scripts_fallback() {
return;
}

// @phpstan-ignore-next-line
wpcf7_enqueue_scripts();
}

Expand Down
7 changes: 6 additions & 1 deletion inc/ThirdParty/Plugins/Ecommerce/WooCommerceSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ public function exclude_product_shipping_taxonomy( $excluded_taxonomies ) {
* @return bool
*/
private function product_has_gallery_images() {
// @phpstan-ignore-next-line
$product = wc_get_product( get_the_ID() );
if ( empty( $product ) ) {
return false;
Expand All @@ -529,6 +530,7 @@ public function show_empty_product_gallery_with_delayJS() {
return;
}

// @phpstan-ignore-next-line
if ( ! is_product() ) {
return;
}
Expand Down Expand Up @@ -560,6 +562,7 @@ public function show_notempty_product_gallery_with_delayJS( $exclusions = [] ):
return $exclusions;
}

// @phpstan-ignore-next-line
if ( ! is_product() ) {
return $exclusions;
}
Expand Down Expand Up @@ -612,13 +615,15 @@ public function disallow_rocket_clean_post(): void {
* @return void
*/
public function allow_rocket_clean_post( int $product_id ): void {
$urls = [];
$urls = [];
// @phpstan-ignore-next-line
$category_list = wc_get_product_category_list( $product_id );

if ( preg_match_all( '/<a\s+(?:[^>]*?\s+)?href=(["\'])(?<urls>.*?)\1/i', $category_list, $matches ) ) {
$urls = $matches['urls'];
}

// @phpstan-ignore-next-line
$shop_page = get_permalink( wc_get_page_id( 'shop' ) );

if ( empty( $shop_page ) ) {
Expand Down
8 changes: 8 additions & 0 deletions inc/ThirdParty/Plugins/I18n/TranslatePress.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static function get_subscribed_events() {
* @return string
*/
public function detect_homepage( $home_url, $url ) {
// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();
$converter = $translatepress->get_component( 'url_converter' );

Expand Down Expand Up @@ -77,6 +78,7 @@ function_exists( 'trp_get_languages' )
* @return array
*/
public function add_langs_to_admin_bar( $langlinks ) {
// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$language_switcher = $translatepress->get_component( 'language_switcher' );
Expand Down Expand Up @@ -127,6 +129,7 @@ public function get_active_languages_uri( $urls ) {

$home_url = home_url();

// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$settings = $translatepress->get_component( 'settings' );
Expand Down Expand Up @@ -156,6 +159,7 @@ public function get_active_languages_codes( $codes ) {
$codes = (array) $codes;
}

// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$settings = $translatepress->get_component( 'settings' );
Expand Down Expand Up @@ -185,6 +189,7 @@ public function get_home_url_for_lang( $home_url, $lang ) {
return $home_url;
}

// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();
$converter = $translatepress->get_component( 'url_converter' );
$settings = $translatepress->get_component( 'settings' );
Expand Down Expand Up @@ -223,6 +228,7 @@ public function get_translated_post_urls( $urls, $url, $post_type, $regex ) {
$urls = (array) $urls;
}

// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$settings = $translatepress->get_component( 'settings' );
Expand All @@ -248,6 +254,7 @@ public function get_translated_post_urls( $urls, $url, $post_type, $regex ) {
* @return void
*/
public function clear_post_languages( $post_id ) {
// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$converter = $translatepress->get_component( 'url_converter' );
Expand Down Expand Up @@ -286,6 +293,7 @@ public function clear_post_languages( $post_id ) {
* @return void
*/
public function clear_post_after_updating_translation( $update_strings, $settings ) {
// @phpstan-ignore-next-line
$translatepress = TRP_Translate_Press::get_trp_instance();

$converter = $translatepress->get_component( 'url_converter' );
Expand Down
15 changes: 14 additions & 1 deletion inc/ThirdParty/Plugins/Optimization/Hummingbird.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ private function check_emoji() {
return false;
}

if ( $this->options->get( 'emoji' ) && WP_Hummingbird_Settings::get_setting( 'emoji', 'advanced' ) ) {
if (
$this->options->get( 'emoji' )
&&
// @phpstan-ignore-next-line
WP_Hummingbird_Settings::get_setting( 'emoji', 'advanced' )
) {
// Translators: %1$s = Plugin name, %2$s = <em>, %3$s = </em>.
$this->errors[] = sprintf( _x( '%1$s %2$sdisable emoji%3$s conflicts with WP Rockets %2$sdisable emoji%3$s', 'Hummingbird notice', 'rocket' ), 'Hummingbird', '<em>', '</em>' );
return true;
Expand All @@ -168,8 +173,10 @@ private function check_gzip() {
return false;
}

// @phpstan-ignore-next-line
$gzip = WP_Hummingbird_Utils::get_module( 'gzip' );

// @phpstan-ignore-next-line
if ( ! $gzip instanceof \WP_Hummingbird_Module_GZip ) {
return false;
}
Expand Down Expand Up @@ -204,8 +211,10 @@ private function check_browser_caching() {
return false;
}

// @phpstan-ignore-next-line
$caching = WP_Hummingbird_Utils::get_module( 'caching' );

// @phpstan-ignore-next-line
if ( ! $caching instanceof \WP_Hummingbird_Module_Caching ) {
return false;
}
Expand Down Expand Up @@ -240,8 +249,10 @@ private function check_cache() {
return false;
}

// @phpstan-ignore-next-line
$cache = WP_Hummingbird_Utils::get_module( 'page_cache' );

// @phpstan-ignore-next-line
if ( ! $cache instanceof \WP_Hummingbird_Module_Page_Cache ) {
return false;
}
Expand Down Expand Up @@ -274,8 +285,10 @@ private function check_assets() {
return false;
}

// @phpstan-ignore-next-line
$minify = WP_Hummingbird_Utils::get_module( 'minify' );

// @phpstan-ignore-next-line
if ( ! $minify instanceof \WP_Hummingbird_Module_Minify ) {
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion inc/ThirdParty/Plugins/SEO/AllInOneSEOPack.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public function add_all_in_one_seo_sitemap( $sitemaps ) {
}

if (
( ! $aioseo_v4 && ! $sitemap_enabled ) ||
( ! $aioseo_v4 && ! $sitemap_enabled )
||
// @phpstan-ignore-next-line
( $aioseo_v4 && ! aioseo()->options->sitemap->general->enable )
) {
return $sitemaps;
Expand Down
4 changes: 3 additions & 1 deletion inc/ThirdParty/Plugins/SEO/RankMathSEO.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct( Options_Data $option ) {
* Subscribed events.
*/
public static function get_subscribed_events() {
// @phpstan-ignore-next-line
if ( ! defined( 'RANK_MATH_FILE' ) || ! Helper::is_module_active( 'sitemap' ) ) {
return [];
}
Expand All @@ -45,8 +46,9 @@ public static function get_subscribed_events() {
* @param array $sitemaps Sitemaps to preload.
* @return array Updated Sitemaps to preload
*/
public function rocket_sitemap( $sitemaps ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals
public function rocket_sitemap( $sitemaps ) {

// @phpstan-ignore-next-line
$sitemaps[] = Router::get_base_url( 'sitemap_index.xml' );

return $sitemaps;
Expand Down
1 change: 1 addition & 0 deletions inc/ThirdParty/Plugins/SEO/SEOPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static function get_subscribed_events() {
return [];
}

// @phpstan-ignore-next-line
if ( ! method_exists( seopress_get_service( 'SitemapOption' ), 'isEnabled' ) || 1 !== (int) seopress_get_service( 'SitemapOption' )->isEnabled() ) {
return [];
}
Expand Down
2 changes: 2 additions & 0 deletions inc/ThirdParty/Plugins/SEO/TheSEOFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function add_tsf_sitemap_to_preload( $sitemaps ) {
// The autoloader in TSF doesn't check for file_exists(). So, use version compare instead to prevent fatal errors.
if ( version_compare( rocket_get_constant( 'THE_SEO_FRAMEWORK_VERSION', false ), '4.0', '>=' ) ) {
// TSF 4.0+. Expect the class to exist indefinitely.
// @phpstan-ignore-next-line
$sitemap_bridge = Sitemap::get_instance();

foreach ( $sitemap_bridge->get_sitemap_endpoint_list() as $id => $data ) {
Expand All @@ -78,6 +79,7 @@ public function add_tsf_sitemap_to_preload( $sitemaps ) {
}
} else {
// Deprecated. TSF <4.0.
// @phpstan-ignore-next-line
$sitemaps[] = the_seo_framework()->get_sitemap_xml_url();
}

Expand Down
6 changes: 5 additions & 1 deletion inc/ThirdParty/Plugins/Security/WordFenceCompatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function pop_old_ip( string $old_rucss_ip ) {
}

// Update whitelist.
// @phpstan-ignore-next-line
wfConfig::set( 'whitelisted', implode( ',', $whitelist ) );
}

Expand All @@ -74,6 +75,7 @@ public function pop_ip_from_whitelist() {
}

// Update whitelist.
// @phpstan-ignore-next-line
wfConfig::set( 'whitelisted', implode( ',', $whitelist ) );
}

Expand All @@ -85,6 +87,7 @@ public function pop_ip_from_whitelist() {
*/
private function can_pop_ip( string $ip ) {
// Get all whitelists.
// @phpstan-ignore-next-line
$whitelists = wfConfig::get( 'whitelisted', '' );

// Convert to array.
Expand Down Expand Up @@ -119,7 +122,7 @@ public function whitelist_wordfence_firewall_ips() {
*
* @since 3.10
*
* @param array list of IPs should be whitelisted
* @param array $ips list of IPs should be whitelisted
*/
$ips = apply_filters( 'rocket_wordfence_whitelisted_ips', self::WHITELISTED_IPS );

Expand All @@ -128,6 +131,7 @@ public function whitelist_wordfence_firewall_ips() {
}

foreach ( $ips as $ip ) {
// @phpstan-ignore-next-line
wordfence::whitelistIP( $ip );
}
}
Expand Down
Loading

0 comments on commit 192cc0d

Please sign in to comment.