From c8552c82d7f6a2a1f0e624e2aa8cb26707fb0070 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 9 Dec 2024 17:52:30 +0100 Subject: [PATCH 1/5] Don't redeclare constant --- tools/phpstan/constants.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/phpstan/constants.php b/tools/phpstan/constants.php index ae469bf4dc..d740676c88 100644 --- a/tools/phpstan/constants.php +++ b/tools/phpstan/constants.php @@ -17,5 +17,3 @@ define( 'IMAGE_PRIORITIZER_VERSION', '0.0.0' ); define( 'EMBED_OPTIMIZER_VERSION', '0.0.0' ); - -define( 'PERFLAB_PLUGIN_DIR_PATH', __DIR__ . '/../../plugins/performance-lab/' ); From 238f29687be1bb6d8fd998a79e9549319ee52bd9 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 9 Dec 2024 17:52:41 +0100 Subject: [PATCH 2/5] Install `swissspidy/phpstan-no-private` --- composer.json | 3 ++- composer.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 1503fcf405..78df2c8070 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "wp-phpunit/wp-phpunit": "^6.5", "yoast/phpunit-polyfills": "^2.0", "phpstan/php-8-stubs": "^0.4.0", - "phpstan/phpstan-strict-rules": "^1.6" + "phpstan/phpstan-strict-rules": "^1.6", + "swissspidy/phpstan-no-private": "^0.2.1" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index f2daba96fe..a57aace60c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "99a4ff17fc479a208dfeba7f135911b8", + "content-hash": "6743d9445c398a38701df2d3af11dfa0", "packages": [], "packages-dev": [ { @@ -2209,6 +2209,57 @@ ], "time": "2024-11-16T12:02:36+00:00" }, + { + "name": "swissspidy/phpstan-no-private", + "version": "v0.2.1", + "source": { + "type": "git", + "url": "https://github.com/swissspidy/phpstan-no-private.git", + "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/f7a1890e350c8d8bf26370426a971d7490ae4245", + "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10.3" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-php-parser": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5", + "slevomat/coding-standard": "^8.8.0", + "squizlabs/php_codesniffer": "^3.5.3" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Swissspidy\\PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of pseudo-private functions, classes, and methods.", + "support": { + "issues": "https://github.com/swissspidy/phpstan-no-private/issues", + "source": "https://github.com/swissspidy/phpstan-no-private/tree/v0.2.1" + }, + "time": "2024-06-05T10:03:17+00:00" + }, { "name": "symfony/polyfill-php73", "version": "v1.30.0", @@ -2578,14 +2629,14 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^7.2 || ^8.0", "ext-json": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "7.2" }, From e798de94ed7ec572228f8bcafde3f56ddcba766b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 10 Dec 2024 09:53:59 +0100 Subject: [PATCH 3/5] Update PHPStan config --- phpstan.neon.dist | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c66cc423a5..1f21368b59 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -66,6 +66,15 @@ parameters: - identifier: staticMethod.dynamicCall path: */tests/* + - + identifier: no.private.class + path: */tests/* + - + identifier: no.private.method + path: */tests/* + - + identifier: no.private.function + path: */tests/* - # TODO: Remove this to fix https://github.com/WordPress/performance/issues/1219 identifier: empty.notAllowed From 95793ee4c1b47536d35b6633bbd662cdc0f5ba16 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 10 Dec 2024 13:41:32 +0100 Subject: [PATCH 4/5] Move PL hooks to own file --- plugins/performance-lab/hooks.php | 306 ++++++++++++++++++++++++++++++ plugins/performance-lab/load.php | 296 +---------------------------- 2 files changed, 308 insertions(+), 294 deletions(-) create mode 100644 plugins/performance-lab/hooks.php diff --git a/plugins/performance-lab/hooks.php b/plugins/performance-lab/hooks.php new file mode 100644 index 0000000000..31a678f618 --- /dev/null +++ b/plugins/performance-lab/hooks.php @@ -0,0 +1,306 @@ + $constant_name ) { + if ( defined( $constant_name ) && ! str_starts_with( constant( $constant_name ), 'Performance Lab ' ) ) { + $active_plugins[] = $plugin_slug; + } + } + + return sprintf( + // Use the plugin slug as it is immutable. + 'performance-lab %1$s; plugins: %2$s', + PERFLAB_VERSION, + implode( ', ', $active_plugins ) + ); +} + +/** + * Displays the HTML generator tag for the Performance Lab plugin. + * + * See {@see 'wp_head'}. + * + * @since 1.1.0 + */ +function perflab_render_generator(): void { + $content = perflab_get_generator_content(); + + echo '' . "\n"; +} +add_action( 'wp_head', 'perflab_render_generator' ); + +/** + * Gets the standalone plugins and their data. + * + * @since 3.0.0 + * + * @return array Associative array of $plugin_slug => $plugin_data pairs. + */ +function perflab_get_standalone_plugin_data(): array { + /* + * Alphabetically sorted list of plugin slugs and their data. + * Supported keys per plugin are: + * - 'constant' (string, required) + * - 'experimental' (boolean, optional) + */ + return array( + 'auto-sizes' => array( + 'constant' => 'IMAGE_AUTO_SIZES_VERSION', + 'experimental' => true, + ), + 'dominant-color-images' => array( + 'constant' => 'DOMINANT_COLOR_IMAGES_VERSION', + ), + 'embed-optimizer' => array( + 'constant' => 'EMBED_OPTIMIZER_VERSION', + 'experimental' => true, + ), + 'image-prioritizer' => array( + 'constant' => 'IMAGE_PRIORITIZER_VERSION', + 'experimental' => true, + ), + 'performant-translations' => array( + 'constant' => 'PERFORMANT_TRANSLATIONS_VERSION', + ), + 'speculation-rules' => array( + 'constant' => 'SPECULATION_RULES_VERSION', + ), + 'web-worker-offloading' => array( + 'constant' => 'WEB_WORKER_OFFLOADING_VERSION', + 'experimental' => true, + ), + 'webp-uploads' => array( + 'constant' => 'WEBP_UPLOADS_VERSION', + ), + ); +} + +/** + * Gets the standalone plugin constants used for each available standalone plugin. + * + * @since 2.9.0 + * @since 3.0.0 The $source parameter was removed. + * + * @return array Map of plugin slug and the version constant used. + */ +function perflab_get_standalone_plugin_version_constants(): array { + return wp_list_pluck( perflab_get_standalone_plugin_data(), 'constant' ); +} + +/** + * Places the Performance Lab's object cache drop-in in the drop-ins folder. + * + * This only runs in WP Admin to not have any potential performance impact on + * the frontend. + * + * This function will short-circuit if at least one of the constants + * 'PERFLAB_DISABLE_SERVER_TIMING' or 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is + * set as true. + * + * @since 1.8.0 + * @since 2.1.0 No longer attempts to use two of the drop-ins together. + * + * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. + */ +function perflab_maybe_set_object_cache_dropin(): void { + global $wp_filesystem; + + // Bail if Server-Timing is disabled entirely. + if ( defined( 'PERFLAB_DISABLE_SERVER_TIMING' ) && PERFLAB_DISABLE_SERVER_TIMING ) { + return; + } + + // Bail if disabled via constant. + if ( defined( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) { + return; + } + + /** + * Filters whether the Perflab server timing drop-in should be set. + * + * @since 2.0.0 + * + * @param bool $disabled Whether to disable the server timing drop-in. Default false. + */ + if ( apply_filters( 'perflab_disable_object_cache_dropin', false ) ) { + return; + } + + /** + * Filters the value of the `object-cache.php` drop-in constant. + * + * This filter should not be used outside of tests. + * + * @since 3.0.0 + * @internal + * + * @param int|bool $current_dropin_version The drop-in version as defined by the + * `PERFLAB_OBJECT_CACHE_DROPIN_VERSION` constant. + */ + $current_dropin_version = apply_filters( 'perflab_object_cache_dropin_version', PERFLAB_OBJECT_CACHE_DROPIN_VERSION ); + + // Bail if already placed in the latest version or newer. + if ( null !== $current_dropin_version && $current_dropin_version >= PERFLAB_OBJECT_CACHE_DROPIN_LATEST_VERSION ) { + return; + } + + // Bail if already attempted before timeout has been completed. + // This is present in case placing the file fails for some reason, to avoid + // excessively retrying to place it on every request. + $timeout = get_transient( 'perflab_set_object_cache_dropin' ); + if ( false !== $timeout ) { + return; + } + + if ( $wp_filesystem instanceof WP_Filesystem_Base || true === WP_Filesystem() ) { + $dropin_path = WP_CONTENT_DIR . '/object-cache.php'; + + /* + * If there is an actual object-cache.php file, it is most likely from + * a third party, or it may be an older version of the Performance Lab + * object-cache.php. If it's from a third party, do not replace it. + * + * Previous versions of the Performance Lab plugin were renaming the + * original object-cache.php file and then loading both. However, due + * to other plugins eagerly checking file headers, this caused too many + * problems across sites, so it was decided to remove this layer. + * Only placing the drop-in file if no other one exists yet is the + * safest solution. + */ + if ( $wp_filesystem->exists( $dropin_path ) ) { + // If this constant evaluates to `false`, the existing file is for sure from a third party. + if ( false === $current_dropin_version ) { + // Set timeout of 1 day before retrying again (only in case the file already exists). + set_transient( 'perflab_set_object_cache_dropin', true, DAY_IN_SECONDS ); + return; + } + + // Otherwise, verify that it's actually the Performance Lab drop-in. + $test_content = "get_contents( $dropin_path ), $test_content ) ) { + // Set timeout of 1 day before retrying again (only in case the file already exists). + set_transient( 'perflab_set_object_cache_dropin', true, DAY_IN_SECONDS ); + return; + } + + /* + * If this logic is reached, the existing file is an older version + * of the Performance Lab drop-in, so it can be safely deleted, and + * then be replaced below. + */ + $wp_filesystem->delete( $dropin_path ); + } + + $wp_filesystem->copy( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php', $dropin_path ); + } + + // Set timeout of 1 hour before retrying again (only relevant in case the above failed). + set_transient( 'perflab_set_object_cache_dropin', true, HOUR_IN_SECONDS ); +} +add_action( 'admin_init', 'perflab_maybe_set_object_cache_dropin' ); + +/** + * Removes the Performance Lab's object cache drop-in from the drop-ins folder. + * + * This function should be run on plugin deactivation. For backward compatibility with + * an earlier implementation of `perflab_maybe_set_object_cache_dropin()`, this function + * checks whether there is an object-cache-plst-orig.php file, and if so restores it. + * + * This function will short-circuit if the constant + * 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is set as true. + * + * @since 1.8.0 + * + * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. + */ +function perflab_maybe_remove_object_cache_dropin(): void { + global $wp_filesystem; + + // Bail if disabled via constant. + if ( defined( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) { + return; + } + + // Bail if custom drop-in not present anyway. + if ( false === PERFLAB_OBJECT_CACHE_DROPIN_VERSION ) { + return; + } + + if ( $wp_filesystem instanceof WP_Filesystem_Base || true === WP_Filesystem() ) { + $dropin_path = WP_CONTENT_DIR . '/object-cache.php'; + $dropin_backup_path = WP_CONTENT_DIR . '/object-cache-plst-orig.php'; + + /** + * If there is an object-cache-plst-orig.php file, restore it and + * override the Performance Lab file. This is only relevant for + * backward-compatibility with previous Performance Lab versions + * which were backing up the file and then loading both. + * Otherwise, just delete the Performance Lab file. + */ + if ( $wp_filesystem->exists( $dropin_backup_path ) ) { + $wp_filesystem->move( $dropin_backup_path, $dropin_path, true ); + } else { + $wp_filesystem->delete( $dropin_path ); + } + } + + // Delete transient for drop-in check in case the plugin is reactivated shortly after. + delete_transient( 'perflab_set_object_cache_dropin' ); +} +register_deactivation_hook( __FILE__, 'perflab_maybe_remove_object_cache_dropin' ); + +/** + * Redirects legacy module page to the performance feature page. + * + * @since 3.0.0 + * + * @global $plugin_page + */ +function perflab_no_access_redirect_module_to_performance_feature_page(): void { + global $plugin_page; + + if ( 'perflab-modules' !== $plugin_page ) { + return; + } + + if ( + current_user_can( 'manage_options' ) && + wp_safe_redirect( add_query_arg( 'page', PERFLAB_SCREEN ) ) + ) { + exit; + } +} +add_action( 'admin_page_access_denied', 'perflab_no_access_redirect_module_to_performance_feature_page' ); + +/** + * Cleanup function to delete legacy 'perflab_modules_settings' option if present. + * + * @since 3.0.0 + */ +function perflab_cleanup_option(): void { + if ( current_user_can( 'manage_options' ) ) { + delete_option( 'perflab_modules_settings' ); + } +} +add_action( 'admin_init', 'perflab_cleanup_option' ); diff --git a/plugins/performance-lab/load.php b/plugins/performance-lab/load.php index 3cc0674036..89937e38e0 100644 --- a/plugins/performance-lab/load.php +++ b/plugins/performance-lab/load.php @@ -30,6 +30,8 @@ } define( 'PERFLAB_OBJECT_CACHE_DROPIN_LATEST_VERSION', 3 ); +require_once __DIR__ . '/hooks.php'; + // Load server-timing API. require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing-metric.php'; require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/class-perflab-server-timing.php'; @@ -39,300 +41,6 @@ // Load site health checks. require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/site-health/load.php'; -/** - * Gets the content attribute for the generator tag for the Performance Lab plugin. - * - * This attribute is then used in {@see perflab_render_generator()}. - * - * @since 1.1.0 - * @since 2.9.0 The generator tag now includes the active standalone plugin slugs. - * @since 3.0.0 The generator tag no longer includes module slugs. - */ -function perflab_get_generator_content(): string { - $active_plugins = array(); - foreach ( perflab_get_standalone_plugin_version_constants() as $plugin_slug => $constant_name ) { - if ( defined( $constant_name ) && ! str_starts_with( constant( $constant_name ), 'Performance Lab ' ) ) { - $active_plugins[] = $plugin_slug; - } - } - - return sprintf( - // Use the plugin slug as it is immutable. - 'performance-lab %1$s; plugins: %2$s', - PERFLAB_VERSION, - implode( ', ', $active_plugins ) - ); -} - -/** - * Displays the HTML generator tag for the Performance Lab plugin. - * - * See {@see 'wp_head'}. - * - * @since 1.1.0 - */ -function perflab_render_generator(): void { - $content = perflab_get_generator_content(); - - echo '' . "\n"; -} -add_action( 'wp_head', 'perflab_render_generator' ); - -/** - * Gets the standalone plugins and their data. - * - * @since 3.0.0 - * - * @return array Associative array of $plugin_slug => $plugin_data pairs. - */ -function perflab_get_standalone_plugin_data(): array { - /* - * Alphabetically sorted list of plugin slugs and their data. - * Supported keys per plugin are: - * - 'constant' (string, required) - * - 'experimental' (boolean, optional) - */ - return array( - 'auto-sizes' => array( - 'constant' => 'IMAGE_AUTO_SIZES_VERSION', - 'experimental' => true, - ), - 'dominant-color-images' => array( - 'constant' => 'DOMINANT_COLOR_IMAGES_VERSION', - ), - 'embed-optimizer' => array( - 'constant' => 'EMBED_OPTIMIZER_VERSION', - 'experimental' => true, - ), - 'image-prioritizer' => array( - 'constant' => 'IMAGE_PRIORITIZER_VERSION', - 'experimental' => true, - ), - 'performant-translations' => array( - 'constant' => 'PERFORMANT_TRANSLATIONS_VERSION', - ), - 'speculation-rules' => array( - 'constant' => 'SPECULATION_RULES_VERSION', - ), - 'web-worker-offloading' => array( - 'constant' => 'WEB_WORKER_OFFLOADING_VERSION', - 'experimental' => true, - ), - 'webp-uploads' => array( - 'constant' => 'WEBP_UPLOADS_VERSION', - ), - ); -} - -/** - * Gets the standalone plugin constants used for each available standalone plugin. - * - * @since 2.9.0 - * @since 3.0.0 The $source parameter was removed. - * - * @return array Map of plugin slug and the version constant used. - */ -function perflab_get_standalone_plugin_version_constants(): array { - return wp_list_pluck( perflab_get_standalone_plugin_data(), 'constant' ); -} - -/** - * Places the Performance Lab's object cache drop-in in the drop-ins folder. - * - * This only runs in WP Admin to not have any potential performance impact on - * the frontend. - * - * This function will short-circuit if at least one of the constants - * 'PERFLAB_DISABLE_SERVER_TIMING' or 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is - * set as true. - * - * @since 1.8.0 - * @since 2.1.0 No longer attempts to use two of the drop-ins together. - * - * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. - */ -function perflab_maybe_set_object_cache_dropin(): void { - global $wp_filesystem; - - // Bail if Server-Timing is disabled entirely. - if ( defined( 'PERFLAB_DISABLE_SERVER_TIMING' ) && PERFLAB_DISABLE_SERVER_TIMING ) { - return; - } - - // Bail if disabled via constant. - if ( defined( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) { - return; - } - - /** - * Filters whether the Perflab server timing drop-in should be set. - * - * @since 2.0.0 - * - * @param bool $disabled Whether to disable the server timing drop-in. Default false. - */ - if ( apply_filters( 'perflab_disable_object_cache_dropin', false ) ) { - return; - } - - /** - * Filters the value of the `object-cache.php` drop-in constant. - * - * This filter should not be used outside of tests. - * - * @since 3.0.0 - * @internal - * - * @param int|bool $current_dropin_version The drop-in version as defined by the - * `PERFLAB_OBJECT_CACHE_DROPIN_VERSION` constant. - */ - $current_dropin_version = apply_filters( 'perflab_object_cache_dropin_version', PERFLAB_OBJECT_CACHE_DROPIN_VERSION ); - - // Bail if already placed in the latest version or newer. - if ( null !== $current_dropin_version && $current_dropin_version >= PERFLAB_OBJECT_CACHE_DROPIN_LATEST_VERSION ) { - return; - } - - // Bail if already attempted before timeout has been completed. - // This is present in case placing the file fails for some reason, to avoid - // excessively retrying to place it on every request. - $timeout = get_transient( 'perflab_set_object_cache_dropin' ); - if ( false !== $timeout ) { - return; - } - - if ( $wp_filesystem instanceof WP_Filesystem_Base || true === WP_Filesystem() ) { - $dropin_path = WP_CONTENT_DIR . '/object-cache.php'; - - /* - * If there is an actual object-cache.php file, it is most likely from - * a third party, or it may be an older version of the Performance Lab - * object-cache.php. If it's from a third party, do not replace it. - * - * Previous versions of the Performance Lab plugin were renaming the - * original object-cache.php file and then loading both. However, due - * to other plugins eagerly checking file headers, this caused too many - * problems across sites, so it was decided to remove this layer. - * Only placing the drop-in file if no other one exists yet is the - * safest solution. - */ - if ( $wp_filesystem->exists( $dropin_path ) ) { - // If this constant evaluates to `false`, the existing file is for sure from a third party. - if ( false === $current_dropin_version ) { - // Set timeout of 1 day before retrying again (only in case the file already exists). - set_transient( 'perflab_set_object_cache_dropin', true, DAY_IN_SECONDS ); - return; - } - - // Otherwise, verify that it's actually the Performance Lab drop-in. - $test_content = "get_contents( $dropin_path ), $test_content ) ) { - // Set timeout of 1 day before retrying again (only in case the file already exists). - set_transient( 'perflab_set_object_cache_dropin', true, DAY_IN_SECONDS ); - return; - } - - /* - * If this logic is reached, the existing file is an older version - * of the Performance Lab drop-in, so it can be safely deleted, and - * then be replaced below. - */ - $wp_filesystem->delete( $dropin_path ); - } - - $wp_filesystem->copy( PERFLAB_PLUGIN_DIR_PATH . 'includes/server-timing/object-cache.copy.php', $dropin_path ); - } - - // Set timeout of 1 hour before retrying again (only relevant in case the above failed). - set_transient( 'perflab_set_object_cache_dropin', true, HOUR_IN_SECONDS ); -} -add_action( 'admin_init', 'perflab_maybe_set_object_cache_dropin' ); - -/** - * Removes the Performance Lab's object cache drop-in from the drop-ins folder. - * - * This function should be run on plugin deactivation. For backward compatibility with - * an earlier implementation of `perflab_maybe_set_object_cache_dropin()`, this function - * checks whether there is an object-cache-plst-orig.php file, and if so restores it. - * - * This function will short-circuit if the constant - * 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is set as true. - * - * @since 1.8.0 - * - * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. - */ -function perflab_maybe_remove_object_cache_dropin(): void { - global $wp_filesystem; - - // Bail if disabled via constant. - if ( defined( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) { - return; - } - - // Bail if custom drop-in not present anyway. - if ( ! PERFLAB_OBJECT_CACHE_DROPIN_VERSION ) { - return; - } - - if ( $wp_filesystem instanceof WP_Filesystem_Base || true === WP_Filesystem() ) { - $dropin_path = WP_CONTENT_DIR . '/object-cache.php'; - $dropin_backup_path = WP_CONTENT_DIR . '/object-cache-plst-orig.php'; - - /** - * If there is an object-cache-plst-orig.php file, restore it and - * override the Performance Lab file. This is only relevant for - * backward-compatibility with previous Performance Lab versions - * which were backing up the file and then loading both. - * Otherwise, just delete the Performance Lab file. - */ - if ( $wp_filesystem->exists( $dropin_backup_path ) ) { - $wp_filesystem->move( $dropin_backup_path, $dropin_path, true ); - } else { - $wp_filesystem->delete( $dropin_path ); - } - } - - // Delete transient for drop-in check in case the plugin is reactivated shortly after. - delete_transient( 'perflab_set_object_cache_dropin' ); -} -register_deactivation_hook( __FILE__, 'perflab_maybe_remove_object_cache_dropin' ); - -/** - * Redirects legacy module page to the performance feature page. - * - * @since 3.0.0 - * - * @global $plugin_page - */ -function perflab_no_access_redirect_module_to_performance_feature_page(): void { - global $plugin_page; - - if ( 'perflab-modules' !== $plugin_page ) { - return; - } - - if ( - current_user_can( 'manage_options' ) && - wp_safe_redirect( add_query_arg( 'page', PERFLAB_SCREEN ) ) - ) { - exit; - } -} -add_action( 'admin_page_access_denied', 'perflab_no_access_redirect_module_to_performance_feature_page' ); - -/** - * Cleanup function to delete legacy 'perflab_modules_settings' option if present. - * - * @since 3.0.0 - */ -function perflab_cleanup_option(): void { - if ( current_user_can( 'manage_options' ) ) { - delete_option( 'perflab_modules_settings' ); - } -} -add_action( 'admin_init', 'perflab_cleanup_option' ); - // Only load admin integration when in admin. if ( is_admin() ) { require_once PERFLAB_PLUGIN_DIR_PATH . 'includes/admin/load.php'; From 498e0fbc3093a99aa476ffe240d8336d0542f833 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 10 Dec 2024 13:42:34 +0100 Subject: [PATCH 5/5] PHPStan 2 --- composer.json | 18 +- composer.lock | 587 +----------------- phpstan.neon.dist | 51 +- phpstan/composer.json | 20 + phpstan/composer.lock | 468 ++++++++++++++ .../class-od-html-tag-processor.php | 1 + plugins/webp-uploads/hooks.php | 1 + tools/phpstan/constants.php | 11 + 8 files changed, 581 insertions(+), 576 deletions(-) create mode 100644 phpstan/composer.json create mode 100644 phpstan/composer.lock diff --git a/composer.json b/composer.json index 78df2c8070..1ed0368194 100644 --- a/composer.json +++ b/composer.json @@ -21,24 +21,15 @@ }, "require-dev": { "phpcompatibility/php-compatibility": "^9.3", - "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^1.11", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", "slevomat/coding-standard": "^8.0", "squizlabs/php_codesniffer": "^3.9", - "szepeviktor/phpstan-wordpress": "^1.3", "wp-coding-standards/wpcs": "^3.1", "wp-phpunit/wp-phpunit": "^6.5", - "yoast/phpunit-polyfills": "^2.0", - "phpstan/php-8-stubs": "^0.4.0", - "phpstan/phpstan-strict-rules": "^1.6", - "swissspidy/phpstan-no-private": "^0.2.1" + "yoast/phpunit-polyfills": "^2.0" }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { "php": "7.2" @@ -89,7 +80,10 @@ "lint:speculation-rules": "@lint -- ./plugins/speculation-rules --standard=./plugins/speculation-rules/phpcs.xml.dist", "lint:web-worker-offloading": "@lint -- ./plugins/web-worker-offloading --standard=./plugins/web-worker-offloading/phpcs.xml.dist", "lint:webp-uploads": "@lint -- ./plugins/webp-uploads --standard=./plugins/webp-uploads/phpcs.xml.dist", - "phpstan": "phpstan analyse --memory-limit=2048M", + "phpstan": [ + "composer --working-dir=phpstan install --no-interaction", + "phpstan/vendor/bin/phpstan analyse --memory-limit=2048M" + ], "test": "phpunit --strict-coverage", "test-multisite": [ "WP_MULTISITE=1 phpunit --exclude-group=ms-excluded" diff --git a/composer.lock b/composer.lock index a57aace60c..e58a6ec21b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6743d9445c398a38701df2d3af11dfa0", + "content-hash": "fe0aa063efeedf6de7d9dd13c896fe64", "packages": [], "packages-dev": [ { @@ -157,16 +157,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -205,7 +205,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -213,7 +213,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "phar-io/manifest", @@ -333,53 +333,6 @@ }, "time": "2022-02-21T01:04:05+00:00" }, - { - "name": "php-stubs/wordpress-stubs", - "version": "v6.5.3", - "source": { - "type": "git", - "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "e611a83292d02055a25f83291a98fadd0c21e092" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/e611a83292d02055a25f83291a98fadd0c21e092", - "reference": "e611a83292d02055a25f83291a98fadd0c21e092", - "shasum": "" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "nikic/php-parser": "^4.13", - "php": "^7.4 || ~8.0.0", - "php-stubs/generator": "^0.8.3", - "phpdocumentor/reflection-docblock": "5.3", - "phpstan/phpstan": "^1.10.49", - "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.11" - }, - "suggest": { - "paragonie/sodium_compat": "Pure PHP implementation of libsodium", - "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WordPress function and class declaration stubs for static analysis.", - "homepage": "https://github.com/php-stubs/wordpress-stubs", - "keywords": [ - "PHPStan", - "static analysis", - "wordpress" - ], - "support": { - "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.5.3" - }, - "time": "2024-05-08T02:12:31+00:00" - }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -522,22 +475,22 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.11", + "version": "1.0.12", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a" + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c457da9dabb60eb7106dd5e3c05132b1a6539c6a", - "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -606,100 +559,20 @@ "type": "open_collective" } ], - "time": "2024-04-24T11:47:18+00:00" - }, - { - "name": "phpstan/extension-installer", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/phpstan/extension-installer.git", - "reference": "85e90b3942d06b2326fba0403ec24fe912372936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", - "reference": "85e90b3942d06b2326fba0403ec24fe912372936", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^2.0", - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.9.0 || ^2.0" - }, - "require-dev": { - "composer/composer": "^2.0", - "php-parallel-lint/php-parallel-lint": "^1.2.0", - "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "PHPStan\\ExtensionInstaller\\Plugin" - }, - "autoload": { - "psr-4": { - "PHPStan\\ExtensionInstaller\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Composer plugin for automatic installation of PHPStan extensions", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpstan/extension-installer/issues", - "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" - }, - "time": "2024-09-04T20:21:43+00:00" - }, - { - "name": "phpstan/php-8-stubs", - "version": "0.4.9", - "source": { - "type": "git", - "url": "https://github.com/phpstan/php-8-stubs.git", - "reference": "1857c330fea6e795af1f7435ed02a18652e7dd8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/php-8-stubs/zipball/1857c330fea6e795af1f7435ed02a18652e7dd8c", - "reference": "1857c330fea6e795af1f7435ed02a18652e7dd8c", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "Php8StubsMap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT", - "PHP-3.01" - ], - "description": "PHP stubs extracted from php-src", - "support": { - "issues": "https://github.com/phpstan/php-8-stubs/issues", - "source": "https://github.com/phpstan/php-8-stubs/tree/0.4.9" - }, - "time": "2024-12-02T00:21:59+00:00" + "time": "2024-05-20T13:34:27+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -731,215 +604,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" - }, - "time": "2024-05-31T08:52:43+00:00" - }, - { - "name": "phpstan/phpstan", - "version": "1.12.7", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", - "reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0", - "shasum": "" - }, - "require": { - "php": "^7.2|^8.0" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "keywords": [ - "dev", - "static analysis" - ], - "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" - }, - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://github.com/phpstan", - "type": "github" - } - ], - "time": "2024-10-18T11:12:07+00:00" - }, - { - "name": "phpstan/phpstan-deprecation-rules", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" - }, - "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", - "support": { - "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.1" - }, - "time": "2024-09-11T15:52:35+00:00" - }, - { - "name": "phpstan/phpstan-phpunit", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11", - "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.11" - }, - "conflict": { - "phpunit/phpunit": "<7.0" - }, - "require-dev": { - "nikic/php-parser": "^4.13.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon", - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPUnit extensions and rules for PHPStan", - "support": { - "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0" - }, - "time": "2024-04-20T06:39:00+00:00" - }, - { - "name": "phpstan/phpstan-strict-rules", - "version": "1.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "daeec748b53de80a97498462513066834ec28f8b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/daeec748b53de80a97498462513066834ec28f8b", - "reference": "daeec748b53de80a97498462513066834ec28f8b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12.4" - }, - "require-dev": { - "nikic/php-parser": "^4.13.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Extra strict and opinionated rules for PHPStan", - "support": { - "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.1" - }, - "time": "2024-09-20T14:04:44+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1240,16 +907,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.39", + "version": "8.5.41", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "172ba97bcf97ae6ef86ca256adf77aece8a143fe" + "reference": "d843cb5bcf0bf9ae3484016444fe0c5b6ec7e4fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/172ba97bcf97ae6ef86ca256adf77aece8a143fe", - "reference": "172ba97bcf97ae6ef86ca256adf77aece8a143fe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d843cb5bcf0bf9ae3484016444fe0c5b6ec7e4fa", + "reference": "d843cb5bcf0bf9ae3484016444fe0c5b6ec7e4fa", "shasum": "" }, "require": { @@ -1260,7 +927,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.0", + "myclabs/deep-copy": "^1.12.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=7.2", @@ -1318,7 +985,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.39" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.41" }, "funding": [ { @@ -1334,7 +1001,7 @@ "type": "tidelift" } ], - "time": "2024-07-10T11:43:00+00:00" + "time": "2024-12-05T13:44:26+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2209,196 +1876,6 @@ ], "time": "2024-11-16T12:02:36+00:00" }, - { - "name": "swissspidy/phpstan-no-private", - "version": "v0.2.1", - "source": { - "type": "git", - "url": "https://github.com/swissspidy/phpstan-no-private.git", - "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/f7a1890e350c8d8bf26370426a971d7490ae4245", - "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.3" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-php-parser": "^1.1", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5", - "slevomat/coding-standard": "^8.8.0", - "squizlabs/php_codesniffer": "^3.5.3" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "Swissspidy\\PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan rules for detecting usage of pseudo-private functions, classes, and methods.", - "support": { - "issues": "https://github.com/swissspidy/phpstan-no-private/issues", - "source": "https://github.com/swissspidy/phpstan-no-private/tree/v0.2.1" - }, - "time": "2024-06-05T10:03:17+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, - { - "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.5", - "source": { - "type": "git", - "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", - "phpstan/phpstan": "^1.10.31", - "symfony/polyfill-php73": "^1.12.0" - }, - "require-dev": { - "composer/composer": "^2.1.14", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.1", - "phpstan/phpstan-strict-rules": "^1.2", - "phpunit/phpunit": "^8.0 || ^9.0", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", - "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" - }, - "suggest": { - "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "SzepeViktor\\PHPStan\\WordPress\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "WordPress extensions for PHPStan", - "keywords": [ - "PHPStan", - "code analyse", - "code analysis", - "static analysis", - "wordpress" - ], - "support": { - "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.5" - }, - "time": "2024-06-28T22:27:19+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.3", @@ -2565,16 +2042,16 @@ }, { "name": "yoast/phpunit-polyfills", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", - "reference": "4a088f125c970d6d6ea52c927f96fe39b330d0f1" + "reference": "562f449a2ec8ab92fe7b30d94da9622c7b1345fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/4a088f125c970d6d6ea52c927f96fe39b330d0f1", - "reference": "4a088f125c970d6d6ea52c927f96fe39b330d0f1", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/562f449a2ec8ab92fe7b30d94da9622c7b1345fe", + "reference": "562f449a2ec8ab92fe7b30d94da9622c7b1345fe", "shasum": "" }, "require": { @@ -2589,7 +2066,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -2624,7 +2101,7 @@ "security": "https://github.com/Yoast/PHPUnit-Polyfills/security/policy", "source": "https://github.com/Yoast/PHPUnit-Polyfills" }, - "time": "2024-04-05T16:36:44+00:00" + "time": "2024-09-06T22:38:28+00:00" } ], "aliases": [], diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 1f21368b59..3aca7f1263 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,33 +3,66 @@ includes: parameters: level: 8 treatPhpDocTypesAsCertain: false + phpVersion: 70200 paths: - plugins - tests - performance.php - - plugins/performance-lab/load.php bootstrapFiles: - tools/phpstan/constants.php - - plugins/performance-lab/load.php - - plugins/webp-uploads/load.php scanDirectories: - vendor/wp-phpunit/wp-phpunit/ scanFiles: # These are needed due config.platform.php being 7.2 in composer.json and wordpress-stubs not including polyfills. # See . - - vendor/phpstan/php-8-stubs/stubs/ext/standard/str_contains.php - - vendor/phpstan/php-8-stubs/stubs/ext/standard/str_starts_with.php - - vendor/phpstan/php-8-stubs/stubs/ext/standard/str_ends_with.php + - phpstan/vendor/phpstan/php-8-stubs/stubs/ext/standard/str_contains.php + - phpstan/vendor/phpstan/php-8-stubs/stubs/ext/standard/str_starts_with.php + - phpstan/vendor/phpstan/php-8-stubs/stubs/ext/standard/str_ends_with.php stubFiles: - tools/phpstan/filtered-functions.stub dynamicConstantNames: - PERFLAB_OBJECT_CACHE_DROPIN_VERSION strictRules: strictArrayFilter: false - featureToggles: - # Ignore errors related to the plugin not running from inside a WP environment, so paths like ABSPATH . WPINC don't resolve. - requireFileExists: false ignoreErrors: + # Allow using a plugin's private functions in itself. + - + identifier: no.private.function + message: '/function dominant_color_.*/' + path: plugins/dominant-color-images/* + - + identifier: no.private.class + message: '/class Image_Prioritizer_.*/' + path: plugins/image-prioritizer/* + - + identifier: no.private.class + message: '/class Embed_Optimizer_.*/' + path: plugins/embed-optimizer/* + - + identifier: no.private.class + message: '/class OD_.*/' + path: plugins/optimization-detective/* + - + identifier: no.private.method + message: '/class OD_.*/' + path: plugins/optimization-detective/* + - + identifier: no.private.function + message: '/function od_.*/' + path: plugins/optimization-detective/* + - + identifier: no.private.function + message: '/function webp_uploads_.*/' + path: plugins/webp-uploads/* + - + identifier: no.private.function + message: '/function plwwo_.*/' + path: plugins/web-worker-offloading/* + # Ignore errors related to the plugin not running from inside a WP environment, so paths like ABSPATH . WPINC don't resolve. + - + identifier: requireOnce.fileNotFound + - + identifier: includeOnce.fileNotFound - # Ignore error related to PHP 8 using a GdImage but PHP 7 using a resource. message: '/^Parameter .+? of function .+? expects resource, GdImage\|resource given\.$/' diff --git a/phpstan/composer.json b/phpstan/composer.json new file mode 100644 index 0000000000..b02bbfdd00 --- /dev/null +++ b/phpstan/composer.json @@ -0,0 +1,20 @@ +{ + "require-dev": { + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.0.3", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-phpunit": "^2.0.1", + "szepeviktor/phpstan-wordpress": "^2.0.1", + "phpstan/php-8-stubs": "^0.4.9", + "phpstan/phpstan-strict-rules": "^2.0.0", + "swissspidy/phpstan-no-private": "^1.0.0" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + }, + "platform": { + "php": "8.2" + } + } +} diff --git a/phpstan/composer.lock b/phpstan/composer.lock new file mode 100644 index 0000000000..65c0f01f10 --- /dev/null +++ b/phpstan/composer.lock @@ -0,0 +1,468 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "9ac5af40b2a6ebccee5a6d36fb79378c", + "packages": [], + "packages-dev": [ + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.7.1", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/83448e918bf06d1ed3d67ceb6a985fc266a02fd1", + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.4.1", + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.1" + }, + "time": "2024-11-24T03:57:09+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, + { + "name": "phpstan/php-8-stubs", + "version": "0.4.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/php-8-stubs.git", + "reference": "1857c330fea6e795af1f7435ed02a18652e7dd8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/php-8-stubs/zipball/1857c330fea6e795af1f7435ed02a18652e7dd8c", + "reference": "1857c330fea6e795af1f7435ed02a18652e7dd8c", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "Php8StubsMap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT", + "PHP-3.01" + ], + "description": "PHP stubs extracted from php-src", + "support": { + "issues": "https://github.com/phpstan/php-8-stubs/issues", + "source": "https://github.com/phpstan/php-8-stubs/tree/0.4.9" + }, + "time": "2024-12-02T00:21:59+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46b4d3529b12178112d9008337beda0cc2a1a6b4", + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-11-28T22:19:37+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1" + }, + "time": "2024-11-28T21:56:36+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.1" + }, + "time": "2024-11-12T12:48:00+00:00" + }, + { + "name": "phpstan/phpstan-strict-rules", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-strict-rules.git", + "reference": "a4a6a08bd4a461e516b9c3b8fdbf0f1883b34158" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/a4a6a08bd4a461e516b9c3b8fdbf0f1883b34158", + "reference": "a4a6a08bd4a461e516b9c3b8fdbf0f1883b34158", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Extra strict and opinionated rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/2.0.0" + }, + "time": "2024-10-26T16:04:33+00:00" + }, + { + "name": "swissspidy/phpstan-no-private", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/swissspidy/phpstan-no-private.git", + "reference": "559cb0e8d092df7314ed4254db83db0427440af2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/559cb0e8d092df7314ed4254db83db0427440af2", + "reference": "559cb0e8d092df7314ed4254db83db0427440af2", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "nikic/php-parser": "^v5.3.1", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.5", + "slevomat/coding-standard": "^8.8.0", + "squizlabs/php_codesniffer": "^3.5.3" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Swissspidy\\PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of pseudo-private functions, classes, and methods.", + "support": { + "issues": "https://github.com/swissspidy/phpstan-no-private/issues", + "source": "https://github.com/swissspidy/phpstan-no-private/tree/v1.0.0" + }, + "time": "2024-11-11T11:04:45+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/f7beb13cd22998e3d913fdb897a1e2553ccd637e", + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": "^6.6.2", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v2.0.1" + }, + "time": "2024-12-01T02:13:05+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "platform-overrides": { + "php": "8.2" + }, + "plugin-api-version": "2.6.0" +} diff --git a/plugins/optimization-detective/class-od-html-tag-processor.php b/plugins/optimization-detective/class-od-html-tag-processor.php index 7fc8967118..e22ee464de 100644 --- a/plugins/optimization-detective/class-od-html-tag-processor.php +++ b/plugins/optimization-detective/class-od-html-tag-processor.php @@ -623,6 +623,7 @@ public function get_updated_html(): string { } else { $start = $this->bookmarks[ $bookmark ]->start; + // @phpstan-ignore no.private.class $this->lexical_updates[] = new WP_HTML_Text_Replacement( $start, 0, diff --git a/plugins/webp-uploads/hooks.php b/plugins/webp-uploads/hooks.php index 0e36bbca5a..97f3cef187 100644 --- a/plugins/webp-uploads/hooks.php +++ b/plugins/webp-uploads/hooks.php @@ -158,6 +158,7 @@ function webp_uploads_create_sources_property( array $metadata, int $attachment_ // Replace the attached file with the custom MIME type version. if ( false !== $original_image ) { + // @phpstan-ignore no.private.function $metadata = _wp_image_meta_replace_original( $saved_data, $original_image, $metadata, $attachment_id ); } diff --git a/tools/phpstan/constants.php b/tools/phpstan/constants.php index d740676c88..0df30bf20f 100644 --- a/tools/phpstan/constants.php +++ b/tools/phpstan/constants.php @@ -17,3 +17,14 @@ define( 'IMAGE_PRIORITIZER_VERSION', '0.0.0' ); define( 'EMBED_OPTIMIZER_VERSION', '0.0.0' ); + +define( 'WEBP_UPLOADS_VERSION', '0.0.0' ); +define( 'WEBP_UPLOADS_MAIN_FILE', '' ); + +define( 'PERFLAB_VERSION', '0.0.0' ); +define( 'PERFLAB_MAIN_FILE', '' ); +define( 'PERFLAB_PLUGIN_DIR_PATH', '' ); +define( 'PERFLAB_SCREEN', '' ); + +define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', false ); +define( 'PERFLAB_OBJECT_CACHE_DROPIN_LATEST_VERSION', 99999 );