From f919899759c8ed64039fef2987ff686f508a8bdf Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Sat, 21 Dec 2024 21:44:08 +0200 Subject: [PATCH] chore: bump PHPStan to v2.x (#153) --- composer.json | 4 +- composer.lock | 212 ++++++++++++--------------------- phpstan.neon.dist | 8 +- src/Admin/SettingsRegistry.php | 2 +- src/Auth/ProviderRegistry.php | 8 +- src/Model/Client.php | 4 +- src/Model/User.php | 2 +- 7 files changed, 89 insertions(+), 151 deletions(-) diff --git a/composer.json b/composer.json index 65c17058..f38ad292 100644 --- a/composer.json +++ b/composer.json @@ -44,8 +44,8 @@ "php-stubs/woocommerce-stubs": "^9.0", "phpcompatibility/php-compatibility": "dev-develop as 9.99.99", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.2", - "szepeviktor/phpstan-wordpress": "^1.1.5", + "phpstan/phpstan": "^2.0.0", + "szepeviktor/phpstan-wordpress": "^2.0.0", "wp-cli/wp-cli-bundle": "^2.8.1", "wp-graphql/wp-graphql-testcase": "^3.0.1" }, diff --git a/composer.lock b/composer.lock index 77e53718..f3b152da 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": "018fda230e4587301e05fa7810c4d9a8", + "content-hash": "567e66d248579bfdcf8d3584ebb25c7c", "packages": [ { "name": "axepress/wp-graphql-plugin-boilerplate", @@ -492,35 +492,30 @@ }, { "name": "league/oauth2-client", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth2-client.git", - "reference": "160d6274b03562ebeb55ed18399281d8118b76c8" + "reference": "3d5cf8d0543731dfb725ab30e4d7289891991e13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/160d6274b03562ebeb55ed18399281d8118b76c8", - "reference": "160d6274b03562ebeb55ed18399281d8118b76c8", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/3d5cf8d0543731dfb725ab30e4d7289891991e13", + "reference": "3d5cf8d0543731dfb725ab30e4d7289891991e13", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "^6.0 || ^7.0", - "paragonie/random_compat": "^1 || ^2 || ^9.99", - "php": "^5.6 || ^7.0 || ^8.0" + "ext-json": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "php": "^7.1 || >=8.0.0 <8.5.0" }, "require-dev": { "mockery/mockery": "^1.3.5", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5", - "squizlabs/php_codesniffer": "^2.3 || ^3.0" + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "^3.11" }, "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.0.x-dev" - } - }, "autoload": { "psr-4": { "League\\OAuth2\\Client\\": "src/" @@ -556,9 +551,9 @@ ], "support": { "issues": "https://github.com/thephpleague/oauth2-client/issues", - "source": "https://github.com/thephpleague/oauth2-client/tree/2.7.0" + "source": "https://github.com/thephpleague/oauth2-client/tree/2.8.0" }, - "time": "2023-04-16T18:19:15+00:00" + "time": "2024-12-11T05:05:52+00:00" }, { "name": "league/oauth2-facebook", @@ -857,56 +852,6 @@ }, "time": "2020-04-20T13:59:44+00:00" }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" - }, { "name": "psr/http-client", "version": "1.0.3", @@ -2483,13 +2428,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "3.x-dev" } }, "autoload": { @@ -3305,16 +3250,16 @@ }, { "name": "lucatume/wp-browser", - "version": "3.7.10", + "version": "3.7.11", "source": { "type": "git", "url": "https://github.com/lucatume/wp-browser.git", - "reference": "7d9a5079fe8bbdc9a4f04b6073d8521293c2d7da" + "reference": "4081b1c9b9f8643db002cc8816bbafd779ef97b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lucatume/wp-browser/zipball/7d9a5079fe8bbdc9a4f04b6073d8521293c2d7da", - "reference": "7d9a5079fe8bbdc9a4f04b6073d8521293c2d7da", + "url": "https://api.github.com/repos/lucatume/wp-browser/zipball/4081b1c9b9f8643db002cc8816bbafd779ef97b8", + "reference": "4081b1c9b9f8643db002cc8816bbafd779ef97b8", "shasum": "" }, "require": { @@ -3390,7 +3335,7 @@ ], "support": { "issues": "https://github.com/lucatume/wp-browser/issues", - "source": "https://github.com/lucatume/wp-browser/tree/3.7.10" + "source": "https://github.com/lucatume/wp-browser/tree/3.7.11" }, "funding": [ { @@ -3398,7 +3343,7 @@ "type": "github" } ], - "time": "2024-11-29T14:01:28+00:00" + "time": "2024-12-09T15:53:54+00:00" }, { "name": "mck89/peast", @@ -4005,16 +3950,16 @@ }, { "name": "php-stubs/woocommerce-stubs", - "version": "v9.4.2", + "version": "v9.5.0", "source": { "type": "git", "url": "https://github.com/php-stubs/woocommerce-stubs.git", - "reference": "d4347943eac3af274089abf1af9449e9dab45a96" + "reference": "813f3cad9892bd3b6ffae9334a4ccaa73692b439" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/d4347943eac3af274089abf1af9449e9dab45a96", - "reference": "d4347943eac3af274089abf1af9449e9dab45a96", + "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/813f3cad9892bd3b6ffae9334a4ccaa73692b439", + "reference": "813f3cad9892bd3b6ffae9334a4ccaa73692b439", "shasum": "" }, "require": { @@ -4043,9 +3988,9 @@ ], "support": { "issues": "https://github.com/php-stubs/woocommerce-stubs/issues", - "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v9.4.2" + "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v9.5.0" }, - "time": "2024-11-19T19:49:15+00:00" + "time": "2024-12-17T03:31:31+00:00" }, { "name": "php-stubs/wordpress-stubs", @@ -4731,20 +4676,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.12", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" + "reference": "50d276fc3bf1430ec315f2f109bbde2769821524" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", - "reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d276fc3bf1430ec315f2f109bbde2769821524", + "reference": "50d276fc3bf1430ec315f2f109bbde2769821524", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -4785,7 +4730,7 @@ "type": "github" } ], - "time": "2024-11-28T22:13:23+00:00" + "time": "2024-12-17T17:14:01+00:00" }, { "name": "phpunit/php-code-coverage", @@ -6760,16 +6705,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.1", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", "shasum": "" }, "require": { @@ -6836,7 +6781,7 @@ "type": "open_collective" } ], - "time": "2024-11-16T12:02:36+00:00" + "time": "2024-12-11T16:04:26+00:00" }, { "name": "symfony/browser-kit", @@ -7549,8 +7494,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7625,8 +7570,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7703,8 +7648,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7787,8 +7732,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7861,8 +7806,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -7937,8 +7882,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -8017,8 +7962,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -8443,30 +8388,29 @@ }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.5", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e" }, "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/f7beb13cd22998e3d913fdb897a1e2553ccd637e", + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e", "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" }, @@ -8500,9 +8444,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.1" }, - "time": "2024-06-28T22:27:19+00:00" + "time": "2024-12-01T02:13:05+00:00" }, { "name": "theseer/tokenizer", @@ -8871,9 +8815,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "core", @@ -8886,7 +8827,10 @@ "core update", "core update-db", "core version" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -9007,9 +8951,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "db", @@ -9029,7 +8970,10 @@ "db tables", "db size", "db columns" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -9510,9 +9454,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "plugin", @@ -9547,7 +9488,10 @@ "theme status", "theme update", "theme mod list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -10883,12 +10827,12 @@ }, "type": "library", "extra": { - "wordpress-install-dir": "local/public", "installer-paths": { "local/public/wp-content/plugins/{$name}/": [ "type:wordpress-plugin" ] - } + }, + "wordpress-install-dir": "local/public" }, "autoload": { "psr-4": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c3b698ef..ac842ff6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,13 +2,9 @@ parameters: level: 8 treatPhpDocTypesAsCertain: false inferPrivatePropertyTypeFromConstructor: true - checkAlwaysTrueCheckTypeFunctionCall: true - checkAlwaysTrueInstanceof: true - checkAlwaysTrueStrictComparison: true checkExplicitMixedMissingReturn: true checkFunctionNameCase: true checkInternalClassCaseSensitivity: true - checkMissingIterableValueType: true checkTooWideReturnTypesInProtectedAndPublicMethods: true polluteScopeWithAlwaysIterableForeach: false polluteScopeWithLoopInitialAssignments: false @@ -17,6 +13,10 @@ parameters: reportWrongPhpDocTypeInVarTag: true bootstrapFiles: - phpstan/constants.php + dynamicConstantNames: + - ADMIN_COOKIE_PATH + - COOKIEPATH + - SITECOOKIEPATH paths: - wp-graphql-headless-login.php - access-functions.php diff --git a/src/Admin/SettingsRegistry.php b/src/Admin/SettingsRegistry.php index eae6b65e..d2e0b9a8 100644 --- a/src/Admin/SettingsRegistry.php +++ b/src/Admin/SettingsRegistry.php @@ -62,7 +62,7 @@ public static function get_all(): array { self::init(); } - /** @var \WPGraphQL\Login\Admin\Settings\AbstractSettings[] */ + /** @var array */ return self::$settings; } diff --git a/src/Auth/ProviderRegistry.php b/src/Auth/ProviderRegistry.php index e889343f..38d3a662 100644 --- a/src/Auth/ProviderRegistry.php +++ b/src/Auth/ProviderRegistry.php @@ -53,8 +53,6 @@ public function __construct() { // Validate the providers, and then add them to the registry. foreach ( $this->registered_providers as $slug => $class ) { - /** @var string $class */ - // Skip if the provider class does not exist. if ( ! class_exists( $class ) ) { graphql_debug( @@ -83,11 +81,7 @@ public function __construct() { continue; } - /** - * Skip if the provider is disabled. - * - * @var \WPGraphQL\Login\Auth\ProviderConfig\ProviderConfig $class - */ + // Skip if the provider is disabled. if ( ! $class::is_enabled() ) { continue; } diff --git a/src/Model/Client.php b/src/Model/Client.php index 16ba4b7d..c3cc1611 100644 --- a/src/Model/Client.php +++ b/src/Model/Client.php @@ -15,10 +15,10 @@ * Class - Client * * @property ?string $authorizationUrl - * @property array $clientOptions + * @property array $clientOptions * @property ?string $id * @property bool $isEnabled - * @property array $loginOptions + * @property array $loginOptions * @property ?string $name * @property ?int $order * @property string $provider diff --git a/src/Model/User.php b/src/Model/User.php index 32d083d5..4d914119 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -21,7 +21,7 @@ * @property ?string $refreshToken * @property ?int $refreshTokenExpiration * @property ?string $userSecret - * @property ?array $linkedIdentities + * @property ?array $linkedIdentities */ class User { /**