diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index dc0c020..560e228 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -22,6 +22,7 @@ jobs: scenario: "symfony7" - php: "8.4" scenario: "symfony6" + phpstan_can_fail: true steps: - uses: actions/checkout@v3 @@ -52,6 +53,7 @@ jobs: - name: PHPStan run: vendor/bin/phpstan analyse -c phpstan.neon src/ + continue-on-error: ${{ matrix.phpstan_can_fail == true }} - name: phpunit run: vendor/bin/phpunit diff --git a/.scenarios.lock/symfony6/composer.json b/.scenarios.lock/symfony6/composer.json index e15e3a1..bd466a4 100644 --- a/.scenarios.lock/symfony6/composer.json +++ b/.scenarios.lock/symfony6/composer.json @@ -27,9 +27,10 @@ "g1a/composer-test-scenarios": "^3.0", "giggsey/libphonenumber-for-php": "^8.0", "friendsofphp/php-cs-fixer": "^3.0.0", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/extension-installer": "^1.3" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan-deprecation-rules": "^2.0" }, "suggest": { "giggsey/libphonenumber-for-php": "^1.1 to manage integration with phone number bundle" diff --git a/.scenarios.lock/symfony6/composer.lock b/.scenarios.lock/symfony6/composer.lock index 5ae9d38..825b924 100644 --- a/.scenarios.lock/symfony6/composer.lock +++ b/.scenarios.lock/symfony6/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": "1c315337075dd3e040908d420677cde9", + "content-hash": "e8509247b8d3e3b8f6274f92f8cf4390", "packages": [ { "name": "friendsofphp/proxy-manager-lts", @@ -2783,15 +2783,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.33", + "version": "2.1.44", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", - "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a88c083c668b2c364a425c9b3171b2d9ea5d218", + "reference": "4a88c083c668b2c364a425c9b3171b2d9ea5d218", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -2832,34 +2832,85 @@ "type": "github" } ], - "time": "2026-02-28T20:30:03+00:00" + "time": "2026-03-25T17:34:21+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.39" + }, + "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.", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.4" + }, + "time": "2026-02-09T13:21:14+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.2", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e" + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^5", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -2880,11 +2931,14 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" }, - "time": "2024-12-17T17:20:49+00:00" + "time": "2026-02-14T09:05:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/.scenarios.lock/symfony7/composer.json b/.scenarios.lock/symfony7/composer.json index 2ab4e9e..9ccdb51 100644 --- a/.scenarios.lock/symfony7/composer.json +++ b/.scenarios.lock/symfony7/composer.json @@ -27,9 +27,10 @@ "g1a/composer-test-scenarios": "^3.0", "giggsey/libphonenumber-for-php": "^8.0", "friendsofphp/php-cs-fixer": "^3.0.0", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/extension-installer": "^1.3" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan-deprecation-rules": "^2.0" }, "suggest": { "giggsey/libphonenumber-for-php": "^1.1 to manage integration with phone number bundle" diff --git a/.scenarios.lock/symfony7/composer.lock b/.scenarios.lock/symfony7/composer.lock index 1c595fa..383a50f 100644 --- a/.scenarios.lock/symfony7/composer.lock +++ b/.scenarios.lock/symfony7/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": "f9219557d36f86280019204202d242f0", + "content-hash": "0f13aa076908861f51f587b76b50c3d1", "packages": [ { "name": "friendsofphp/proxy-manager-lts", @@ -2700,15 +2700,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.33", + "version": "2.1.44", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", - "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a88c083c668b2c364a425c9b3171b2d9ea5d218", + "reference": "4a88c083c668b2c364a425c9b3171b2d9ea5d218", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -2749,34 +2749,85 @@ "type": "github" } ], - "time": "2026-02-28T20:30:03+00:00" + "time": "2026-03-25T17:34:21+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.39" + }, + "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.", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.4" + }, + "time": "2026-02-09T13:21:14+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.2", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e" + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^5", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -2797,11 +2848,14 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" }, - "time": "2024-12-17T17:20:49+00:00" + "time": "2026-02-14T09:05:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/.scenarios.lock/symfony8/composer.json b/.scenarios.lock/symfony8/composer.json index 1de19a1..128abb8 100644 --- a/.scenarios.lock/symfony8/composer.json +++ b/.scenarios.lock/symfony8/composer.json @@ -27,9 +27,10 @@ "g1a/composer-test-scenarios": "^3.0", "giggsey/libphonenumber-for-php": "^8.0", "friendsofphp/php-cs-fixer": "^3.0.0", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/extension-installer": "^1.3" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan-deprecation-rules": "^2.0" }, "suggest": { "giggsey/libphonenumber-for-php": "^1.1 to manage integration with phone number bundle" diff --git a/.scenarios.lock/symfony8/composer.lock b/.scenarios.lock/symfony8/composer.lock index c6b1e2a..810b795 100644 --- a/.scenarios.lock/symfony8/composer.lock +++ b/.scenarios.lock/symfony8/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": "3a71b78932a688856c3a7ca8c3bd96c2", + "content-hash": "86d119e525c322fe23cf0ae9a08d6a93", "packages": [ { "name": "friendsofphp/proxy-manager-lts", @@ -2698,15 +2698,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.33", + "version": "2.1.44", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", - "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a88c083c668b2c364a425c9b3171b2d9ea5d218", + "reference": "4a88c083c668b2c364a425c9b3171b2d9ea5d218", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -2747,34 +2747,85 @@ "type": "github" } ], - "time": "2026-02-28T20:30:03+00:00" + "time": "2026-03-25T17:34:21+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.39" + }, + "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.", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.4" + }, + "time": "2026-02-09T13:21:14+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.2", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e" + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^5", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -2795,11 +2846,14 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" }, - "time": "2024-12-17T17:20:49+00:00" + "time": "2026-02-14T09:05:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/CHANGELOG.md b/CHANGELOG.md index 091d7d0..6f14605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [BREAKING] Drop support for PHP < 8.4 - [BREAKING] Drop support for Symfony < 6.0 - Allow Symfony 7 and 8 +- [BREAKING] phpstan-extension: Drop support PHPStan < 2.0 ## 2.1.1 diff --git a/composer.json b/composer.json index 4e7cdd4..f18f541 100644 --- a/composer.json +++ b/composer.json @@ -27,9 +27,10 @@ "g1a/composer-test-scenarios": "^3.0", "giggsey/libphonenumber-for-php": "^8.0", "friendsofphp/php-cs-fixer": "^3.0.0", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpstan/extension-installer": "^1.3" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan-deprecation-rules": "^2.0" }, "suggest": { "giggsey/libphonenumber-for-php": "^1.1 to manage integration with phone number bundle" diff --git a/composer.lock b/composer.lock index 3c3b492..91df9aa 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": "0c14ef03560518debcd8c2d7f9e17e88", + "content-hash": "7a30683e64adfecbfa351e811bf409bb", "packages": [ { "name": "friendsofphp/proxy-manager-lts", @@ -2698,15 +2698,15 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.33", + "version": "2.1.44", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37982d6fc7cbb746dda7773530cda557cdf119e1", - "reference": "37982d6fc7cbb746dda7773530cda557cdf119e1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4a88c083c668b2c364a425c9b3171b2d9ea5d218", + "reference": "4a88c083c668b2c364a425c9b3171b2d9ea5d218", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -2747,34 +2747,85 @@ "type": "github" } ], - "time": "2026-02-28T20:30:03+00:00" + "time": "2026-03-25T17:34:21+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "reference": "6b5571001a7f04fa0422254c30a0017ec2f2cacc", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.39" + }, + "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.", + "keywords": [ + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.4" + }, + "time": "2026-02-09T13:21:14+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.2", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e" + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e", - "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.1.32" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^5", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -2795,11 +2846,14 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" }, - "time": "2024-12-17T17:20:49+00:00" + "time": "2026-02-14T09:05:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8b095a5..e2c5946 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,66 +1,229 @@ parameters: ignoreErrors: - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:addIdentifiers\\(\\) has parameter \\$dirtyFields with no value type specified in iterable type array\\.$#" + rawMessage: 'Parameter #1 $id of method Mapado\RestClientSdk\UnitOfWork::clear() expects string, mixed given.' + identifier: argument.type + count: 1 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $id of method Mapado\RestClientSdk\UnitOfWork::getDirtyEntity() expects string, mixed given.' + identifier: argument.type + count: 1 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $id of method Mapado\RestClientSdk\UnitOfWork::registerClean() expects string, mixed given.' + identifier: argument.type + count: 3 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $key of method Mapado\RestClientSdk\EntityRepository::removeFromCache() expects string, mixed given.' + identifier: argument.type + count: 2 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $key of method Mapado\RestClientSdk\EntityRepository::saveToCache() expects string, mixed given.' + identifier: argument.type + count: 3 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $path of method Mapado\RestClientSdk\EntityRepository::addQueryParameter() expects string, mixed given.' + identifier: argument.type + count: 1 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $path of method Mapado\RestClientSdk\RestClient::delete() expects string, mixed given.' + identifier: argument.type + count: 1 + path: src/EntityRepository.php + + - + rawMessage: 'Parameter #1 $array of function array_diff_assoc expects an array of values castable to string, array given.' + identifier: argument.type + count: 1 + path: src/Helper/ArrayHelper.php + + - + rawMessage: 'Parameter #2 $arrays of function array_diff_assoc expects an array of values castable to string, array given.' + identifier: argument.type + count: 1 + path: src/Helper/ArrayHelper.php + + - + rawMessage: 'Parameter #1 $callback of function array_map expects (callable(mixed): mixed)|null, Closure(array|null): (object|null) given.' + identifier: argument.type + count: 1 + path: src/Model/ModelHydrator.php + + - + rawMessage: 'Call to function is_object() with object will always evaluate to true.' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Model/Serializer.php + + - + rawMessage: Cannot cast mixed to string. + identifier: cast.string + count: 1 + path: src/Model/Serializer.php + + - + rawMessage: 'Method Mapado\RestClientSdk\Model\Serializer::recursiveSerialize() should return array|string but returns mixed.' + identifier: return.type + count: 1 + path: src/Model/Serializer.php + + - + rawMessage: 'Argument of an invalid type mixed supplied for foreach, only iterables are supported.' + identifier: foreach.nonIterable count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:addIdentifiers\\(\\) has parameter \\$newSerializedModel with no value type specified in iterable type array\\.$#" + rawMessage: Cannot access offset mixed on mixed. + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: src/UnitOfWork.php + + - + rawMessage: Cannot access offset non-falsy-string on mixed. + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: src/UnitOfWork.php + + - + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::addIdentifiers() has parameter $dirtyFields with no value type specified in iterable type array.' + identifier: missingType.iterableValue + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::addIdentifiers() has parameter $newSerializedModel with no value type specified in iterable type array.' + identifier: missingType.iterableValue + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::addIdentifiers() return type has no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:addIdentifiers\\(\\) return type has no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::findOldRelation() has parameter $oldValue with no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:findOldRelation\\(\\) has parameter \\$oldValue with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::findOldRelation() has parameter $relationValue with no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:findOldRelation\\(\\) has parameter \\$relationValue with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::findOldRelation() return type has no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:findOldRelation\\(\\) return type has no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::findOldRelation() should return array|string but returns mixed.' + identifier: return.type count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyData\\(\\) has parameter \\$newSerializedModel with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyData() has parameter $newSerializedModel with no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyData\\(\\) has parameter \\$oldSerializedModel with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyData() has parameter $oldSerializedModel with no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyData\\(\\) return type has no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyData() return type has no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyFields\\(\\) has parameter \\$newSerializedModel with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyFields() has parameter $newSerializedModel with no value type specified in iterable type array.' + identifier: missingType.iterableValue count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyFields\\(\\) has parameter \\$oldSerializedModel with no value type specified in iterable type array\\.$#" + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyFields() has parameter $oldSerializedModel with no value type specified in iterable type array.' + identifier: missingType.iterableValue + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getDirtyFields() return type has no value type specified in iterable type array.' + identifier: missingType.iterableValue + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Method Mapado\RestClientSdk\UnitOfWork::getEntityId() has parameter $stringOrEntity with no value type specified in iterable type array.' + identifier: missingType.iterableValue + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #1 $newSerializedModel of method Mapado\RestClientSdk\UnitOfWork::addIdentifiers() expects array, mixed given.' + identifier: argument.type + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #1 $newSerializedModel of method Mapado\RestClientSdk\UnitOfWork::getDirtyFields() expects array, mixed given.' + identifier: argument.type + count: 2 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #1 $relationValue of method Mapado\RestClientSdk\UnitOfWork::findOldRelation() expects array|string, mixed given.' + identifier: argument.type + count: 1 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #1 $stringOrEntity of static method Mapado\RestClientSdk\UnitOfWork::getEntityId() expects array|string, mixed given.' + identifier: argument.type + count: 3 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #1 $value of function count expects array|Countable, mixed given.' + identifier: argument.type + count: 2 + path: src/UnitOfWork.php + + - + rawMessage: 'Parameter #2 $array2 of static method Mapado\RestClientSdk\Helper\ArrayHelper::arraySame() expects array, mixed given.' + identifier: argument.type count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getDirtyFields\\(\\) return type has no value type specified in iterable type array\\.$#" + rawMessage: 'Parameter #2 $oldSerializedModel of method Mapado\RestClientSdk\UnitOfWork::getDirtyFields() expects array, mixed given.' + identifier: argument.type count: 1 path: src/UnitOfWork.php - - message: "#^Method Mapado\\\\RestClientSdk\\\\UnitOfWork\\:\\:getEntityId\\(\\) has parameter \\$stringOrEntity with no value type specified in iterable type array\\.$#" + rawMessage: 'Parameter #2 $oldValue of method Mapado\RestClientSdk\UnitOfWork::findOldRelation() expects array, mixed given.' + identifier: argument.type count: 1 path: src/UnitOfWork.php diff --git a/phpstan-extension/Reflection/RepositoryMagicFindExtension.php b/phpstan-extension/Reflection/RepositoryMagicFindExtension.php index 33e99f3..2b601f1 100644 --- a/phpstan-extension/Reflection/RepositoryMagicFindExtension.php +++ b/phpstan-extension/Reflection/RepositoryMagicFindExtension.php @@ -4,42 +4,57 @@ namespace Mapado\RestClientSdk\PHPStan\Reflection; -use PHPStan\Broker\Broker; -use PHPStan\Reflection\BrokerAwareExtension; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\Dummy\DummyMethodReflection; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\MethodsClassReflectionExtension; +use PHPStan\Reflection\ReflectionProvider; -class RepositoryMagicFindExtension implements MethodsClassReflectionExtension, BrokerAwareExtension +class RepositoryMagicFindExtension implements MethodsClassReflectionExtension { - /** @var Broker */ - private $broker; + private ReflectionProvider $reflectionProvider; - public function setBroker(Broker $broker): void + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } - public function hasMethod(ClassReflection $classReflection, string $methodName): bool - { - if (0 !== mb_strpos($methodName, 'findBy') - && 0 !== mb_strpos($methodName, 'findOneBy') + public function hasMethod( + ClassReflection $classReflection, + string $methodName, + ): bool { + if ( + 0 !== mb_strpos($methodName, 'findBy') && + 0 !== mb_strpos($methodName, 'findOneBy') ) { return false; } - if ('Mapado\RestClientSdk\EntityRepository' === $classReflection->getName()) { + if ( + 'Mapado\RestClientSdk\EntityRepository' === + $classReflection->getName() + ) { return true; } - if (!$this->broker->hasClass('Mapado\RestClientSdk\EntityRepository')) { + if ( + !$this->reflectionProvider->hasClass( + 'Mapado\RestClientSdk\EntityRepository', + ) + ) { return false; } - return $classReflection->isSubclassOf('Mapado\RestClientSdk\EntityRepository'); + return $classReflection->isSubclassOfClass( + $this->reflectionProvider->getClass( + 'Mapado\RestClientSdk\EntityRepository', + ), + ); } - public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection - { + public function getMethod( + ClassReflection $classReflection, + string $methodName, + ): MethodReflection { + /** @phpstan-ignore-next-line phpstanApi.constructor */ return new DummyMethodReflection($methodName); } } diff --git a/phpstan-extension/Type/GetRepositoryDynamicReturnTypeExtension.php b/phpstan-extension/Type/GetRepositoryDynamicReturnTypeExtension.php index 2d33d68..87f8caa 100644 --- a/phpstan-extension/Type/GetRepositoryDynamicReturnTypeExtension.php +++ b/phpstan-extension/Type/GetRepositoryDynamicReturnTypeExtension.php @@ -8,29 +8,29 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParametersAcceptorSelector; -use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\MixedType; use PHPStan\Type\Type; -class GetRepositoryDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension +class GetRepositoryDynamicReturnTypeExtension implements + DynamicMethodReturnTypeExtension { - /** @var string */ - private $sdkClientClass; + private string $sdkClientClass; - /** @var ObjectMetadataResolver */ - private $metadataResolver; + private ObjectMetadataResolver $metadataResolver; public function __construct( string $sdkClientClass, - ObjectMetadataResolver $metadataResolver + ObjectMetadataResolver $metadataResolver, ) { + /** @var class-string $sdkClientClass */ $this->sdkClientClass = $sdkClientClass; $this->metadataResolver = $metadataResolver; } public function getClass(): string { + /** @var class-string */ return $this->sdkClientClass; } @@ -42,20 +42,28 @@ public function isMethodSupported(MethodReflection $methodReflection): bool public function getTypeFromMethodCall( MethodReflection $methodReflection, MethodCall $methodCall, - Scope $scope + Scope $scope, ): Type { - if (0 === count($methodCall->args)) { - return ParametersAcceptorSelector::selectSingle( - $methodReflection->getVariants() + $args = $methodCall->getArgs(); + if (0 === count($args)) { + return ParametersAcceptorSelector::selectFromArgs( + $scope, + $args, + $methodReflection->getVariants(), )->getReturnType(); } - $argType = $scope->getType($methodCall->args[0]->value); - if (!$argType instanceof ConstantStringType) { + $argType = $scope->getType($args[0]->value); + $constantStrings = $argType->getConstantStrings(); + if (count($constantStrings) === 0) { return new MixedType(); } - $objectName = $argType->getValue(); - $className = $this->metadataResolver->resolveClassnameForKey($objectName); - $repositoryClass = $this->metadataResolver->getRepositoryClass($className); + $objectName = $constantStrings[0]->getValue(); + $className = $this->metadataResolver->resolveClassnameForKey( + $objectName, + ); + $repositoryClass = $this->metadataResolver->getRepositoryClass( + $className, + ); return new ObjectRepositoryType($className, $repositoryClass); } diff --git a/phpstan-extension/Type/ObjectMetadataResolver.php b/phpstan-extension/Type/ObjectMetadataResolver.php index fec181f..d5e71c7 100644 --- a/phpstan-extension/Type/ObjectMetadataResolver.php +++ b/phpstan-extension/Type/ObjectMetadataResolver.php @@ -52,6 +52,8 @@ public function getRepositoryClass(string $className): string private function getMetadataForKeyOrClassname(string $value): ClassMetadata { + assert($this->registry !== null); + foreach ($this->registry->getSdkClientList() as $sdkClient) { $mapping = $sdkClient->getMapping(); @@ -78,6 +80,9 @@ private function loadRegistry(string $registryFile): ?SdkClientRegistry throw new \PHPStan\ShouldNotHappenException('Object manager could not be loaded'); } - return require $registryFile; + /** @var SdkClientRegistry|null */ + $registry = require $registryFile; + + return $registry; } } diff --git a/phpstan-extension/Type/ObjectRepositoryDynamicReturnTypeExtension.php b/phpstan-extension/Type/ObjectRepositoryDynamicReturnTypeExtension.php index ca8ab74..66f1377 100644 --- a/phpstan-extension/Type/ObjectRepositoryDynamicReturnTypeExtension.php +++ b/phpstan-extension/Type/ObjectRepositoryDynamicReturnTypeExtension.php @@ -6,24 +6,22 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; -use PHPStan\Broker\Broker; -use PHPStan\Reflection\BrokerAwareExtension; use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\ParametersAcceptorSelector; +use PHPStan\Reflection\ReflectionProvider; +use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; -use PHPStan\Type\TypeWithClassName; -class ObjectRepositoryDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension, BrokerAwareExtension +class ObjectRepositoryDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var Broker */ - private $broker; + private ReflectionProvider $reflectionProvider; - public function setBroker(Broker $broker): void + public function __construct(ReflectionProvider $reflectionProvider) { - $this->broker = $broker; + $this->reflectionProvider = $reflectionProvider; } public function getClass(): string @@ -50,13 +48,15 @@ public function getTypeFromMethodCall( Scope $scope ): Type { $calledOnType = $scope->getType($methodCall->var); - if (!$calledOnType instanceof TypeWithClassName) { + $classNames = $calledOnType->getObjectClassNames(); + if (count($classNames) === 0) { return new MixedType(); } + $className = $classNames[0]; $methodName = $methodReflection->getName(); - if ($this->broker->hasClass($calledOnType->getClassName())) { - $repositoryClassReflection = $this->broker->getClass($calledOnType->getClassName()); + if ($this->reflectionProvider->hasClass($className)) { + $repositoryClassReflection = $this->reflectionProvider->getClass($className); if ( ( ( @@ -71,7 +71,7 @@ public function getTypeFromMethodCall( ) { return ParametersAcceptorSelector::selectFromArgs( $scope, - $methodCall->args, + $methodCall->getArgs(), $repositoryClassReflection->getNativeMethod($methodName)->getVariants() )->getReturnType(); } diff --git a/phpstan.neon b/phpstan.neon index 4b51bb3..937afe3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,11 +1,14 @@ includes: + - phar://phpstan.phar/conf/bleedingEdge.neon - 'phpstan-baseline.neon' - 'aliases.neon' parameters: - level: max - ignoreErrors: [] + level: max + ignoreErrors: [] + treatPhpDocTypesAsCertain: false - paths: - - src - # - Tests/Units + paths: + - src + - phpstan-extension + # - Tests/Units diff --git a/src/Collection/Collection.php b/src/Collection/Collection.php index bf0daf3..91fe781 100644 --- a/src/Collection/Collection.php +++ b/src/Collection/Collection.php @@ -94,7 +94,7 @@ public function getTotalItems(): int } /** - * @param mixed|null $offset + * @param array-key|null $offset * * @phpstan-param E $value */ @@ -108,7 +108,7 @@ public function offsetSet($offset, $value): void } /** - * @param mixed|null $offset + * @param array-key|null $offset */ public function offsetExists($offset): bool { @@ -116,7 +116,7 @@ public function offsetExists($offset): bool } /** - * @param mixed|null $offset + * @param array-key|null $offset */ public function offsetUnset($offset): void { @@ -124,7 +124,7 @@ public function offsetUnset($offset): void } /** - * @param mixed|null $offset + * @param array-key|null $offset * * @return mixed|null * diff --git a/src/EntityRepository.php b/src/EntityRepository.php index ef34a9d..5e37832 100644 --- a/src/EntityRepository.php +++ b/src/EntityRepository.php @@ -129,6 +129,9 @@ public function __call(string $method, array $arguments) $entityList = ArrayHelper::arrayGet($data, $collectionKey); if (!empty($entityList) && is_array($entityList)) { $data = current($entityList); + + $this->assertItemIsArrayOrNull($data, $methodName); + $hydratedData = $hydrator->hydrate($data, $this->entityName); $identifier = $hydratedData->{$this->getClassMetadata()->getIdGetter()}(); @@ -516,12 +519,34 @@ private function assertArray($data, string $methodName): array ); } + /** + * @param mixed $data + * + * @phpstan-assert array|null $data + */ + private function assertItemIsArrayOrNull($data, string $methodName): void + { + if (null === $data) { + return; + } + + if (is_array($data)) { + return; + } + + $type = get_debug_type($data); + + throw new UnexpectedTypeException( + "Item from collection returned by method {$methodName} should be either an array or null. {$type} given.", + ); + } + /** * @template I * * @param array|ResponseInterface|null $data * - * @phpstan-assert array|null $data + * @phpstan-assert array|null $data * * @return array|null */ diff --git a/src/Model/ModelHydrator.php b/src/Model/ModelHydrator.php index d6e5e58..35d07d1 100644 --- a/src/Model/ModelHydrator.php +++ b/src/Model/ModelHydrator.php @@ -41,7 +41,7 @@ public function convertId(string|int $id, string $modelName): string } /** - * @param array|null $data + * @param array|null $data * @param class-string $modelName */ public function hydrate(?array $data, string $modelName): ?object @@ -124,7 +124,7 @@ private function deserializeAll(array $data, string $modelName): Collection /** * convert array to entity * - * @param array|null $data + * @param array|null $data * @param class-string $modelName */ private function deserialize(?array $data, string $modelName): ?object @@ -139,13 +139,13 @@ private function deserialize(?array $data, string $modelName): ?object /** * guess collection classname according to response data * - * @param array $data + * @param array $data */ private function guessCollectionClassname(array $data): string { switch (true) { - case !empty($data['@type']) - && 'hydra:PagedCollection' === $data['@type']: + case !empty($data['@type']) && + 'hydra:PagedCollection' === $data['@type']: return HydraPaginatedCollection::class; case array_key_exists('_embedded', $data): diff --git a/src/RestClient.php b/src/RestClient.php index c8c7a8c..e8aca80 100644 --- a/src/RestClient.php +++ b/src/RestClient.php @@ -111,7 +111,7 @@ public function get(string $path, array $parameters = []) return $this->executeRequest('GET', $requestUrl, $parameters); } catch (ClientException $e) { $response = $e->getResponse(); - if (null !== $response && 404 === $response->getStatusCode()) { + if (404 === $response->getStatusCode()) { return null; } throw new RestClientException( @@ -243,18 +243,8 @@ protected function mergeDefaultParameters(array $parameters): array $defaultParameters['headers'] = ['Referer' => $request->getUri()]; } - /** @var array|null $out */ $out = array_replace_recursive($defaultParameters, $parameters); - if (null === $out) { - throw new \RuntimeException( - sprintf( - 'Error while calling array_replace_recursive in %s. This should not happen.', - __METHOD__, - ), - ); - } - return $out; } diff --git a/src/SdkClient.php b/src/SdkClient.php index 718f4bf..056783e 100644 --- a/src/SdkClient.php +++ b/src/SdkClient.php @@ -196,15 +196,12 @@ public function createProxy(string $id): GhostObjectInterface $proxyModelName = preg_replace('/^\\\\*/', '', $modelName); - /** - * @var \Closure(RealObjectType&GhostObjectInterface, string, array, ?Closure, array) $initializer - */ $initializer = function ( - GhostObjectInterface $proxy, - string $method, - array $parameters, - \Closure|null &$initializer, - array $properties, + ?GhostObjectInterface $proxy = null, + string $method = '', + array $parameters = [], + \Closure|null &$initializer = null, + array $properties = [], ) use ($sdk, $classMetadata, $id, $proxyModelName) { $isAllowedMethod = 'jsonSerialize' === $method