diff --git a/inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php b/inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php index eeba4355b3..fe9319e19d 100644 --- a/inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php +++ b/inc/Engine/CDN/RocketCDN/AdminPageSubscriber.php @@ -86,18 +86,21 @@ public function display_rocketcdn_status() { $subscription_data = $this->api_client->get_subscription_data(); + $container_class = ''; + $status_class = ''; + $label = ''; + $status_text = ''; + $is_active = false; + if ( 'running' === $subscription_data['subscription_status'] ) { - $label = __( 'Next Billing Date', 'rocket' ); - $status_class = ' wpr-isValid'; - $container_class = ''; - $status_text = date_i18n( get_option( 'date_format' ), strtotime( $subscription_data['subscription_next_date_update'] ) ); - $is_active = true; + $label = __( 'Next Billing Date', 'rocket' ); + $status_class = ' wpr-isValid'; + $status_text = date_i18n( get_option( 'date_format' ), strtotime( $subscription_data['subscription_next_date_update'] ) ); + $is_active = true; } elseif ( 'cancelled' === $subscription_data['subscription_status'] ) { - $label = ''; $status_class = ' wpr-isInvalid'; $container_class = ' wpr-flex--egal'; $status_text = __( 'No Subscription', 'rocket' ); - $is_active = false; } $data = [ diff --git a/inc/Engine/CDN/RocketCDN/views/cta-big.php b/inc/Engine/CDN/RocketCDN/views/cta-big.php index cb5b3608d7..f5ccf86b32 100644 --- a/inc/Engine/CDN/RocketCDN/views/cta-big.php +++ b/inc/Engine/CDN/RocketCDN/views/cta-big.php @@ -15,6 +15,8 @@ */ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); + +$data = isset( $data ) && is_array( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
diff --git a/inc/Engine/CDN/RocketCDN/views/cta-small.php b/inc/Engine/CDN/RocketCDN/views/cta-small.php index 93d8285592..dd5167561f 100644 --- a/inc/Engine/CDN/RocketCDN/views/cta-small.php +++ b/inc/Engine/CDN/RocketCDN/views/cta-small.php @@ -10,6 +10,8 @@ */ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); + +$data = isset( $data ) && is_array( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
diff --git a/inc/Engine/CDN/RocketCDN/views/dashboard-status.php b/inc/Engine/CDN/RocketCDN/views/dashboard-status.php index ac22d8a4c2..48ab3841eb 100644 --- a/inc/Engine/CDN/RocketCDN/views/dashboard-status.php +++ b/inc/Engine/CDN/RocketCDN/views/dashboard-status.php @@ -14,6 +14,7 @@ * } */ +$data = isset( $data ) && is_array( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>

RocketCDN

diff --git a/inc/Engine/Common/Database/Queries/AbstractQuery.php b/inc/Engine/Common/Database/Queries/AbstractQuery.php index f74d93b1dc..29f15f599b 100644 --- a/inc/Engine/Common/Database/Queries/AbstractQuery.php +++ b/inc/Engine/Common/Database/Queries/AbstractQuery.php @@ -511,7 +511,7 @@ protected function table_exists(): bool { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } diff --git a/inc/Engine/Common/Database/Tables/AbstractTable.php b/inc/Engine/Common/Database/Tables/AbstractTable.php index f8fd6a6885..283c9736cc 100644 --- a/inc/Engine/Common/Database/Tables/AbstractTable.php +++ b/inc/Engine/Common/Database/Tables/AbstractTable.php @@ -49,7 +49,7 @@ public function delete_old_rows() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -89,7 +89,7 @@ public function get_old_rows(): array { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -113,7 +113,7 @@ public function remove_all_completed_rows() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } diff --git a/inc/Engine/CriticalPath/APIClient.php b/inc/Engine/CriticalPath/APIClient.php index ec285aa100..5112731297 100644 --- a/inc/Engine/CriticalPath/APIClient.php +++ b/inc/Engine/CriticalPath/APIClient.php @@ -108,7 +108,11 @@ private function get_response_success( $response_code, $response_data ) { return ( 200 === $response_code && - ! empty( $response_data ) + ( + $response_data instanceof stdClass + && + ! empty( (array) $response_data ) + ) && ( ( diff --git a/inc/Engine/License/views/promo-banner.php b/inc/Engine/License/views/promo-banner.php index 78c42b396f..73bd727d9b 100644 --- a/inc/Engine/License/views/promo-banner.php +++ b/inc/Engine/License/views/promo-banner.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
diff --git a/inc/Engine/License/views/renewal-expired-banner-ocd-disabled.php b/inc/Engine/License/views/renewal-expired-banner-ocd-disabled.php index 777030c6db..79995f55b6 100644 --- a/inc/Engine/License/views/renewal-expired-banner-ocd-disabled.php +++ b/inc/Engine/License/views/renewal-expired-banner-ocd-disabled.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>

diff --git a/inc/Engine/License/views/renewal-expired-banner-ocd.php b/inc/Engine/License/views/renewal-expired-banner-ocd.php index 5aad300ed6..e8bb28a4ee 100644 --- a/inc/Engine/License/views/renewal-expired-banner-ocd.php +++ b/inc/Engine/License/views/renewal-expired-banner-ocd.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>

diff --git a/inc/Engine/License/views/renewal-expired-banner.php b/inc/Engine/License/views/renewal-expired-banner.php index c3572769d2..eb294e4c03 100644 --- a/inc/Engine/License/views/renewal-expired-banner.php +++ b/inc/Engine/License/views/renewal-expired-banner.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>

diff --git a/inc/Engine/License/views/renewal-soon-banner.php b/inc/Engine/License/views/renewal-soon-banner.php index 46bb3392d7..18a16985f5 100644 --- a/inc/Engine/License/views/renewal-soon-banner.php +++ b/inc/Engine/License/views/renewal-soon-banner.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
    diff --git a/inc/Engine/License/views/upgrade-popin.php b/inc/Engine/License/views/upgrade-popin.php index 5a4ec990cd..af78aa4a51 100644 --- a/inc/Engine/License/views/upgrade-popin.php +++ b/inc/Engine/License/views/upgrade-popin.php @@ -6,6 +6,8 @@ */ defined( 'ABSPATH' ) || exit; + +$data = isset( $data ) ? $data : []; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound ?>
    diff --git a/inc/Engine/Media/AboveTheFold/Database/Queries/AboveTheFold.php b/inc/Engine/Media/AboveTheFold/Database/Queries/AboveTheFold.php index 74d539fa47..02230da8f7 100644 --- a/inc/Engine/Media/AboveTheFold/Database/Queries/AboveTheFold.php +++ b/inc/Engine/Media/AboveTheFold/Database/Queries/AboveTheFold.php @@ -85,7 +85,7 @@ public function make_job_completed( string $url, bool $is_mobile, array $data ) $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -115,7 +115,7 @@ public function delete_old_rows() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } diff --git a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php index f5bb1dece3..26856608f5 100644 --- a/inc/Engine/Media/AboveTheFold/Frontend/Controller.php +++ b/inc/Engine/Media/AboveTheFold/Frontend/Controller.php @@ -147,7 +147,7 @@ private function set_fetchpriority( $lcp, string $html ): string { 'picture', ]; - if ( empty( $lcp ) || empty( $lcp->type ) || ! in_array( $lcp->type, $allowed_types, true ) ) { + if ( empty( (array) $lcp ) || empty( $lcp->type ) || ! in_array( $lcp->type, $allowed_types, true ) ) { return $html; } @@ -488,7 +488,7 @@ private function generate_source_tags( $lcp, $start_tag, $end_tag ) { $link_attribute = ( substr_count( $source->srcset, ',' ) > 0 ) ? 'imagesrcset' : 'href'; // Append the source and media query to the tag string. - $tag .= $start_tag . $link_attribute . '="' . $source->srcset . '"' . ( $media ?? '' ) . $sizes . $end_tag; + $tag .= $start_tag . $link_attribute . '="' . $source->srcset . '"' . ( $media ) . $sizes . $end_tag; // If a max-width is found in the source's media attribute, update the previous max-width. if ( preg_match( '/\(max-width: (\d+(\.\d+)?)px\)/', $source->media, $matches ) ) { diff --git a/inc/Engine/Media/ImageDimensions/ImageDimensions.php b/inc/Engine/Media/ImageDimensions/ImageDimensions.php index 77e3832511..1a6f024299 100644 --- a/inc/Engine/Media/ImageDimensions/ImageDimensions.php +++ b/inc/Engine/Media/ImageDimensions/ImageDimensions.php @@ -208,10 +208,6 @@ private function is_external_file( $url ) { $hosts = array_unique( $hosts ); - if ( empty( $hosts ) ) { - return true; - } - // URL has domain and domain is part of the internal domains. if ( ! empty( $file['host'] ) ) { foreach ( $hosts as $host ) { diff --git a/inc/Engine/Optimization/CSSTrait.php b/inc/Engine/Optimization/CSSTrait.php index 58bbbf4641..3a90e18c1c 100644 --- a/inc/Engine/Optimization/CSSTrait.php +++ b/inc/Engine/Optimization/CSSTrait.php @@ -469,10 +469,6 @@ protected function is_external_path( $url ) { $hosts = array_unique( $hosts ); - if ( empty( $hosts ) ) { - return true; - } - // URL has domain and domain is part of the internal domains. if ( ! empty( $file['host'] ) ) { foreach ( $hosts as $host ) { diff --git a/inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php b/inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php index 9a8ba4a31a..27d40d8f53 100644 --- a/inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php +++ b/inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php @@ -499,6 +499,8 @@ private function add_used_fonts_preload( string $html, string $used_css ): strin // Making sure the excluded fonts array isn't empty to avoid excluding all fonts. if ( ! empty( $exclude_fonts_preload ) ) { + $exclude_fonts_preload = array_filter( $exclude_fonts_preload ); + // Combine the array elements into a single string with | as a separator and returning a pattern. $exclude_fonts_preload_pattern = implode( '|', diff --git a/inc/Engine/Optimization/RUCSS/Database/Queries/UsedCSS.php b/inc/Engine/Optimization/RUCSS/Database/Queries/UsedCSS.php index 89ed6188bf..99e8a5087c 100644 --- a/inc/Engine/Optimization/RUCSS/Database/Queries/UsedCSS.php +++ b/inc/Engine/Optimization/RUCSS/Database/Queries/UsedCSS.php @@ -87,7 +87,7 @@ public function make_status_completed( string $url, bool $is_mobile, string $has $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } diff --git a/inc/Engine/Optimization/UrlTrait.php b/inc/Engine/Optimization/UrlTrait.php index 07e5b08c30..979c6db72a 100644 --- a/inc/Engine/Optimization/UrlTrait.php +++ b/inc/Engine/Optimization/UrlTrait.php @@ -51,10 +51,6 @@ private function is_external_file( $url ) { $hosts = array_unique( $hosts ); - if ( empty( $hosts ) ) { - return true; - } - // URL has domain and domain is part of the internal domains. if ( ! empty( $file['host'] ) ) { foreach ( $hosts as $host ) { diff --git a/inc/Engine/Preload/Controller/PreloadUrl.php b/inc/Engine/Preload/Controller/PreloadUrl.php index a085e0ad8c..7e8f41987c 100755 --- a/inc/Engine/Preload/Controller/PreloadUrl.php +++ b/inc/Engine/Preload/Controller/PreloadUrl.php @@ -61,6 +61,9 @@ public function __construct( Options_Data $options, Queue $queue, Cache $rocket_ * @return void */ public function preload_url( string $url ) { + $start = 0; + $duration = 0; + $is_mobile = $this->options->get( 'do_caching_mobile_files', false ); if ( $this->is_already_cached( $url ) && ( ! $is_mobile || $this->is_already_cached( $url, true ) ) ) { diff --git a/inc/Engine/Preload/Database/Queries/Cache.php b/inc/Engine/Preload/Database/Queries/Cache.php index 82d06fb935..c03aa909e6 100644 --- a/inc/Engine/Preload/Database/Queries/Cache.php +++ b/inc/Engine/Preload/Database/Queries/Cache.php @@ -303,7 +303,7 @@ public function get_old_cache( float $delay = 1, string $unit = 'month' ): array $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return []; } @@ -473,7 +473,7 @@ public function revert_old_in_progress() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -489,7 +489,7 @@ public function revert_old_failed() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -505,7 +505,7 @@ public function set_all_to_pending() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -568,7 +568,7 @@ public function remove_all() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } @@ -603,7 +603,7 @@ public function unlock_all() { $db = $this->get_db(); // Bail if no database interface is available. - if ( empty( $db ) ) { + if ( ! $db ) { return false; } diff --git a/inc/ThirdParty/Plugins/Optimization/AMP.php b/inc/ThirdParty/Plugins/Optimization/AMP.php index 5b66ae55fb..2a27e9ae3f 100644 --- a/inc/ThirdParty/Plugins/Optimization/AMP.php +++ b/inc/ThirdParty/Plugins/Optimization/AMP.php @@ -126,7 +126,7 @@ public function disable_options_on_amp() { global $wp_filter; - remove_filter( 'wp_resource_hints', 'rocket_dns_prefetch', 10, 2 ); + remove_filter( 'wp_resource_hints', 'rocket_dns_prefetch', 10 ); add_filter( 'do_rocket_lazyload', '__return_false' ); add_filter( 'do_rocket_lazyload_iframes', '__return_false' ); add_filter( 'pre_get_rocket_option_async_css', '__return_false' ); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 71ae4fda0b..db347384e3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,7 +1,7 @@ includes: - phar://phpstan.phar/conf/bleedingEdge.neon parameters: - level: 0 + level: 1 inferPrivatePropertyTypeFromConstructor: true paths: # Test only the new architecture for now. @@ -13,6 +13,8 @@ parameters: bootstrapFiles: # Must be first - %currentWorkingDirectory%/inc/functions/options.php + # PHPStan bootstrap + - %currentWorkingDirectory%/tests/phpstan/phpstan-bootstrap.php # Procedural code - %currentWorkingDirectory%/inc/constants.php - %currentWorkingDirectory%/inc/common/purge.php @@ -41,6 +43,7 @@ parameters: - %currentWorkingDirectory%/inc/admin/options.php - %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php - %currentWorkingDirectory%/vendor/php-stubs/wordpress-tests-stubs/wordpress-tests-stubs.php + - %currentWorkingDirectory%/wp-rocket.php excludePaths: - %currentWorkingDirectory%/inc/vendors/ # These need plugin stubs! diff --git a/tests/Fixtures/inc/ThirdParty/Hostings/LiteSpeed/override_header_functions.php b/tests/Fixtures/inc/ThirdParty/Hostings/LiteSpeed/override_header_functions.php index 0adabf1196..4d47890a17 100644 --- a/tests/Fixtures/inc/ThirdParty/Hostings/LiteSpeed/override_header_functions.php +++ b/tests/Fixtures/inc/ThirdParty/Hostings/LiteSpeed/override_header_functions.php @@ -10,7 +10,7 @@ function headers_sent() return false; } -function header($string) +function header($string, $replace) { if ( in_array( $string , HeaderCollector::$headers, true ) ) { return; diff --git a/tests/Fixtures/inc/ThirdParty/Plugins/SEO/SEOPress/fixtures.php b/tests/Fixtures/inc/ThirdParty/Plugins/SEO/SEOPress/fixtures.php index d66b82443c..f4af1fd2a4 100644 --- a/tests/Fixtures/inc/ThirdParty/Plugins/SEO/SEOPress/fixtures.php +++ b/tests/Fixtures/inc/ThirdParty/Plugins/SEO/SEOPress/fixtures.php @@ -1,6 +1,6 @@ filesystem->put_contents( $item_path, '.cpcss { color: red; }'); $this->assertTrue( $this->filesystem->exists( $item_path ) ); + $mobile_item_path = ''; + if ( $this->async_css_mobile ) { $mobile_item_path = 'wp-content/cache/critical-css/1/posts' . DIRECTORY_SEPARATOR . "{$post_type}-" . self::$post_id . "-mobile.css"; $this->filesystem->put_contents( $mobile_item_path, '.cpcss-mobile { color: red; }'); diff --git a/tests/Integration/inc/Engine/CriticalPath/ProcessorService/processGenerate.php b/tests/Integration/inc/Engine/CriticalPath/ProcessorService/processGenerate.php index 0a9ad2c3c9..862b0f61d1 100644 --- a/tests/Integration/inc/Engine/CriticalPath/ProcessorService/processGenerate.php +++ b/tests/Integration/inc/Engine/CriticalPath/ProcessorService/processGenerate.php @@ -138,7 +138,7 @@ public function testShouldDoExpected( $config, $expected ) { } } - if ( isset( $save_cpcss ) && is_wp_error( $save_cpcss ) ) { + if ( is_wp_error( $save_cpcss ) ) { $this->filesystem->chmod( 'wp-content/cache/critical-css/1/', 0444 ); } diff --git a/tests/Integration/inc/Engine/Media/ImageDimensions/Subscriber/specifyImageDimensions.php b/tests/Integration/inc/Engine/Media/ImageDimensions/Subscriber/specifyImageDimensions.php index 1269bfbe06..aec2370c49 100644 --- a/tests/Integration/inc/Engine/Media/ImageDimensions/Subscriber/specifyImageDimensions.php +++ b/tests/Integration/inc/Engine/Media/ImageDimensions/Subscriber/specifyImageDimensions.php @@ -28,7 +28,7 @@ public function tear_down() { remove_filter( 'rocket_specify_image_dimensions', [$this, 'filter_rocket_specify_image_dimensions'] ); } - if ( isset( $config['rocket_specify_dimension_skip_pictures_filter'] ) ){ + if ( isset( $this->config_data['rocket_specify_dimension_skip_pictures_filter'] ) ){ remove_filter( 'rocket_specify_dimension_skip_pictures', [$this, 'filter_rocket_specify_dimension_skip_pictures'] ); } diff --git a/tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php b/tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php index ca19af9e4b..52ef757140 100644 --- a/tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php +++ b/tests/Integration/inc/Engine/Optimization/DelayJS/Subscriber/delayJs.php @@ -40,7 +40,7 @@ public function tear_down() { delete_transient( 'wpr_dynamic_lists' ); if ( isset( $this->post->ID ) ) { - delete_post_meta( $this->post->ID, '_rocket_exclude_delay_js', 1, true ); + delete_post_meta( $this->post->ID, '_rocket_exclude_delay_js', 1 ); } $this->restoreWpHook( 'rocket_buffer' ); diff --git a/tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php b/tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php index dc04c5b875..5b1c3fb795 100644 --- a/tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php +++ b/tests/Integration/inc/Engine/Optimization/RUCSS/Frontend/Subscriber/maybeDisablePreloadFonts.php @@ -30,7 +30,7 @@ public function tear_down() { remove_filter( 'pre_get_rocket_option_remove_unused_css', [ $this, 'rucss' ] ); if ( isset( $this->post->ID ) ) { - delete_post_meta( $this->post->ID, '_rocket_exclude_remove_unused_css', 1, true ); + delete_post_meta( $this->post->ID, '_rocket_exclude_remove_unused_css', 1 ); } remove_filter( 'pre_option_wp_rocket_prewarmup_stats', [ $this, 'return_prewarmup_stats' ] ); diff --git a/tests/Unit/inc/Engine/Cache/Purge/purgePostTermsUrls.php b/tests/Unit/inc/Engine/Cache/Purge/purgePostTermsUrls.php index b95b242715..795ce442ab 100644 --- a/tests/Unit/inc/Engine/Cache/Purge/purgePostTermsUrls.php +++ b/tests/Unit/inc/Engine/Cache/Purge/purgePostTermsUrls.php @@ -120,7 +120,7 @@ public function testShouldReturnExpectedUrls( $post_data, $terms, $expected ) { } } } - Filters\expectApplied( 'rocket_post_terms_urls', $expected )->once(); + Filters\expectApplied( 'rocket_post_terms_urls' )->once(); $this->stubWpParseUrl(); diff --git a/tests/Unit/inc/Engine/Common/JobManager/Strategy/Strategies/JobSetFail/execute.php b/tests/Unit/inc/Engine/Common/JobManager/Strategy/Strategies/JobSetFail/execute.php index 6f4f6862c0..fe43ed9e04 100644 --- a/tests/Unit/inc/Engine/Common/JobManager/Strategy/Strategies/JobSetFail/execute.php +++ b/tests/Unit/inc/Engine/Common/JobManager/Strategy/Strategies/JobSetFail/execute.php @@ -34,6 +34,10 @@ public function testShouldBehaveAsExpected( $config, $expected ) } else { $row_details = null; } + $job_details = [ + 'code' => '', + 'message' => '', + ]; if ( isset( $config['job_details'] ) ) { $job_details = $config['job_details']; } diff --git a/tests/Unit/inc/Engine/CriticalPath/Admin/Admin/enqueueAdminCpcssHeartbeatScript.php b/tests/Unit/inc/Engine/CriticalPath/Admin/Admin/enqueueAdminCpcssHeartbeatScript.php index 781ddd90f0..368c8661d0 100644 --- a/tests/Unit/inc/Engine/CriticalPath/Admin/Admin/enqueueAdminCpcssHeartbeatScript.php +++ b/tests/Unit/inc/Engine/CriticalPath/Admin/Admin/enqueueAdminCpcssHeartbeatScript.php @@ -44,7 +44,7 @@ public function testShouldEnqueueAdminScript( $config, $expected ) { ->andReturn( $config['options']['async_css'] ); if ( $expected ) { - $this->assertExpected( $config ); + $this->assertExpected(); } else { $this->assertNotExpected(); } diff --git a/tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php b/tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php index c822fa3071..411690687a 100644 --- a/tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php +++ b/tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/disableOptionsOnAmp.php @@ -58,7 +58,7 @@ public function testShouldDoExpected( $config, $expected ) { // Check the hooks before invoking the method. $this->assertSame( 10, - has_filter( 'wp_resource_hints', 'rocket_dns_prefetch', 10, 2 ) + has_filter( 'wp_resource_hints', 'rocket_dns_prefetch' ) ); $this->assertFalse( has_filter( 'do_rocket_lazyload', '__return_false' ) ); $this->assertFalse( has_filter( 'do_rocket_lazyload_iframes', '__return_false' ) ); @@ -70,7 +70,7 @@ public function testShouldDoExpected( $config, $expected ) { $this->assertSame( PHP_INT_MAX, - has_filter( 'wp_calculate_image_srcset', 'rocket_protocol_rewrite_srcset', PHP_INT_MAX ) + has_filter( 'wp_calculate_image_srcset', 'rocket_protocol_rewrite_srcset' ) ); $this->assertFalse( has_filter( 'rocket_buffer', [ $this->cdn_subscriber, 'rewrite' ] ) ); $this->assertFalse( has_filter( 'rocket_buffer', [ $this->cdn_subscriber, 'rewrite_srcset' ] ) ); @@ -85,7 +85,7 @@ public function testShouldDoExpected( $config, $expected ) { if ( ! $expected[ 'bailout' ] ) { // Check the hooks after invoking the method. - $this->assertFalse( has_filter( 'wp_resource_hints', 'rocket_dns_prefetch', 10, 2 ) ); + $this->assertFalse( has_filter( 'wp_resource_hints', 'rocket_dns_prefetch' ) ); $this->assertSame( 10, has_filter( 'do_rocket_lazyload', '__return_false' ) diff --git a/tests/Unit/inc/functions/rocketRrmdir.php b/tests/Unit/inc/functions/rocketRrmdir.php index dc88aea255..40a9f94db9 100644 --- a/tests/Unit/inc/functions/rocketRrmdir.php +++ b/tests/Unit/inc/functions/rocketRrmdir.php @@ -31,7 +31,7 @@ public function testShouldRecursivelyRemoveFilesAndDirectories( $to_delete, $to_ rocket_rrmdir( $to_delete, $to_preserve ); $dump_results = isset( $expected['dump_results'] ); - $this->checkEntriesDeleted( $expected['removed'], $dump_results ); + $this->checkEntriesDeleted( $expected['removed'] ); $this->checkShouldNotDeleteEntries( $dump_results ); } } diff --git a/tests/phpstan/phpstan-bootstrap.php b/tests/phpstan/phpstan-bootstrap.php new file mode 100644 index 0000000000..0577e85f32 --- /dev/null +++ b/tests/phpstan/phpstan-bootstrap.php @@ -0,0 +1,10 @@ +