From 49203b07c32e7123565ac20a096e79d74b06cebc Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 29 Nov 2024 17:40:17 +0100 Subject: [PATCH] Update to PHPStan 2.0 --- composer.json | 8 +- composer.lock | 158 +++++++++--------- includes/AMP/Meta_Sanitizer.php | 2 +- includes/AMP/Sanitization.php | 4 +- includes/AMP/Traits/Sanitization_Utils.php | 2 +- includes/Admin/Activation_Notice.php | 6 +- includes/Admin/Customizer.php | 12 +- includes/Admin/Dashboard.php | 2 +- includes/Admin/Editor.php | 4 +- includes/Analytics.php | 2 +- includes/Assets.php | 12 +- includes/Block/Web_Stories_Block.php | 2 +- includes/Experiments.php | 2 +- .../Infrastructure/ServiceBasedPlugin.php | 4 +- includes/Integrations/AMP.php | 4 +- includes/Integrations/Jetpack.php | 2 +- includes/KSES.php | 2 +- includes/Media/SVG.php | 2 +- includes/Post_Type_Base.php | 2 +- includes/REST_API/Embed_Controller.php | 6 +- includes/REST_API/Font_Controller.php | 4 +- includes/REST_API/Hotlinking_Controller.php | 12 +- includes/REST_API/Link_Controller.php | 6 +- includes/REST_API/Products_Controller.php | 6 +- includes/REST_API/Stories_Base_Controller.php | 2 +- includes/REST_API/Stories_Controller.php | 8 +- includes/REST_API/Stories_Lock_Controller.php | 4 +- .../REST_API/Stories_Users_Controller.php | 2 +- .../Renderer/Stories/Carousel_Renderer.php | 2 +- .../Renderer/Stories/Generic_Renderer.php | 4 +- includes/Renderer/Stories/Renderer.php | 6 +- includes/Renderer/Story/Embed.php | 2 +- includes/Renderer/Story/Singleton.php | 2 +- includes/Settings.php | 4 +- includes/Widgets/Stories.php | 8 +- includes/namespace.php | 6 +- phpstan.neon.dist | 6 +- ...iceContainerDynamicReturnTypeExtension.php | 10 +- .../ServicesDynamicReturnTypeExtension.php | 10 +- .../phpunit/integration/tests/Model/Story.php | 4 - .../tests/REST_API/Stories_Controller.php | 1 - tests/phpunit/integration/tests/Tracking.php | 4 - 42 files changed, 176 insertions(+), 175 deletions(-) diff --git a/composer.json b/composer.json index 0d621b4862a2..f8933b699791 100644 --- a/composer.json +++ b/composer.json @@ -27,14 +27,14 @@ "phpcompatibility/phpcompatibility-wp": "^2.1", "phpmd/phpmd": "^2.9", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.2", + "phpstan/phpstan-deprecation-rules": "^2.0.1", + "phpstan/phpstan-phpunit": "^2.0.1", "roave/security-advisories": "dev-latest", "sirbrillig/phpcs-variable-analysis": "^2.8", "slevomat/coding-standard": "^8.0.0", "sniccowp/php-scoper-wordpress-excludes": "^6.0", - "swissspidy/phpstan-no-private": "^0.2.0", - "szepeviktor/phpstan-wordpress": "^1.1.3", + "swissspidy/phpstan-no-private": "^v1.0.0", + "szepeviktor/phpstan-wordpress": "^v2.0.0", "wp-coding-standards/wpcs": "^3.0.0", "yoast/wp-test-utils": "^1.0.0" }, diff --git a/composer.lock b/composer.lock index 554aea311bc4..98cc66705487 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": "ee23bdcfe0de62daa1254fab27c92be2", + "content-hash": "a37ff368e715e006fc989a9a0cfc5513", "packages": [ { "name": "ampproject/amp-toolbox", @@ -3018,20 +3018,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.11", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733" + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", - "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46b4d3529b12178112d9008337beda0cc2a1a6b4", + "reference": "46b4d3529b12178112d9008337beda0cc2a1a6b4", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -3072,30 +3072,30 @@ "type": "github" } ], - "time": "2024-11-17T14:08:01+00:00" + "time": "2024-11-28T22:19:37+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "1.2.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82" + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", + "reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -3117,36 +3117,35 @@ "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" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1" }, - "time": "2024-09-11T15:52:35+00:00" + "time": "2024-11-28T21:56:36+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "11d4235fbc6313ecbf93708606edfd3222e44949" + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/11d4235fbc6313ecbf93708606edfd3222e44949", - "reference": "11d4235fbc6313ecbf93708606edfd3222e44949", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "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" + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -3169,9 +3168,9 @@ "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.1" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.1" }, - "time": "2024-11-12T12:43:59+00:00" + "time": "2024-11-12T12:48:00+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3749,12 +3748,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "4b0583eef37941e72c51ea847d0e03ef52a302d9" + "reference": "fff26f7a91a7458bf6eea5afdd71b4aba1f1d3ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/4b0583eef37941e72c51ea847d0e03ef52a302d9", - "reference": "4b0583eef37941e72c51ea847d0e03ef52a302d9", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/fff26f7a91a7458bf6eea5afdd71b4aba1f1d3ea", + "reference": "fff26f7a91a7458bf6eea5afdd71b4aba1f1d3ea", "shasum": "" }, "conflict": { @@ -4335,6 +4334,7 @@ "socialiteproviders/steam": "<1.1", "spatie/browsershot": "<3.57.4", "spatie/image-optimizer": "<1.7.3", + "spencer14420/sp-php-email-handler": "<1", "spipu/html2pdf": "<5.2.8", "spoon/library": "<1.4.1", "spoonity/tcpdf": "<6.2.22", @@ -4583,7 +4583,7 @@ "type": "tidelift" } ], - "time": "2024-11-26T22:05:25+00:00" + "time": "2024-11-27T22:05:07+00:00" }, { "name": "sebastian/cli-parser", @@ -5800,27 +5800,28 @@ }, { "name": "swissspidy/phpstan-no-private", - "version": "v0.2.1", + "version": "v1.0.0", "source": { "type": "git", "url": "https://github.com/swissspidy/phpstan-no-private.git", - "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245" + "reference": "559cb0e8d092df7314ed4254db83db0427440af2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/f7a1890e350c8d8bf26370426a971d7490ae4245", - "reference": "f7a1890e350c8d8bf26370426a971d7490ae4245", + "url": "https://api.github.com/repos/swissspidy/phpstan-no-private/zipball/559cb0e8d092df7314ed4254db83db0427440af2", + "reference": "559cb0e8d092df7314ed4254db83db0427440af2", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.3" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "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", + "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" @@ -5845,9 +5846,9 @@ "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" + "source": "https://github.com/swissspidy/phpstan-no-private/tree/v1.0.0" }, - "time": "2024-06-05T10:03:17+00:00" + "time": "2024-11-11T11:04:45+00:00" }, { "name": "symfony/config", @@ -6029,16 +6030,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v5.4.45", + "version": "v5.4.48", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "0c199da64bb27e4216ccccb83f451e2ec66b3c4b" + "reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/0c199da64bb27e4216ccccb83f451e2ec66b3c4b", - "reference": "0c199da64bb27e4216ccccb83f451e2ec66b3c4b", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e5ca16dee39ef7d63e552ff0bf0a2526a1142c92", + "reference": "e5ca16dee39ef7d63e552ff0bf0a2526a1142c92", "shasum": "" }, "require": { @@ -6098,7 +6099,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.4.45" + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.48" }, "funding": [ { @@ -6114,20 +6115,20 @@ "type": "tidelift" } ], - "time": "2024-10-22T18:49:16+00:00" + "time": "2024-11-20T10:51:57+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.3", + "version": "v2.5.4", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", "shasum": "" }, "require": { @@ -6165,7 +6166,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" }, "funding": [ { @@ -6181,20 +6182,20 @@ "type": "tidelift" } ], - "time": "2023-01-24T14:02:46+00:00" + "time": "2024-09-25T14:11:13+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v2.5.3", + "version": "v2.5.4", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73" + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/540f4c73e87fd0c71ca44a6aa305d024ac68cb73", - "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", "shasum": "" }, "require": { @@ -6244,7 +6245,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4" }, "funding": [ { @@ -6260,7 +6261,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T13:51:25+00:00" + "time": "2024-09-25T14:11:13+00:00" }, { "name": "symfony/filesystem", @@ -6788,16 +6789,16 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.3", + "version": "v2.5.4", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", - "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300", + "reference": "f37b419f7aea2e9abf10abd261832cace12e3300", "shasum": "" }, "require": { @@ -6851,7 +6852,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.4" }, "funding": [ { @@ -6867,7 +6868,7 @@ "type": "tidelift" } ], - "time": "2023-04-21T15:04:16+00:00" + "time": "2024-09-25T14:11:13+00:00" }, { "name": "symfony/string", @@ -6957,30 +6958,29 @@ }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.5", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" + "reference": "fab61ad0e3ba963877eea48d29248eb1ae2a3eda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/fab61ad0e3ba963877eea48d29248eb1ae2a3eda", + "reference": "fab61ad0e3ba963877eea48d29248eb1ae2a3eda", "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" + "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": "^1.2", - "phpunit/phpunit": "^8.0 || ^9.0", + "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" }, @@ -7014,9 +7014,9 @@ ], "support": { "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.5" + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v2.0.0" }, - "time": "2024-06-28T22:27:19+00:00" + "time": "2024-11-17T13:12:31+00:00" }, { "name": "thecodingmachine/safe", diff --git a/includes/AMP/Meta_Sanitizer.php b/includes/AMP/Meta_Sanitizer.php index a5c936f7fbeb..bb3f70d50d24 100644 --- a/includes/AMP/Meta_Sanitizer.php +++ b/includes/AMP/Meta_Sanitizer.php @@ -52,7 +52,7 @@ class Meta_Sanitizer extends AMP_Meta_Sanitizer { * "Finally, specify the AMP boilerplate code. By putting the boilerplate code last, it prevents custom styles from * accidentally overriding the boilerplate css rules." * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.1.0 * diff --git a/includes/AMP/Sanitization.php b/includes/AMP/Sanitization.php index b486f6e39993..2666fe633ee1 100644 --- a/includes/AMP/Sanitization.php +++ b/includes/AMP/Sanitization.php @@ -128,7 +128,7 @@ public function validation_error_callback( array $error, array $data = [] ): boo /** * Adds missing scripts. * - * @SuppressWarnings(PHPMD) + * @SuppressWarnings("PHPMD") * * @since 1.1.0 * @@ -418,7 +418,7 @@ protected function is_amp_dev_mode(): bool { * accessing options from the database, requiring AMP__VERSION, * and causing conflicts with our own amp_is_request() compat shim. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.1.0 * diff --git a/includes/AMP/Traits/Sanitization_Utils.php b/includes/AMP/Traits/Sanitization_Utils.php index dd6e87968e82..83513a72dceb 100644 --- a/includes/AMP/Traits/Sanitization_Utils.php +++ b/includes/AMP/Traits/Sanitization_Utils.php @@ -71,7 +71,7 @@ private function transform_html_start_tag( $document ): void { * Removes empty data-tooltip-icon and data-tooltip-text attributes * to prevent validation issues. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.1.0 * diff --git a/includes/Admin/Activation_Notice.php b/includes/Admin/Activation_Notice.php index 35a36340217b..4e26d3181b0b 100644 --- a/includes/Admin/Activation_Notice.php +++ b/includes/Admin/Activation_Notice.php @@ -235,7 +235,7 @@ protected function is_plugins_page( $hook_suffix ): bool { /** * Sets the flag that the plugin has just been activated. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.13.0 * @@ -252,7 +252,7 @@ protected function set_activation_flag( bool $network_wide = false ): bool { /** * Gets the flag that the plugin has just been activated. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.13.0 * @@ -270,7 +270,7 @@ protected function get_activation_flag( bool $network_wide = false ): bool { /** * Deletes the flag that the plugin has just been activated. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.13.0 * diff --git a/includes/Admin/Customizer.php b/includes/Admin/Customizer.php index 69f1a7f8ea38..1fcce9b3ebbe 100644 --- a/includes/Admin/Customizer.php +++ b/includes/Admin/Customizer.php @@ -40,7 +40,7 @@ /** * Class customizer settings. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type ThemeSupport array{ * customizer: array{ @@ -159,9 +159,9 @@ public static function is_needed(): bool { /** * Registers web stories customizer settings. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.CyclomaticComplexity") * * @since 1.5.0 * @@ -531,8 +531,8 @@ public function validate_number_of_columns( WP_Error $validity, int $value ): WP /** * Renders web stories based on the customizer selected options. * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.CyclomaticComplexity") * * @since 1.5.0 */ diff --git a/includes/Admin/Dashboard.php b/includes/Admin/Dashboard.php index 634a81c0ca8f..b12d7f1c9b67 100644 --- a/includes/Admin/Dashboard.php +++ b/includes/Admin/Dashboard.php @@ -156,7 +156,7 @@ class Dashboard extends Service_Base { /** * Dashboard constructor. * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * @SuppressWarnings("PHPMD.ExcessiveParameterList") * * @since 1.0.0 * diff --git a/includes/Admin/Editor.php b/includes/Admin/Editor.php index 565817bf8772..2d023411870d 100644 --- a/includes/Admin/Editor.php +++ b/includes/Admin/Editor.php @@ -151,7 +151,7 @@ class Editor extends Service_Base implements HasRequirements { /** * Dashboard constructor. * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * @SuppressWarnings("PHPMD.ExcessiveParameterList") * * @since 1.0.0 * @@ -333,7 +333,7 @@ public function admin_enqueue_scripts( string $hook ): void { /** * Get editor settings as an array. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 * diff --git a/includes/Analytics.php b/includes/Analytics.php index ea05f0beb8e4..67ade9904e1a 100644 --- a/includes/Analytics.php +++ b/includes/Analytics.php @@ -89,7 +89,7 @@ public function get_tracking_id(): string { * * Note: variables in single quotes will be substituted by . * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @see https://github.com/ampproject/amphtml/blob/main/docs/spec/amp-var-substitutions.md * diff --git a/includes/Assets.php b/includes/Assets.php index 6edb82377d2a..246b4803a6bd 100644 --- a/includes/Assets.php +++ b/includes/Assets.php @@ -113,7 +113,7 @@ public function get_asset_metadata( string $handle ): array { /** * Register script using handle. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * @@ -181,7 +181,7 @@ public function register_script_asset( string $script_handle, array $script_depe /** * Enqueue script using handle. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * @@ -255,7 +255,7 @@ public function enqueue_style_asset( string $style_handle, array $style_dependen /** * Register a CSS stylesheet. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * @@ -283,7 +283,7 @@ public function register_style( string $style_handle, $src, array $deps = [], $v /** * Register a new script. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * @@ -315,7 +315,7 @@ public function register_script( string $script_handle, $src, array $deps = [], /** * Enqueue a style. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * @@ -339,7 +339,7 @@ public function enqueue_style( string $style_handle, string $src = '', array $de /** * Enqueue a script. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.8.0 * diff --git a/includes/Block/Web_Stories_Block.php b/includes/Block/Web_Stories_Block.php index cf723dc300eb..4e9157fd0346 100644 --- a/includes/Block/Web_Stories_Block.php +++ b/includes/Block/Web_Stories_Block.php @@ -388,7 +388,7 @@ protected function initialize_block_attributes( array $block_attributes = [] ): /** * Returns arguments to be passed to the WP_Query object initialization. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.5.0 * diff --git a/includes/Experiments.php b/includes/Experiments.php index f93032b516d3..55a9e535e284 100644 --- a/includes/Experiments.php +++ b/includes/Experiments.php @@ -225,7 +225,7 @@ public function get_experiment_groups(): array { /** * Returns a list of all experiments. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 * diff --git a/includes/Infrastructure/ServiceBasedPlugin.php b/includes/Infrastructure/ServiceBasedPlugin.php index 1542912a4374..b8be48abfa7b 100644 --- a/includes/Infrastructure/ServiceBasedPlugin.php +++ b/includes/Infrastructure/ServiceBasedPlugin.php @@ -31,7 +31,7 @@ * This abstract base plugin provides all the boilerplate code for working with * the dependency injector and the service container. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @template C of Conditional * @template D of Delayed @@ -715,7 +715,7 @@ protected function instantiate_service( $class_name ): Service { * object * or into configuration files. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.6.0 * diff --git a/includes/Integrations/AMP.php b/includes/Integrations/AMP.php index da241e237228..8da5fe5e8546 100644 --- a/includes/Integrations/AMP.php +++ b/includes/Integrations/AMP.php @@ -41,7 +41,7 @@ /** * Class AMP. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type AMPOptions array{ * theme_support?: string, @@ -349,7 +349,7 @@ public function filter_amp_skip_post( $skipped, int $post ) { /** * Get the post type for the current request. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.2.0 */ diff --git a/includes/Integrations/Jetpack.php b/includes/Integrations/Jetpack.php index d4fae74e3762..f5d655d500ef 100644 --- a/includes/Integrations/Jetpack.php +++ b/includes/Integrations/Jetpack.php @@ -38,7 +38,7 @@ /** * Class Jetpack. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type AttachmentData array{ * media_details?: array{ diff --git a/includes/KSES.php b/includes/KSES.php index abdc39a52d97..45c44976a7e9 100644 --- a/includes/KSES.php +++ b/includes/KSES.php @@ -40,7 +40,7 @@ * * Provides KSES utility methods to override the ones from core. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type PostData array{ * post_parent: int|string|null, diff --git a/includes/Media/SVG.php b/includes/Media/SVG.php index c44bd8f2f887..e64c3e280cc2 100644 --- a/includes/Media/SVG.php +++ b/includes/Media/SVG.php @@ -302,7 +302,7 @@ private function svg_already_enabled(): bool { /** * Get SVG image size. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.3.0 * diff --git a/includes/Post_Type_Base.php b/includes/Post_Type_Base.php index 075449493a3f..74536261cb66 100644 --- a/includes/Post_Type_Base.php +++ b/includes/Post_Type_Base.php @@ -318,7 +318,7 @@ public function get_parent_controller(): WP_REST_Controller { * Identical to {@see get_post_type_archive_link()}, but also returns a URL * if the archive page has been disabled. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.14.0 * diff --git a/includes/REST_API/Embed_Controller.php b/includes/REST_API/Embed_Controller.php index c9202608d71e..9bf63d58dbd3 100644 --- a/includes/REST_API/Embed_Controller.php +++ b/includes/REST_API/Embed_Controller.php @@ -47,7 +47,7 @@ * * API endpoint to facilitate embedding web stories. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type SchemaEntry array{ * description: string, @@ -126,7 +126,7 @@ public function register_routes(): void { * * Returns information about the given story. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 * @@ -365,7 +365,7 @@ private function get_data_from_post( string $url ) { * * Checks are supposedly from the hosted site blog. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.2.0 * diff --git a/includes/REST_API/Font_Controller.php b/includes/REST_API/Font_Controller.php index 05f04137583a..d5390398f035 100644 --- a/includes/REST_API/Font_Controller.php +++ b/includes/REST_API/Font_Controller.php @@ -246,7 +246,7 @@ public function delete_item( $request ) { /** * Prepares a single post output for response. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.16.0 * @@ -371,7 +371,7 @@ public function get_collection_params(): array { /** * Retrieves the font's schema, conforming to JSON Schema. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.16.0 * diff --git a/includes/REST_API/Hotlinking_Controller.php b/includes/REST_API/Hotlinking_Controller.php index 717ecfa6d7eb..0faaf8442e84 100644 --- a/includes/REST_API/Hotlinking_Controller.php +++ b/includes/REST_API/Hotlinking_Controller.php @@ -42,7 +42,7 @@ * * API endpoint for pinging and hotlinking media URLs. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type LinkData array{ * ext?: string, @@ -203,8 +203,8 @@ public function register_routes(): void { /** * Parses a URL to return some metadata for inserting external media. * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.11.0 * @@ -327,7 +327,7 @@ public function parse_url( WP_REST_Request $request ) { /** * Parses a URL to return proxied file. * - * @SuppressWarnings(PHPMD.ErrorControlOperator) + * @SuppressWarnings("PHPMD.ErrorControlOperator") * * @since 1.13.0 * @@ -724,8 +724,8 @@ private function proxy_url_fallback( string $url, array $args ): void { * Like {@see wp_http_validate_url} in core, but with extra hardening * to avoid DNS rebinding issues. * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.CyclomaticComplexity") * * @since 1.22.0 * diff --git a/includes/REST_API/Link_Controller.php b/includes/REST_API/Link_Controller.php index df7201c596a2..81f77e6784b5 100644 --- a/includes/REST_API/Link_Controller.php +++ b/includes/REST_API/Link_Controller.php @@ -122,9 +122,9 @@ public function register_routes(): void { /** * Parses a URL to return some metadata for inserting links. * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.CyclomaticComplexity") + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 * diff --git a/includes/REST_API/Products_Controller.php b/includes/REST_API/Products_Controller.php index fc85d66a140d..73da3a1ea2c3 100644 --- a/includes/REST_API/Products_Controller.php +++ b/includes/REST_API/Products_Controller.php @@ -163,7 +163,7 @@ public function get_items_permissions_check( $request ) { /** * Retrieves all products. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.20.0 * @@ -227,7 +227,7 @@ public function get_items( $request ) { /** * Prepares a single post output for response. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.20.0 * @@ -323,7 +323,7 @@ public function prepare_item_for_response( $item, $request ): WP_REST_Response { /** * Retrieves the product schema, conforming to JSON Schema. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.20.0 * diff --git a/includes/REST_API/Stories_Base_Controller.php b/includes/REST_API/Stories_Base_Controller.php index e0516c502872..c2ea2d5d4ee3 100644 --- a/includes/REST_API/Stories_Base_Controller.php +++ b/includes/REST_API/Stories_Base_Controller.php @@ -40,7 +40,7 @@ /** * Stories_Base_Controller class. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * Override the WP_REST_Posts_Controller class to add `post_content_filtered` to REST request. * diff --git a/includes/REST_API/Stories_Controller.php b/includes/REST_API/Stories_Controller.php index afff8f7ad724..dd2954b7f93e 100644 --- a/includes/REST_API/Stories_Controller.php +++ b/includes/REST_API/Stories_Controller.php @@ -41,7 +41,7 @@ /** * Stories_Controller class. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type QueryArgs array{ * posts_per_page?: int, @@ -71,8 +71,8 @@ class Stories_Controller extends Stories_Base_Controller { /** * Prepares a single story output for response. Add post_content_filtered field to output. * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.CyclomaticComplexity") + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.0.0 * @@ -484,7 +484,7 @@ protected function get_attached_post_ids( array $posts ): array { /** * Add response headers, with post counts. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.12.0 * diff --git a/includes/REST_API/Stories_Lock_Controller.php b/includes/REST_API/Stories_Lock_Controller.php index 6d575ebcbef5..85ff42d0f4a7 100644 --- a/includes/REST_API/Stories_Lock_Controller.php +++ b/includes/REST_API/Stories_Lock_Controller.php @@ -261,8 +261,8 @@ public function delete_item_permissions_check( $request ) { /** * Prepares a single lock output for response. * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.6.0 * diff --git a/includes/REST_API/Stories_Users_Controller.php b/includes/REST_API/Stories_Users_Controller.php index 2575ff7d8e5f..8075813ead15 100644 --- a/includes/REST_API/Stories_Users_Controller.php +++ b/includes/REST_API/Stories_Users_Controller.php @@ -233,7 +233,7 @@ public function get_item_permissions_check( $request ) { * * Wraps {@see count_user_posts()} results in a cache. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.10.0 * diff --git a/includes/Renderer/Stories/Carousel_Renderer.php b/includes/Renderer/Stories/Carousel_Renderer.php index acd8f09a476b..5c937e7905f3 100644 --- a/includes/Renderer/Stories/Carousel_Renderer.php +++ b/includes/Renderer/Stories/Carousel_Renderer.php @@ -79,7 +79,7 @@ public function load_assets(): void { /** * Renders the stories output for given attributes. * - * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @SuppressWarnings("PHPMD.UnusedLocalVariable") * * @since 1.5.0 * diff --git a/includes/Renderer/Stories/Generic_Renderer.php b/includes/Renderer/Stories/Generic_Renderer.php index 6ad68611c18a..f603e0c90687 100644 --- a/includes/Renderer/Stories/Generic_Renderer.php +++ b/includes/Renderer/Stories/Generic_Renderer.php @@ -60,7 +60,7 @@ public function init(): void { /** * Renders the stories output for given attributes. * - * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @SuppressWarnings("PHPMD.UnusedLocalVariable") * * @since 1.5.0 * @@ -86,7 +86,7 @@ function () { $this->render_single_story_content(); $this->next(); }, - $this->stories + $this->stories ); $this->maybe_render_archive_link(); ?> diff --git a/includes/Renderer/Stories/Renderer.php b/includes/Renderer/Stories/Renderer.php index 82058fc1f0d7..f1ac41677983 100644 --- a/includes/Renderer/Stories/Renderer.php +++ b/includes/Renderer/Stories/Renderer.php @@ -42,8 +42,8 @@ /** * Renderer class. * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") + * @SuppressWarnings("PHPMD.TooManyPublicMethods") * * @phpstan-import-type StoryAttributes from \Google\Web_Stories\Story_Query * @@ -304,7 +304,7 @@ public function add_amp_post_template_css(): void { /** * Returns story item data. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.5.0 * diff --git a/includes/Renderer/Story/Embed.php b/includes/Renderer/Story/Embed.php index b2053cc89cc6..5c33406faa25 100644 --- a/includes/Renderer/Story/Embed.php +++ b/includes/Renderer/Story/Embed.php @@ -77,7 +77,7 @@ public function __construct( Story $story, Assets $assets, Context $context ) { /** * Renders the block output in default context. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 * diff --git a/includes/Renderer/Story/Singleton.php b/includes/Renderer/Story/Singleton.php index d53c47f1f5eb..30f3eccdf137 100644 --- a/includes/Renderer/Story/Singleton.php +++ b/includes/Renderer/Story/Singleton.php @@ -83,7 +83,7 @@ public function __construct( Story $story, Assets $assets ) { /** * Renders the block output in default context. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.30.0 * diff --git a/includes/Settings.php b/includes/Settings.php index 355c415739b3..04d5a3b76fbc 100644 --- a/includes/Settings.php +++ b/includes/Settings.php @@ -183,7 +183,7 @@ public function prime_option_caches(): void { /** * Register settings. * - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.0.0 */ @@ -454,7 +454,7 @@ public function register(): void { /** * Returns the value for a given setting. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.12.0 * diff --git a/includes/Widgets/Stories.php b/includes/Widgets/Stories.php index 823678caf09d..5b7395dd08e7 100644 --- a/includes/Widgets/Stories.php +++ b/includes/Widgets/Stories.php @@ -32,7 +32,7 @@ /** * Class Stories * - * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings("PHPMD.ExcessiveClassComplexity") * * @phpstan-type InputArgs array{ * type?: string, @@ -167,8 +167,8 @@ public function widget( $args, $instance ): void { /** * Display widget form. * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.NPathComplexity") + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") * * @since 1.5.0 * @@ -409,7 +409,7 @@ public function form( $instance ): string { /** * Update widget settings. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.5.0 * diff --git a/includes/namespace.php b/includes/namespace.php index c0a0d4c57347..1eddc13cbf1a 100644 --- a/includes/namespace.php +++ b/includes/namespace.php @@ -35,7 +35,7 @@ /** * Handles plugin activation. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.0.0 * @@ -110,7 +110,7 @@ function remove_site( WP_Error $error, $site ): void { /** * Handles plugin deactivation. * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings("PHPMD.BooleanArgumentFlag") * * @since 1.0.0 * @@ -163,7 +163,7 @@ function load_functions(): void { * * Like rest_preload_api_request() in core, but embeds links and removes trailing slashes. * - * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings("PHPMD.NPathComplexity") * * @since 1.2.0 * diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5e86220a973b..2c74e79b84c0 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -17,6 +17,10 @@ parameters: ignoreErrors: - identifier: missingType.generics + - + identifier: requireOnce.fileNotFound + - + identifier: require.fileNotFound - message: '/^Parameter #2 \$args of method WP_Customize_Manager::add_setting\(\)/' path: includes/Admin/Customizer.php @@ -61,5 +65,3 @@ parameters: - IS_WPCOM - GOOGLESITEKIT_VERSION - AMP__VERSION - featureToggles: - requireFileExists: false diff --git a/tests/phpstan/src/ServiceContainerDynamicReturnTypeExtension.php b/tests/phpstan/src/ServiceContainerDynamicReturnTypeExtension.php index bd84bed79575..b974526af769 100644 --- a/tests/phpstan/src/ServiceContainerDynamicReturnTypeExtension.php +++ b/tests/phpstan/src/ServiceContainerDynamicReturnTypeExtension.php @@ -70,7 +70,8 @@ public function getTypeFromMethodCall( case 'get': return $this->getGetTypeFromMethodCall( $methodReflection, - $methodCall + $methodCall, + $scope, ); case 'has': @@ -85,9 +86,12 @@ public function getTypeFromMethodCall( private function getGetTypeFromMethodCall( MethodReflection $methodReflection, - MethodCall $methodCall + MethodCall $methodCall, + Scope $scope ): Type { - $return_type = ParametersAcceptorSelector::selectSingle( + $return_type = ParametersAcceptorSelector::selectFromArgs( + $scope, + $methodCall->getArgs(), $methodReflection->getVariants() )->getReturnType(); diff --git a/tests/phpstan/src/ServicesDynamicReturnTypeExtension.php b/tests/phpstan/src/ServicesDynamicReturnTypeExtension.php index 2947a504f0a8..0aca9fbbdab4 100644 --- a/tests/phpstan/src/ServicesDynamicReturnTypeExtension.php +++ b/tests/phpstan/src/ServicesDynamicReturnTypeExtension.php @@ -71,7 +71,8 @@ public function getTypeFromStaticMethodCall( case 'get': return $this->getGetTypeFromStaticMethodCall( $methodReflection, - $methodCall + $methodCall, + $scope ); } @@ -80,9 +81,12 @@ public function getTypeFromStaticMethodCall( private function getGetTypeFromStaticMethodCall( MethodReflection $methodReflection, - StaticCall $methodCall + StaticCall $methodCall, + Scope $scope ): Type { - $return_type = ParametersAcceptorSelector::selectSingle( + $return_type = ParametersAcceptorSelector::selectFromArgs( + $scope, + $methodCall->getArgs(), $methodReflection->getVariants() )->getReturnType(); diff --git a/tests/phpunit/integration/tests/Model/Story.php b/tests/phpunit/integration/tests/Model/Story.php index 80eaa6d935e9..86660df9e0d3 100644 --- a/tests/phpunit/integration/tests/Model/Story.php +++ b/tests/phpunit/integration/tests/Model/Story.php @@ -155,9 +155,7 @@ public function test_load_from_post_with_poster(): void { $this->assertEquals( $story->get_url(), get_permalink( $post ) ); $this->assertStringContainsString( 'paint-640x853.jpeg', $story->get_poster_portrait() ); $this->assertNotEmpty( $story->get_poster_sizes() ); - $this->assertIsString( $story->get_poster_sizes() ); $this->assertNotEmpty( $story->get_poster_srcset() ); - $this->assertIsString( $story->get_poster_srcset() ); } /** @@ -244,8 +242,6 @@ public function test_load_from_post_with_poster_and_poster_meta(): void { $this->assertEquals( $story->get_url(), get_permalink( $post ) ); $this->assertStringContainsString( 'paint-640x853.jpeg', $story->get_poster_portrait() ); $this->assertNotEmpty( $story->get_poster_sizes() ); - $this->assertIsString( $story->get_poster_sizes() ); $this->assertNotEmpty( $story->get_poster_srcset() ); - $this->assertIsString( $story->get_poster_srcset() ); } } diff --git a/tests/phpunit/integration/tests/REST_API/Stories_Controller.php b/tests/phpunit/integration/tests/REST_API/Stories_Controller.php index 4a4117f75940..fd8874f0f6b5 100644 --- a/tests/phpunit/integration/tests/REST_API/Stories_Controller.php +++ b/tests/phpunit/integration/tests/REST_API/Stories_Controller.php @@ -930,7 +930,6 @@ public function test_get_collection_params(): void { $this->assertArrayHasKey( 'web_stories_demo', $collection_params ); $this->assertArrayHasKey( 'orderby', $collection_params ); $this->assertArrayHasKey( 'enum', $collection_params['orderby'] ); - $this->assertIsArray( $collection_params['orderby'] ); $this->assertIsArray( $collection_params['orderby']['enum'] ); $this->assertContains( 'story_author', $collection_params['orderby']['enum'] ); } diff --git a/tests/phpunit/integration/tests/Tracking.php b/tests/phpunit/integration/tests/Tracking.php index 1fd7b1f821a3..0a6d78430211 100644 --- a/tests/phpunit/integration/tests/Tracking.php +++ b/tests/phpunit/integration/tests/Tracking.php @@ -187,14 +187,10 @@ public function test_get_settings(): void { $this->assertSame( 'administrator', $settings['userProperties']['userRole'] ); $this->assertSame( 'enableFoo,enableBar', $settings['userProperties']['enabledExperiments'] ); $this->assertSame( WEBSTORIES_VERSION, $settings['userProperties']['pluginVersion'] ); - $this->assertIsString( $settings['userProperties']['wpVersion'] ); - $this->assertIsString( $settings['userProperties']['phpVersion'] ); $this->assertIsInt( $settings['userProperties']['isMultisite'] ); $this->assertIsString( $settings['userProperties']['adNetwork'] ); $this->assertIsString( $settings['userProperties']['analytics'] ); $this->assertIsString( $settings['userProperties']['activePlugins'] ); - $this->assertIsString( $settings['userProperties']['serverEnvironment'] ); - $this->assertIsString( $settings['userProperties']['pluginVersion'] ); } /**