From 988a1cc5387c17e8d6dfd1f608cedac8d1cd8372 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 13:50:47 +0000 Subject: [PATCH] Update dependency ergebnis/phpstan-rules to ^2.17.0 --- tools/.phpstan/composer.json | 2 +- tools/.phpstan/composer.lock | 96 +++- tools/.phpstan/vendor/composer/installed.json | 98 +++- tools/.phpstan/vendor/composer/installed.php | 19 +- .../ergebnis/phpstan-rules/CHANGELOG.md | 23 +- .../ergebnis/phpstan-rules/composer.json | 3 +- .../NoNullableReturnTypeDeclarationRule.php | 43 +- .../NoParameterPassedByReferenceRule.php | 51 +- .../NoParameterWithNullDefaultValueRule.php | 47 +- ...rameterWithNullableTypeDeclarationRule.php | 47 +- .../src/CallLikes/NoNamedArgumentRule.php | 75 +-- .../phpstan-rules/src/Classes/FinalRule.php | 108 ++-- .../src/Classes/NoExtendsRule.php | 80 +-- .../Framework/TestCaseWithSuffixRule.php | 59 +- .../NoNullableReturnTypeDeclarationRule.php | 51 +- .../NoParameterPassedByReferenceRule.php | 59 +- .../NoParameterWithNullDefaultValueRule.php | 55 +- ...rameterWithNullableTypeDeclarationRule.php | 55 +- .../src/Documentation/CodeSample.php | 6 - .../src/Documentation/CodeSampleList.php | 46 ++ .../src/Documentation/ConfigurationKey.php | 44 ++ .../src/Documentation/Description.php | 48 ++ .../src/Documentation/ErrorTip.php | 54 +- .../Documentation/InvalidConfigurationKey.php | 28 + .../src/Documentation/InvalidDescription.php | 33 ++ .../Documentation/InvalidParameterName.php | 28 + .../src/Documentation/InvalidRationale.php | 33 ++ .../src/Documentation/InvalidTip.php | 49 ++ .../src/Documentation/Parameter.php | 42 +- .../src/Documentation/ParameterExample.php | 59 ++ .../src/Documentation/ParameterList.php | 46 ++ .../src/Documentation/ParameterName.php | 44 ++ .../src/Documentation/Rationale.php | 48 ++ .../src/Documentation/Reference.php | 68 +++ .../src/Documentation/RuleDefinition.php | 100 +--- .../phpstan-rules/src/Documentation/Tip.php | 71 +++ .../Expressions/NoAssignByReferenceRule.php | 55 +- .../src/Expressions/NoCompactRule.php | 51 +- .../Expressions/NoErrorSuppressionRule.php | 49 +- .../src/Expressions/NoEvalRule.php | 43 +- .../src/Expressions/NoIssetRule.php | 63 ++- .../src/Files/DeclareStrictTypesRule.php | 47 +- .../src/Files/NoPhpstanIgnoreRule.php | 57 +- .../NoNullableReturnTypeDeclarationRule.php | 59 +- .../NoParameterPassedByReferenceRule.php | 63 ++- .../NoParameterWithNullDefaultValueRule.php | 59 +- ...rameterWithNullableTypeDeclarationRule.php | 59 +- .../src/Functions/NoReturnByReferenceRule.php | 67 ++- .../src/Methods/FinalInAbstractClassRule.php | 76 +-- .../Methods/InvokeParentHookMethodRule.php | 94 ++-- ...nstructorParameterWithDefaultValueRule.php | 71 +-- .../NoNullableReturnTypeDeclarationRule.php | 81 +-- .../NoParameterPassedByReferenceRule.php | 69 ++- ...ameterWithContainerTypeDeclarationRule.php | 118 ++-- .../NoParameterWithNullDefaultValueRule.php | 81 +-- ...rameterWithNullableTypeDeclarationRule.php | 81 +-- .../src/Methods/NoReturnByReferenceRule.php | 71 +-- .../src/Methods/PrivateInFinalClassRule.php | 69 +-- ...rameterWithNullableTypeDeclarationRule.php | 73 +-- .../PropertyHooks/NoReturnByReferenceRule.php | 75 +-- .../src/Statements/NoSwitchRule.php | 67 ++- .../vendor/ergebnis/version/CHANGELOG.md | 82 +++ .../vendor/ergebnis/version/LICENSE.md | 16 + .../vendor/ergebnis/version/README.md | 523 ++++++++++++++++++ .../vendor/ergebnis/version/composer.json | 82 +++ .../ergebnis/version/src/BuildMetaData.php | 56 ++ .../src/Exception/ExtensionMissing.php | 25 + .../src/Exception/InvalidBuildMetaData.php | 25 + .../version/src/Exception/InvalidMajor.php | 33 ++ .../version/src/Exception/InvalidMinor.php | 33 ++ .../version/src/Exception/InvalidPatch.php | 33 ++ .../src/Exception/InvalidPreRelease.php | 25 + .../version/src/Exception/InvalidVersion.php | 25 + .../vendor/ergebnis/version/src/Major.php | 99 ++++ .../vendor/ergebnis/version/src/Minor.php | 99 ++++ .../vendor/ergebnis/version/src/Patch.php | 99 ++++ .../ergebnis/version/src/PreRelease.php | 129 +++++ .../vendor/ergebnis/version/src/Version.php | 238 ++++++++ 78 files changed, 3872 insertions(+), 1266 deletions(-) create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSampleList.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ConfigurationKey.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Description.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidConfigurationKey.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidDescription.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidParameterName.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidRationale.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidTip.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterExample.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterList.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterName.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Rationale.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Reference.php create mode 100644 tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Tip.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/CHANGELOG.md create mode 100644 tools/.phpstan/vendor/ergebnis/version/LICENSE.md create mode 100644 tools/.phpstan/vendor/ergebnis/version/README.md create mode 100644 tools/.phpstan/vendor/ergebnis/version/composer.json create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/BuildMetaData.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/ExtensionMissing.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidBuildMetaData.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidMajor.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidMinor.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidPatch.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidPreRelease.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Exception/InvalidVersion.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Major.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Minor.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Patch.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/PreRelease.php create mode 100644 tools/.phpstan/vendor/ergebnis/version/src/Version.php diff --git a/tools/.phpstan/composer.json b/tools/.phpstan/composer.json index 4d1bcfaff..70aa7c94f 100644 --- a/tools/.phpstan/composer.json +++ b/tools/.phpstan/composer.json @@ -4,7 +4,7 @@ "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan-phpunit": "^2.1.1", "phpstan/phpstan-strict-rules": "^2.1.0", - "ergebnis/phpstan-rules": "^2.16.0" + "ergebnis/phpstan-rules": "^2.17.0" }, "config": { "allow-plugins": { diff --git a/tools/.phpstan/composer.lock b/tools/.phpstan/composer.lock index 9b0ba3f5d..827ce6363 100644 --- a/tools/.phpstan/composer.lock +++ b/tools/.phpstan/composer.lock @@ -4,25 +4,26 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c022e2ec548451eec8b00b57a3d053cb", + "content-hash": "4991035ce60bf654e38c70df46b98710", "packages": [], "packages-dev": [ { "name": "ergebnis/phpstan-rules", - "version": "2.16.0", + "version": "2.17.0", "source": { "type": "git", "url": "https://github.com/ergebnis/phpstan-rules.git", - "reference": "e123a05ffb337670f9f65fff3c3f25517d3d888e" + "reference": "5988e8fe66c09558c73824fce64123fdcd5afae2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/e123a05ffb337670f9f65fff3c3f25517d3d888e", - "reference": "e123a05ffb337670f9f65fff3c3f25517d3d888e", + "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/5988e8fe66c09558c73824fce64123fdcd5afae2", + "reference": "5988e8fe66c09558c73824fce64123fdcd5afae2", "shasum": "" }, "require": { "composer-runtime-api": "^2.0.0", + "ergebnis/version": "^1.4.0", "ext-mbstring": "*", "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "phpstan/phpstan": "^2.1.35" @@ -54,7 +55,7 @@ ] }, "branch-alias": { - "dev-main": "2.16-dev" + "dev-main": "2.17-dev" } }, "autoload": { @@ -84,7 +85,86 @@ "security": "https://github.com/ergebnis/phpstan-rules/blob/main/.github/SECURITY.md", "source": "https://github.com/ergebnis/phpstan-rules" }, - "time": "2026-10-28T23:53:24+00:00" + "time": "2026-10-29T11:16:56+00:00", + "published-time": "2026-10-29T11:18:22+00:00" + }, + { + "name": "ergebnis/version", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/version.git", + "reference": "cfdde08dac36650286acf310a8f99138201a484b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/version/zipball/cfdde08dac36650286acf310a8f99138201a484b", + "reference": "cfdde08dac36650286acf310a8f99138201a484b", + "shasum": "" + }, + "require": { + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.53.0", + "ergebnis/data-provider": "^3.6.0", + "ergebnis/license": "^2.7.0", + "ergebnis/php-cs-fixer-config": "^6.63.2", + "ergebnis/phpunit-slow-test-detector": "^2.25.0", + "ergebnis/rector-rules": "^1.18.3", + "ext-bcmath": "*", + "fakerphp/faker": "^1.24.1", + "infection/infection": "~0.26.6", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.2.14", + "phpstan/phpstan-deprecation-rules": "^2.0.5", + "phpstan/phpstan-phpunit": "^2.0.18", + "phpstan/phpstan-strict-rules": "^2.0.12", + "phpunit/phpunit": "^9.6.33", + "rector/rector": "^2.6.7" + }, + "suggest": { + "ext-bcmath": "If you want to bump Major, Minor, or Patch versions greater than PHP_MAX_INT." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.4-dev" + }, + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + }, + "autoload": { + "psr-4": { + "Ergebnis\\Version\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides an abstraction of a semantic version.", + "homepage": "https://github.com/ergebnis/version", + "keywords": [ + "semantic", + "version" + ], + "support": { + "issues": "https://github.com/ergebnis/version/issues", + "security": "https://github.com/ergebnis/version/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/version" + }, + "time": "2026-09-24T19:43:55+00:00", + "published-time": "2026-09-24T19:44:08+00:00" }, { "name": "phar-io/version", @@ -367,5 +447,5 @@ "prefer-lowest": false, "platform": {}, "platform-dev": {}, - "plugin-api-version": "2.9.0" + "plugin-api-version": "2.11.0" } diff --git a/tools/.phpstan/vendor/composer/installed.json b/tools/.phpstan/vendor/composer/installed.json index 035710922..6d1433df2 100644 --- a/tools/.phpstan/vendor/composer/installed.json +++ b/tools/.phpstan/vendor/composer/installed.json @@ -2,21 +2,22 @@ "packages": [ { "name": "ergebnis/phpstan-rules", - "version": "2.16.0", - "version_normalized": "2.16.0.0", + "version": "2.17.0", + "version_normalized": "2.17.0.0", "source": { "type": "git", "url": "https://github.com/ergebnis/phpstan-rules.git", - "reference": "e123a05ffb337670f9f65fff3c3f25517d3d888e" + "reference": "5988e8fe66c09558c73824fce64123fdcd5afae2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/e123a05ffb337670f9f65fff3c3f25517d3d888e", - "reference": "e123a05ffb337670f9f65fff3c3f25517d3d888e", + "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/5988e8fe66c09558c73824fce64123fdcd5afae2", + "reference": "5988e8fe66c09558c73824fce64123fdcd5afae2", "shasum": "" }, "require": { "composer-runtime-api": "^2.0.0", + "ergebnis/version": "^1.4.0", "ext-mbstring": "*", "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "phpstan/phpstan": "^2.1.35" @@ -40,7 +41,8 @@ "symfony/finder": "^5.4.45", "symfony/process": "^5.4.51" }, - "time": "2026-10-28T23:53:24+00:00", + "time": "2026-10-29T11:16:56+00:00", + "published-time": "2026-10-29T11:18:22+00:00", "type": "phpstan-extension", "extra": { "phpstan": { @@ -49,7 +51,7 @@ ] }, "branch-alias": { - "dev-main": "2.16-dev" + "dev-main": "2.17-dev" } }, "installation-source": "dist", @@ -82,6 +84,87 @@ }, "install-path": "../ergebnis/phpstan-rules" }, + { + "name": "ergebnis/version", + "version": "1.4.0", + "version_normalized": "1.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/ergebnis/version.git", + "reference": "cfdde08dac36650286acf310a8f99138201a484b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ergebnis/version/zipball/cfdde08dac36650286acf310a8f99138201a484b", + "reference": "cfdde08dac36650286acf310a8f99138201a484b", + "shasum": "" + }, + "require": { + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.53.0", + "ergebnis/data-provider": "^3.6.0", + "ergebnis/license": "^2.7.0", + "ergebnis/php-cs-fixer-config": "^6.63.2", + "ergebnis/phpunit-slow-test-detector": "^2.25.0", + "ergebnis/rector-rules": "^1.18.3", + "ext-bcmath": "*", + "fakerphp/faker": "^1.24.1", + "infection/infection": "~0.26.6", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.2.14", + "phpstan/phpstan-deprecation-rules": "^2.0.5", + "phpstan/phpstan-phpunit": "^2.0.18", + "phpstan/phpstan-strict-rules": "^2.0.12", + "phpunit/phpunit": "^9.6.33", + "rector/rector": "^2.6.7" + }, + "suggest": { + "ext-bcmath": "If you want to bump Major, Minor, or Patch versions greater than PHP_MAX_INT." + }, + "time": "2026-09-24T19:43:55+00:00", + "published-time": "2026-09-24T19:44:08+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.4-dev" + }, + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Ergebnis\\Version\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "description": "Provides an abstraction of a semantic version.", + "homepage": "https://github.com/ergebnis/version", + "keywords": [ + "semantic", + "version" + ], + "support": { + "issues": "https://github.com/ergebnis/version/issues", + "security": "https://github.com/ergebnis/version/blob/main/.github/SECURITY.md", + "source": "https://github.com/ergebnis/version" + }, + "install-path": "../ergebnis/version" + }, { "name": "phar-io/version", "version": "3.2.1", @@ -374,6 +457,7 @@ "dev": true, "dev-package-names": [ "ergebnis/phpstan-rules", + "ergebnis/version", "phar-io/version", "phpstan/extension-installer", "phpstan/phpstan", diff --git a/tools/.phpstan/vendor/composer/installed.php b/tools/.phpstan/vendor/composer/installed.php index aaa17ce84..6f5d8eeca 100644 --- a/tools/.phpstan/vendor/composer/installed.php +++ b/tools/.phpstan/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => 'dd46746634c26062387acf9f60b2e52947203633', + 'reference' => 'e44bd64c11f8eb239a4104f1a0ccab4ab2e285e4', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,21 +13,30 @@ '__root__' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => 'dd46746634c26062387acf9f60b2e52947203633', + 'reference' => 'e44bd64c11f8eb239a4104f1a0ccab4ab2e285e4', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'ergebnis/phpstan-rules' => array( - 'pretty_version' => '2.16.0', - 'version' => '2.16.0.0', - 'reference' => 'e123a05ffb337670f9f65fff3c3f25517d3d888e', + 'pretty_version' => '2.17.0', + 'version' => '2.17.0.0', + 'reference' => '5988e8fe66c09558c73824fce64123fdcd5afae2', 'type' => 'phpstan-extension', 'install_path' => __DIR__ . '/../ergebnis/phpstan-rules', 'aliases' => array(), 'dev_requirement' => true, ), + 'ergebnis/version' => array( + 'pretty_version' => '1.4.0', + 'version' => '1.4.0.0', + 'reference' => 'cfdde08dac36650286acf310a8f99138201a484b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ergebnis/version', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'phar-io/version' => array( 'pretty_version' => '3.2.1', 'version' => '3.2.1.0', diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/CHANGELOG.md b/tools/.phpstan/vendor/ergebnis/phpstan-rules/CHANGELOG.md index c32a0cfc9..6dbc96b66 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/CHANGELOG.md +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/CHANGELOG.md @@ -6,7 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased -For a full diff see [`2.16.0...main`][2.16.0...main]. +For a full diff see [`2.17.0...main`][2.17.0...main]. + +## [`2.17.0`][2.17.0] + +For a full diff see [`2.16.0...2.17.0`][2.16.0...2.17.0]. + +### Changed + +- Adjusted the rules to build their rule definitions once, when they are created, instead of once for every reported error ([#1164]), by [@localheinz] +- Extracted value objects for the configuration key, description, rationale, tip, parameters, and code samples of rule definitions ([#1165]), by [@localheinz] +- Extracted a value object for the reference used in links to the documentation of rules, falling back to `main` when no release is installed, which requires `ergebnis/version:^1.4.0` ([#1167]), by [@localheinz] +- Extracted a value object for the names of parameters of rule definitions ([#1168]), by [@localheinz] +- Extracted a value object for the examples of parameters of rule definitions ([#1169]), by [@localheinz] ## [`2.16.0`][2.16.0] @@ -730,7 +742,9 @@ For a full diff see [`362c7ea...0.1.0`][362c7ea...0.1.0]. [2.15.0]: https://github.com/ergebnis/phpstan-rules/releases/tag/2.15.0 [2.15.0...2.16.0]: https://github.com/ergebnis/phpstan-rules/compare/2.15.0...2.16.0 [2.16.0]: https://github.com/ergebnis/phpstan-rules/releases/tag/2.16.0 -[2.16.0...main]: https://github.com/ergebnis/phpstan-rules/compare/2.16.0...main +[2.16.0...2.17.0]: https://github.com/ergebnis/phpstan-rules/compare/2.16.0...2.17.0 +[2.17.0]: https://github.com/ergebnis/phpstan-rules/releases/tag/2.17.0 +[2.17.0...main]: https://github.com/ergebnis/phpstan-rules/compare/2.17.0...main [#1]: https://github.com/ergebnis/phpstan-rules/pull/1 [#4]: https://github.com/ergebnis/phpstan-rules/pull/4 @@ -849,6 +863,11 @@ For a full diff see [`362c7ea...0.1.0`][362c7ea...0.1.0]. [#1160]: https://github.com/ergebnis/phpstan-rules/pull/1160 [#1162]: https://github.com/ergebnis/phpstan-rules/pull/1162 [#1163]: https://github.com/ergebnis/phpstan-rules/pull/1163 +[#1164]: https://github.com/ergebnis/phpstan-rules/pull/1164 +[#1165]: https://github.com/ergebnis/phpstan-rules/pull/1165 +[#1167]: https://github.com/ergebnis/phpstan-rules/pull/1167 +[#1168]: https://github.com/ergebnis/phpstan-rules/pull/1168 +[#1169]: https://github.com/ergebnis/phpstan-rules/pull/1169 [@alfredbez]: https://github.com/alfredbez [@cosmastech]: https://github.com/cosmastech diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/composer.json b/tools/.phpstan/vendor/ergebnis/phpstan-rules/composer.json index 775fb9d7c..c6d47fe67 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/composer.json +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/composer.json @@ -24,6 +24,7 @@ "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0", "ext-mbstring": "*", "composer-runtime-api": "^2.0.0", + "ergebnis/version": "^1.4.0", "phpstan/phpstan": "^2.1.35" }, "require-dev": { @@ -72,7 +73,7 @@ }, "extra": { "branch-alias": { - "dev-main": "2.16-dev" + "dev-main": "2.17-dev" }, "phpstan": { "includes": [ diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoNullableReturnTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoNullableReturnTypeDeclarationRule.php index c0ef8e834..7c884504c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoNullableReturnTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoNullableReturnTypeDeclarationRule.php @@ -28,37 +28,42 @@ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noNullableReturnTypeDeclaration', - 'This rule reports an error when an arrow function uses a nullable return type declaration.', - 'A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the arrow function in two keeps the callers simpler.', - 'Throw an exception, return a null object, or split the arrow function in two instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noNullableReturnTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when an arrow function uses a nullable return type declaration.'), + Documentation\Rationale::fromString('A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the arrow function in two keeps the callers simpler.'), + Documentation\Tip::fromString('Throw an exception, return a null object, or split the arrow function in two instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + \strtoupper($value); - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - \strtoupper($value); + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + \strtoupper($value); - PHP), + $toUpperCase = static fn (string $value): string => \strtoupper($value); + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\ArrowFunction::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterPassedByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterPassedByReferenceRule.php index 5e33a20c2..1db594168 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterPassedByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterPassedByReferenceRule.php @@ -26,31 +26,40 @@ final class NoParameterPassedByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noParameterPassedByReference', - 'This rule reports an error when an arrow function has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).', - 'A parameter passed by reference lets an arrow function change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.', - 'Return the new value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - $value + 1; - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - $value + 1; - PHP), + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterPassedByReference'), + Documentation\Description::fromString('This rule reports an error when an arrow function has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).'), + Documentation\Rationale::fromString('A parameter passed by reference lets an arrow function change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.'), + Documentation\Tip::fromString('Return the new value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + $value + 1; + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + $value + 1; + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\ArrowFunction::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullDefaultValueRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullDefaultValueRule.php index 1f02ee996..cc01766de 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullDefaultValueRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullDefaultValueRule.php @@ -28,35 +28,40 @@ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullDefaultValue'), + Documentation\Description::fromString('This rule reports an error when an arrow function has a parameter with `null` as default value.'), + Documentation\Rationale::fromString('A parameter with `null` as its default value makes the argument optional and nullable at once, so the arrow function has to handle a missing value. Separate arrow functions or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate arrow functions or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + \strtoupper((string) $value); + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + \strtoupper($value); + PHP), + ), + ); } public function ruleDefinition(): Documentation\RuleDefinition { - return Documentation\RuleDefinition::create( - 'noParameterWithNullDefaultValue', - 'This rule reports an error when an arrow function has a parameter with `null` as default value.', - 'A parameter with `null` as its default value makes the argument optional and nullable at once, so the arrow function has to handle a missing value. Separate arrow functions or a null object make each case explicit.', - 'Use separate arrow functions or a null object instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - \strtoupper((string) $value); - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - \strtoupper($value); - PHP), - ); + return $this->ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullableTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullableTypeDeclarationRule.php index f9d96b56b..c2a29a789 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullableTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/ArrowFunctions/NoParameterWithNullableTypeDeclarationRule.php @@ -28,35 +28,40 @@ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullableTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when an arrow function has a parameter with a nullable type declaration.'), + Documentation\Rationale::fromString('A parameter with a nullable type declaration makes the arrow function handle two cases: a value and `null`. Separate arrow functions or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate arrow functions or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + \strtoupper((string) $value); + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + \strtoupper($value); + PHP), + ), + ); } public function ruleDefinition(): Documentation\RuleDefinition { - return Documentation\RuleDefinition::create( - 'noParameterWithNullableTypeDeclaration', - 'This rule reports an error when an arrow function has a parameter with a nullable type declaration.', - 'A parameter with a nullable type declaration makes the arrow function handle two cases: a value and `null`. Separate arrow functions or a null object make each case explicit.', - 'Use separate arrow functions or a null object instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - \strtoupper((string) $value); - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - \strtoupper($value); - PHP), - ); + return $this->ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php index 88738960b..97cb96712 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/CallLikes/NoNamedArgumentRule.php @@ -26,47 +26,56 @@ final class NoNamedArgumentRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noNamedArgument', - 'This rule reports an error when an anonymous function, a function, or a method is invoked using a [named argument](https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments).', - 'Named arguments make the names of parameters part of the public API, so renaming a parameter breaks callers. Positional arguments keep the names of parameters an implementation detail.', - 'Use positional arguments instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noNamedArgument'), + Documentation\Description::fromString('This rule reports an error when an anonymous function, a function, or a method is invoked using a [named argument](https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments).'), + Documentation\Rationale::fromString('Named arguments make the names of parameters part of the public API, so renaming a parameter breaks callers. Positional arguments keep the names of parameters an implementation detail.'), + Documentation\Tip::fromString('Use positional arguments instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\CallLike::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/FinalRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/FinalRule.php index dd01fe7ed..2b69bb0a0 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/FinalRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/FinalRule.php @@ -51,6 +51,7 @@ final class FinalRule implements */ private array $classesNotRequiredToBeAbstractOrFinal; private string $errorMessageTemplate = 'Class %s is not final.'; + private Documentation\RuleDefinition $ruleDefinition; /** * @param list $classesNotRequiredToBeAbstractOrFinal @@ -69,13 +70,10 @@ public function __construct( if ($allowAbstractClasses) { $this->errorMessageTemplate = 'Class %s is neither abstract nor final.'; } - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'final', - <<<'MARKDOWN' + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('final'), + Documentation\Description::fromString(<<<'MARKDOWN' This rule reports an error when a non-anonymous class is not `final`. 💡 By default, this rule ignores classes that @@ -84,61 +82,69 @@ public function ruleDefinition(): Documentation\RuleDefinition - use `Doctrine\ORM\Mapping\Entity` attributes on the class level. - MARKDOWN, - 'A class that is not `final` can be extended, so every change to it can break a subclass. Declare classes `final` and prefer composition over inheritance.', - 'Declare the class `final` and prefer composition over inheritance.', - Documentation\Parameter::create( - 'allowAbstractClasses', - <<<'MARKDOWN' - By default, this rule allows to declare `abstract` classes. - - You can set the `allowAbstractClasses` parameter to `false` to disallow abstract classes. - MARKDOWN, - false, - ), - Documentation\Parameter::create( - 'classesNotRequiredToBeAbstractOrFinal', - 'You can set the `classesNotRequiredToBeAbstractOrFinal` parameter to a list of class names that you want to exclude from inspection.', - [ - 'Foo\\Bar\\NeitherAbstractNorFinal', - 'Bar\\Baz\\NeitherAbstractNorFinal', - ], + MARKDOWN), + Documentation\Rationale::fromString('A class that is not `final` can be extended, so every change to it can break a subclass. Declare classes `final` and prefer composition over inheritance.'), + Documentation\Tip::fromString('Declare the class `final` and prefer composition over inheritance.'), + Documentation\ParameterList::create( + Documentation\Parameter::create( + Documentation\ParameterName::fromString('allowAbstractClasses'), + Documentation\Description::fromString(<<<'MARKDOWN' + By default, this rule allows to declare `abstract` classes. + + You can set the `allowAbstractClasses` parameter to `false` to disallow abstract classes. + MARKDOWN), + Documentation\ParameterExample::fromBool(false), + ), + Documentation\Parameter::create( + Documentation\ParameterName::fromString('classesNotRequiredToBeAbstractOrFinal'), + Documentation\Description::fromString('You can set the `classesNotRequiredToBeAbstractOrFinal` parameter to a list of class names that you want to exclude from inspection.'), + Documentation\ParameterExample::fromStrings( + 'Foo\\Bar\\NeitherAbstractNorFinal', + 'Bar\\Baz\\NeitherAbstractNorFinal', + ), + ), + Documentation\Parameter::create( + Documentation\ParameterName::fromString('ignoreDoctrineEntities'), + Documentation\Description::fromString(<<<'MARKDOWN' + By default, this rule ignores Doctrine entities, because Doctrine creates proxies for lazy loading by extending them. + + When you use [native lazy objects](https://github.com/doctrine/orm/pull/11853) with `doctrine/orm:^3.4.0` on PHP 8.4 or later, Doctrine no longer extends entities, and you can set the `ignoreDoctrineEntities` parameter to `false` to require Doctrine entities to be `final` as well. + MARKDOWN), + Documentation\ParameterExample::fromBool(false), + ), ), - Documentation\Parameter::create( - 'ignoreDoctrineEntities', - <<<'MARKDOWN' - By default, this rule ignores Doctrine entities, because Doctrine creates proxies for lazy loading by extending them. - - When you use [native lazy objects](https://github.com/doctrine/orm/pull/11853) with `doctrine/orm:^3.4.0` on PHP 8.4 or later, Doctrine no longer extends entities, and you can set the `ignoreDoctrineEntities` parameter to `false` to require Doctrine entities to be `final` as well. - MARKDOWN, - false, - ), - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Class_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/NoExtendsRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/NoExtendsRule.php index 3538be7a7..82d04fdbb 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/NoExtendsRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/NoExtendsRule.php @@ -38,6 +38,7 @@ final class NoExtendsRule implements * @var list */ private array $classesAllowedToBeExtended; + private Documentation\RuleDefinition $ruleDefinition; /** * @param list $classesAllowedToBeExtended @@ -51,63 +52,66 @@ public function __construct(array $classesAllowedToBeExtended) return $classAllowedToBeExtended; }, $classesAllowedToBeExtended), ))); - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noExtends', - 'This rule reports an error when a class extends another class.', - 'Extending a class couples the subclass to the implementation of its parent class. Prefer composition: inject collaborators and implement interfaces.', - 'Inject collaborators and implement interfaces instead.', - Documentation\Parameter::create( - 'classesAllowedToBeExtended', - <<<'MARKDOWN' + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noExtends'), + Documentation\Description::fromString('This rule reports an error when a class extends another class.'), + Documentation\Rationale::fromString('Extending a class couples the subclass to the implementation of its parent class. Prefer composition: inject collaborators and implement interfaces.'), + Documentation\Tip::fromString('Inject collaborators and implement interfaces instead.'), + Documentation\ParameterList::create(Documentation\Parameter::create( + Documentation\ParameterName::fromString('classesAllowedToBeExtended'), + Documentation\Description::fromString(<<<'MARKDOWN' By default, this rule allows the following classes to be extended: - [`PHPUnit\Framework\TestCase`](https://github.com/sebastianbergmann/phpunit/blob/6.0.0/src/Framework/TestCase.php) You can set the `classesAllowedToBeExtended` parameter to a list of class names that you want to allow to be extended. - MARKDOWN, - [ + MARKDOWN), + Documentation\ParameterExample::fromStrings( 'Ergebnis\\PHPStan\\Rules\\Test\\Integration\\AbstractTestCase', 'PHPStan\\Testing\\RuleTestCase', - ], - ), - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Class_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php index 993ec7449..1076ba897 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php @@ -34,49 +34,54 @@ final class TestCaseWithSuffixRule implements 'PHPUnit\Framework\TestCase', ]; private Reflection\ReflectionProvider $reflectionProvider; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Reflection\ReflectionProvider $reflectionProvider) { $this->reflectionProvider = $reflectionProvider; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'testCaseWithSuffix', - 'This rule reports an error when a concrete class is a sub-class of `PHPUnit\\Framework\\TestCase` but does not have a `Test` suffix.', - 'By default, PHPUnit only runs tests from files whose names end with `Test.php`, and the suffix tells readers which classes are tests.', - 'Add the `Test` suffix to the name of the class.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('testCaseWithSuffix'), + Documentation\Description::fromString('This rule reports an error when a concrete class is a sub-class of `PHPUnit\\Framework\\TestCase` but does not have a `Test` suffix.'), + Documentation\Rationale::fromString('By default, PHPUnit only runs tests from files whose names end with `Test.php`, and the suffix tells readers which classes are tests.'), + Documentation\Tip::fromString('Add the `Test` suffix to the name of the class.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Class_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoNullableReturnTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoNullableReturnTypeDeclarationRule.php index 3ef318c70..cfed29ad0 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoNullableReturnTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoNullableReturnTypeDeclarationRule.php @@ -28,41 +28,46 @@ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noNullableReturnTypeDeclaration', - 'This rule reports an error when a closure uses a nullable return type declaration.', - 'A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the closure in two keeps the callers simpler.', - 'Throw an exception, return a null object, or split the closure in two instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noNullableReturnTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a closure uses a nullable return type declaration.'), + Documentation\Rationale::fromString('A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the closure in two keeps the callers simpler.'), + Documentation\Tip::fromString('Throw an exception, return a null object, or split the closure in two instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\Closure::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterPassedByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterPassedByReferenceRule.php index 993edcff4..ec2744c2c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterPassedByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterPassedByReferenceRule.php @@ -26,35 +26,44 @@ final class NoParameterPassedByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noParameterPassedByReference', - 'This rule reports an error when a closure has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).', - 'A parameter passed by reference lets a closure change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.', - 'Return the new value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterPassedByReference'), + Documentation\Description::fromString('This rule reports an error when a closure has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).'), + Documentation\Rationale::fromString('A parameter passed by reference lets a closure change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.'), + Documentation\Tip::fromString('Return the new value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\Closure::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullDefaultValueRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullDefaultValueRule.php index 24b35131f..df3974b37 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullDefaultValueRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullDefaultValueRule.php @@ -28,39 +28,44 @@ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullDefaultValue'), + Documentation\Description::fromString('This rule reports an error when a closure has a parameter with `null` as default value.'), + Documentation\Rationale::fromString('A parameter with `null` as its default value makes the argument optional and nullable at once, so the closure has to handle a missing value. Separate closures or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate closures or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullableTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullableTypeDeclarationRule.php index 22f4ece52..d739df059 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullableTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Closures/NoParameterWithNullableTypeDeclarationRule.php @@ -28,39 +28,44 @@ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullableTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a closure has a parameter with a nullable type declaration.'), + Documentation\Rationale::fromString('A parameter with a nullable type declaration makes the closure handle two cases: a value and `null`. Separate closures or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate closures or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSample.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSample.php index 0f178ef75..ab8f1f48b 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSample.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSample.php @@ -29,9 +29,6 @@ private function __construct( $this->reported = $reported; } - /** - * Creates a code sample for which the rule reports an error. - */ public static function reported(string $code): self { return new self( @@ -40,9 +37,6 @@ public static function reported(string $code): self ); } - /** - * Creates a code sample for which the rule does not report an error. - */ public static function notReported(string $code): self { return new self( diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSampleList.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSampleList.php new file mode 100644 index 000000000..3a1c413f0 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/CodeSampleList.php @@ -0,0 +1,46 @@ + + */ + private array $codeSamples; + + /** + * @param list $codeSamples + */ + private function __construct(array $codeSamples) + { + $this->codeSamples = $codeSamples; + } + + public static function create(CodeSample ...$codeSamples): self + { + return new self(\array_values($codeSamples)); + } + + /** + * @return list + */ + public function toArray(): array + { + return $this->codeSamples; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ConfigurationKey.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ConfigurationKey.php new file mode 100644 index 000000000..28362e8a8 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ConfigurationKey.php @@ -0,0 +1,44 @@ +value = $value; + } + + /** + * @throws InvalidConfigurationKey + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match('/^[a-z][a-zA-Z0-9]*$/', $value)) { + throw InvalidConfigurationKey::notCamelCased($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Description.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Description.php new file mode 100644 index 000000000..4b9a44f36 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Description.php @@ -0,0 +1,48 @@ +value = $value; + } + + /** + * @throws InvalidDescription + */ + public static function fromString(string $value): self + { + if ('' === \trim($value)) { + throw InvalidDescription::blank(); + } + + if (\trim($value) !== $value) { + throw InvalidDescription::hasLeadingOrTrailingWhitespace($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ErrorTip.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ErrorTip.php index 6ed46c567..ed14e5e8c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ErrorTip.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ErrorTip.php @@ -13,29 +13,29 @@ namespace Ergebnis\PHPStan\Rules\Documentation; -use Composer\InstalledVersions; - /** * @internal */ final class ErrorTip { private const NAMESPACE_PREFIX = 'Ergebnis\\PHPStan\\Rules\\'; - private const PACKAGE_NAME = 'ergebnis/phpstan-rules'; - /** - * Returns the tip of the rule without Markdown backticks, followed by a link to the documentation of the rule for the installed version. - */ public static function for(HasRuleDefinition $rule): string { + return self::forReference( + $rule, + Reference::installed(), + ); + } + + public static function forReference( + HasRuleDefinition $rule, + Reference $reference + ): string { return \sprintf( '%s Learn more at https://github.com/ergebnis/phpstan-rules/blob/%s/doc/rules/%s.md', - \str_replace( - '`', - '', - $rule->ruleDefinition()->tip(), - ), - self::installedReference(), + $rule->ruleDefinition()->tip()->toPlainText(), + $reference->toString(), \str_replace( '\\', '/', @@ -46,34 +46,4 @@ public static function for(HasRuleDefinition $rule): string ), ); } - - /** - * Returns the tag of the installed release, or the commit of an installed development version, or main when neither is known. - */ - private static function installedReference(): string - { - if (!InstalledVersions::isInstalled(self::PACKAGE_NAME)) { - return 'main'; - } - - $version = InstalledVersions::getPrettyVersion(self::PACKAGE_NAME); - - if ( - \is_string($version) - && 1 === \preg_match('/^\d+\.\d+\.\d+$/', $version) - ) { - return $version; - } - - $reference = InstalledVersions::getReference(self::PACKAGE_NAME); - - if ( - \is_string($reference) - && '' !== $reference - ) { - return $reference; - } - - return 'main'; - } } diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidConfigurationKey.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidConfigurationKey.php new file mode 100644 index 000000000..53eacbb0d --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/InvalidConfigurationKey.php @@ -0,0 +1,28 @@ +>|list - */ - private $example; - - /** - * @param bool|list>|list $example - */ private function __construct( - string $name, - string $description, - $example + ParameterName $name, + Description $description, + ParameterExample $example ) { $this->name = $name; $this->description = $description; $this->example = $example; } - /** - * @param bool|list>|list $example - */ public static function create( - string $name, - string $description, - $example + ParameterName $name, + Description $description, + ParameterExample $example ): self { return new self( $name, @@ -54,25 +44,17 @@ public static function create( ); } - public function name(): string + public function name(): ParameterName { return $this->name; } - /** - * Returns a description of the parameter, in Markdown. - */ - public function description(): string + public function description(): Description { return $this->description; } - /** - * Returns an example value for the parameter. - * - * @return bool|list>|list - */ - public function example() + public function example(): ParameterExample { return $this->example; } diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterExample.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterExample.php new file mode 100644 index 000000000..e49900b43 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterExample.php @@ -0,0 +1,59 @@ +>|list + */ + private $value; + + /** + * @param bool|list>|list $value + */ + private function __construct($value) + { + $this->value = $value; + } + + public static function fromBool(bool $value): self + { + return new self($value); + } + + public static function fromStrings(string ...$values): self + { + return new self(\array_values($values)); + } + + /** + * @param array ...$maps + */ + public static function fromMaps(array ...$maps): self + { + return new self(\array_values($maps)); + } + + /** + * @return bool|list>|list + */ + public function toValue() + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterList.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterList.php new file mode 100644 index 000000000..175a833f8 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterList.php @@ -0,0 +1,46 @@ + + */ + private array $parameters; + + /** + * @param list $parameters + */ + private function __construct(array $parameters) + { + $this->parameters = $parameters; + } + + public static function create(Parameter ...$parameters): self + { + return new self(\array_values($parameters)); + } + + /** + * @return list + */ + public function toArray(): array + { + return $this->parameters; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterName.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterName.php new file mode 100644 index 000000000..25d1a7545 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/ParameterName.php @@ -0,0 +1,44 @@ +value = $value; + } + + /** + * @throws InvalidParameterName + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match('/^[a-z][a-zA-Z0-9]*$/', $value)) { + throw InvalidParameterName::notCamelCased($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Rationale.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Rationale.php new file mode 100644 index 000000000..570c43f07 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Rationale.php @@ -0,0 +1,48 @@ +value = $value; + } + + /** + * @throws InvalidRationale + */ + public static function fromString(string $value): self + { + if ('' === \trim($value)) { + throw InvalidRationale::blank(); + } + + if (\trim($value) !== $value) { + throw InvalidRationale::hasLeadingOrTrailingWhitespace($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Reference.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Reference.php new file mode 100644 index 000000000..ffb21f8b3 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Reference.php @@ -0,0 +1,68 @@ +value = $value; + } + + public static function fromPrettyVersion(string $prettyVersion): self + { + try { + $version = Version\Version::fromString($prettyVersion); + } catch (Version\Exception\InvalidVersion $exception) { + return new self('main'); + } + + return new self($version->toString()); + } + + public static function fromVersion(Version\Version $version): self + { + return new self($version->toString()); + } + + public static function main(): self + { + return new self('main'); + } + + public static function installed(): self + { + $prettyVersion = ''; + + if (InstalledVersions::isInstalled(self::PACKAGE_NAME)) { + $prettyVersion = (string) InstalledVersions::getPrettyVersion(self::PACKAGE_NAME); + } + + return self::fromPrettyVersion($prettyVersion); + } + + public function toString(): string + { + return $this->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/RuleDefinition.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/RuleDefinition.php index 712e26a12..2122c5f1c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/RuleDefinition.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/RuleDefinition.php @@ -18,32 +18,20 @@ */ final class RuleDefinition { - private string $configurationKey; - private string $description; - private string $rationale; - private string $tip; + private ConfigurationKey $configurationKey; + private Description $description; + private Rationale $rationale; + private Tip $tip; + private ParameterList $parameters; + private CodeSampleList $codeSamples; - /** - * @var list - */ - private array $parameters; - - /** - * @var list - */ - private array $codeSamples; - - /** - * @param list $parameters - * @param list $codeSamples - */ private function __construct( - string $configurationKey, - string $description, - string $rationale, - string $tip, - array $parameters, - array $codeSamples + ConfigurationKey $configurationKey, + Description $description, + Rationale $rationale, + Tip $tip, + ParameterList $parameters, + CodeSampleList $codeSamples ) { $this->configurationKey = $configurationKey; $this->description = $description; @@ -54,85 +42,49 @@ private function __construct( } public static function create( - string $configurationKey, - string $description, - string $rationale, - string $tip, - Parameter ...$parameters + ConfigurationKey $configurationKey, + Description $description, + Rationale $rationale, + Tip $tip, + ParameterList $parameters, + CodeSampleList $codeSamples ): self { return new self( $configurationKey, $description, $rationale, $tip, - \array_values($parameters), - [], - ); - } - - /** - * Returns a copy of the rule definition with the code samples. - */ - public function withCodeSamples(CodeSample ...$codeSamples): self - { - return new self( - $this->configurationKey, - $this->description, - $this->rationale, - $this->tip, - $this->parameters, - \array_values($codeSamples), + $parameters, + $codeSamples, ); } - /** - * Returns the key below parameters.ergebnis that holds the configuration of the rule. - */ - public function configurationKey(): string + public function configurationKey(): ConfigurationKey { return $this->configurationKey; } - /** - * Returns a description of the rule, in Markdown. - */ - public function description(): string + public function description(): Description { return $this->description; } - /** - * Returns the reason for the rule, in Markdown. - */ - public function rationale(): string + public function rationale(): Rationale { return $this->rationale; } - /** - * Returns a short instruction for fixing errors reported by the rule, in Markdown that uses only backticks, so that it can also be shown as a tip for these errors. - */ - public function tip(): string + public function tip(): Tip { return $this->tip; } - /** - * Returns the parameters for configuring the rule, other than the enabled parameter that every rule has. - * - * @return list - */ - public function parameters(): array + public function parameters(): ParameterList { return $this->parameters; } - /** - * Returns code samples for which the rule reports or does not report an error. - * - * @return list - */ - public function codeSamples(): array + public function codeSamples(): CodeSampleList { return $this->codeSamples; } diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Tip.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Tip.php new file mode 100644 index 000000000..5042a3fbf --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Documentation/Tip.php @@ -0,0 +1,71 @@ +value = $value; + } + + /** + * @throws InvalidTip + */ + public static function fromString(string $value): self + { + if ('' === \trim($value)) { + throw InvalidTip::blank(); + } + + if (\trim($value) !== $value) { + throw InvalidTip::hasLeadingOrTrailingWhitespace($value); + } + + if (1 === \preg_match('/[\r\n]/', $value)) { + throw InvalidTip::spansMultipleLines($value); + } + + $valueWithoutInlineCode = \preg_replace( + '/`[^`]+`/', + '', + $value, + ); + + if (1 === \preg_match('/[`*_\[\]<>#~|\\\\]/', (string) $valueWithoutInlineCode)) { + throw InvalidTip::usesMarkdownOtherThanInlineCode($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } + + public function toPlainText(): string + { + return \str_replace( + '`', + '', + $this->value, + ); + } +} diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoAssignByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoAssignByReferenceRule.php index ddf5e574b..73caa504c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoAssignByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoAssignByReferenceRule.php @@ -26,39 +26,48 @@ final class NoAssignByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noAssignByReference', - 'This rule reports an error when [a variable is assigned by reference](https://www.php.net/manual/en/language.references.whatdo.php#language.references.whatdo.assign).', - 'Assigning by reference makes two variables share one value, so changing one changes the other, which makes the code harder to follow.', - 'Assign the value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noAssignByReference'), + Documentation\Description::fromString('This rule reports an error when [a variable is assigned by reference](https://www.php.net/manual/en/language.references.whatdo.php#language.references.whatdo.assign).'), + Documentation\Rationale::fromString('Assigning by reference makes two variables share one value, so changing one changes the other, which makes the code harder to follow.'), + Documentation\Tip::fromString('Assign the value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\AssignRef::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoCompactRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoCompactRule.php index 1b7e95d36..5fab5a21c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoCompactRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoCompactRule.php @@ -26,37 +26,46 @@ final class NoCompactRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noCompact', - 'This rule reports an error when the function [`compact()`](https://www.php.net/compact) is used.', - 'The function `compact()` refers to variables by their names in strings, which static analysis and automated refactoring cannot follow. Build the array explicitly instead.', - 'Build the array explicitly instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noCompact'), + Documentation\Description::fromString('This rule reports an error when the function [`compact()`](https://www.php.net/compact) is used.'), + Documentation\Rationale::fromString('The function `compact()` refers to variables by their names in strings, which static analysis and automated refactoring cannot follow. Build the array explicitly instead.'), + Documentation\Tip::fromString('Build the array explicitly instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + $name, - ]; - PHP), + $context = [ + 'name' => $name, + ]; + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\FuncCall::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoErrorSuppressionRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoErrorSuppressionRule.php index d89468408..634f9fbef 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoErrorSuppressionRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoErrorSuppressionRule.php @@ -26,35 +26,44 @@ final class NoErrorSuppressionRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noErrorSuppression', - 'This rule reports an error when [`@`](https://www.php.net/manual/en/language.operators.errorcontrol.php) is used to suppress errors.', - 'The error control operator hides every error that the expression causes, including errors you did not expect. Check for the error condition explicitly instead.', - 'Check for the error condition explicitly instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noErrorSuppression'), + Documentation\Description::fromString('This rule reports an error when [`@`](https://www.php.net/manual/en/language.operators.errorcontrol.php) is used to suppress errors.'), + Documentation\Rationale::fromString('The error control operator hides every error that the expression causes, including errors you did not expect. Check for the error condition explicitly instead.'), + Documentation\Tip::fromString('Check for the error condition explicitly instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\ErrorSuppress::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoEvalRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoEvalRule.php index 0a12a7ebf..9c7f8b0b8 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoEvalRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoEvalRule.php @@ -26,31 +26,40 @@ final class NoEvalRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noEval', - 'This rule reports an error when the language construct [`eval()`](https://www.php.net/eval) is used.', - 'The language construct `eval()` executes a string as code, which is a security risk and cannot be analyzed statically.', - 'Write the code directly instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noEval'), + Documentation\Description::fromString('This rule reports an error when the language construct [`eval()`](https://www.php.net/eval) is used.'), + Documentation\Rationale::fromString('The language construct `eval()` executes a string as code, which is a security risk and cannot be analyzed statically.'), + Documentation\Tip::fromString('Write the code directly instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\Eval_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoIssetRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoIssetRule.php index a7a875fd6..d2215331c 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoIssetRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Expressions/NoIssetRule.php @@ -26,43 +26,52 @@ final class NoIssetRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noIsset', - 'This rule reports an error when the language construct [`isset()`](https://www.php.net/isset) is used.', - 'The language construct `isset()` returns `false` both when a variable, array key, or property does not exist and when it holds `null`, so it hides which of the two applies. Use `array_key_exists()`, `property_exists()`, or a comparison with `null` instead.', - 'Use `array_key_exists()`, `property_exists()`, or a comparison with `null` instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noIsset'), + Documentation\Description::fromString('This rule reports an error when the language construct [`isset()`](https://www.php.net/isset) is used.'), + Documentation\Rationale::fromString('The language construct `isset()` returns `false` both when a variable, array key, or property does not exist and when it holds `null`, so it hides which of the two applies. Use `array_key_exists()`, `property_exists()`, or a comparison with `null` instead.'), + Documentation\Tip::fromString('Use `array_key_exists()`, `property_exists()`, or a comparison with `null` instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + 'Jane', - ]; + $values = [ + 'name' => 'Jane', + ]; - if (isset($values['name'])) { - echo $values['name']; - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - 'Jane', - ]; + $values = [ + 'name' => 'Jane', + ]; - if (\array_key_exists('name', $values)) { - echo $values['name']; - } - PHP), + if (\array_key_exists('name', $values)) { + echo $values['name']; + } + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Expr\Isset_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/DeclareStrictTypesRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/DeclareStrictTypesRule.php index dc3a09a23..5dc81a2de 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/DeclareStrictTypesRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/DeclareStrictTypesRule.php @@ -27,29 +27,38 @@ final class DeclareStrictTypesRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'declareStrictTypes', - 'This rule reports an error when a non-empty file does not contain a `declare(strict_types=1)` declaration.', - 'Without a `declare(strict_types=1)` declaration, PHP coerces scalar arguments and return values to the declared types, which hides type errors.', - 'Add a `declare(strict_types=1)` declaration at the top of the file.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('declareStrictTypes'), + Documentation\Description::fromString('This rule reports an error when a non-empty file does not contain a `declare(strict_types=1)` declaration.'), + Documentation\Rationale::fromString('Without a `declare(strict_types=1)` declaration, PHP coerces scalar arguments and return values to the declared types, which hides type errors.'), + Documentation\Tip::fromString('Add a `declare(strict_types=1)` declaration at the top of the file.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return FileNode::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/NoPhpstanIgnoreRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/NoPhpstanIgnoreRule.php index 899ab3a21..115910f09 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/NoPhpstanIgnoreRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Files/NoPhpstanIgnoreRule.php @@ -28,34 +28,43 @@ final class NoPhpstanIgnoreRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noPhpstanIgnore', - 'This rule reports an error when a `@phpstan-ignore`, `@phpstan-ignore-line`, or `@phpstan-ignore-next-line` tag is used to [ignore errors reported by `phpstan/phpstan`](https://phpstan.org/user-guide/ignoring-errors#ignoring-in-code-using-phpdocs).', - 'An ignore tag hides an error where it occurs and tends to stay after the reason for it is gone. Fix the error, or ignore it in the configuration or the baseline, where it stays visible.', - 'Fix the error, or ignore it in the configuration or the baseline instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noPhpstanIgnore'), + Documentation\Description::fromString('This rule reports an error when a `@phpstan-ignore`, `@phpstan-ignore-line`, or `@phpstan-ignore-next-line` tag is used to [ignore errors reported by `phpstan/phpstan`](https://phpstan.org/user-guide/ignoring-errors#ignoring-in-code-using-phpdocs).'), + Documentation\Rationale::fromString('An ignore tag hides an error where it occurs and tends to stay after the reason for it is gone. Fix the error, or ignore it in the configuration or the baseline, where it stays visible.'), + Documentation\Tip::fromString('Fix the error, or ignore it in the configuration or the baseline instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return FileNode::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoNullableReturnTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoNullableReturnTypeDeclarationRule.php index a9feae7e5..229339b42 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoNullableReturnTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoNullableReturnTypeDeclarationRule.php @@ -28,41 +28,46 @@ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noNullableReturnTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a function uses a nullable return type declaration.'), + Documentation\Rationale::fromString('A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the function in two keeps the callers simpler.'), + Documentation\Tip::fromString('Throw an exception, return a null object, or split the function in two instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterPassedByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterPassedByReferenceRule.php index 73efb9e69..b52b3f622 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterPassedByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterPassedByReferenceRule.php @@ -26,37 +26,46 @@ final class NoParameterPassedByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noParameterPassedByReference', - 'This rule reports an error when a function has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).', - 'A parameter passed by reference lets a function change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.', - 'Return the new value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterPassedByReference'), + Documentation\Description::fromString('This rule reports an error when a function has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).'), + Documentation\Rationale::fromString('A parameter passed by reference lets a function change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.'), + Documentation\Tip::fromString('Return the new value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Function_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullDefaultValueRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullDefaultValueRule.php index fe0c70199..5b78892ae 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullDefaultValueRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullDefaultValueRule.php @@ -28,41 +28,46 @@ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullDefaultValue'), + Documentation\Description::fromString('This rule reports an error when a function has a parameter with `null` as default value.'), + Documentation\Rationale::fromString('A parameter with `null` as its default value makes the argument optional and nullable at once, so the function has to handle a missing value. Separate functions or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate functions or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullableTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullableTypeDeclarationRule.php index ff31e5a10..834d0da95 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullableTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoParameterWithNullableTypeDeclarationRule.php @@ -28,41 +28,46 @@ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; + + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullableTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a function has a parameter with a nullable type declaration.'), + Documentation\Rationale::fromString('A parameter with a nullable type declaration makes the function handle two cases: a value and `null`. Separate functions or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate functions or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; } public function getNodeType(): string diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoReturnByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoReturnByReferenceRule.php index 02051de7c..686a73863 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoReturnByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Functions/NoReturnByReferenceRule.php @@ -26,39 +26,48 @@ final class NoReturnByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noReturnByReference', - 'This rule reports an error when a function [returns by reference](https://www.php.net/manual/en/language.references.return.php).', - 'Returning by reference lets the caller change state that the function keeps, which makes the code harder to follow. Return a value instead.', - 'Return a value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noReturnByReference'), + Documentation\Description::fromString('This rule reports an error when a function [returns by reference](https://www.php.net/manual/en/language.references.return.php).'), + Documentation\Rationale::fromString('Returning by reference lets the caller change state that the function keeps, which makes the code harder to follow. Return a value instead.'), + Documentation\Tip::fromString('Return a value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Function_::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/FinalInAbstractClassRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/FinalInAbstractClassRule.php index d712c7faa..857dc05fe 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/FinalInAbstractClassRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/FinalInAbstractClassRule.php @@ -39,66 +39,70 @@ final class FinalInAbstractClassRule implements '@Entity', ]; private bool $ignoreDoctrineEntities; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(bool $ignoreDoctrineEntities) { $this->ignoreDoctrineEntities = $ignoreDoctrineEntities; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'finalInAbstractClass', - <<<'MARKDOWN' + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('finalInAbstractClass'), + Documentation\Description::fromString(<<<'MARKDOWN' This rule reports an error when a concrete `public` or `protected` method in an `abstract` class is not `final`. 💡 By default, this rule ignores Doctrine entities. - MARKDOWN, - 'A concrete method in an `abstract` class that is not `final` can be overridden by subclasses, which can break the assumptions of the abstract class. Declare the method `final`, or `abstract` when subclasses need to provide it.', - 'Declare the method `final`, or `abstract` when subclasses need to provide it.', - Documentation\Parameter::create( - 'ignoreDoctrineEntities', - <<<'MARKDOWN' + MARKDOWN), + Documentation\Rationale::fromString('A concrete method in an `abstract` class that is not `final` can be overridden by subclasses, which can break the assumptions of the abstract class. Declare the method `final`, or `abstract` when subclasses need to provide it.'), + Documentation\Tip::fromString('Declare the method `final`, or `abstract` when subclasses need to provide it.'), + Documentation\ParameterList::create(Documentation\Parameter::create( + Documentation\ParameterName::fromString('ignoreDoctrineEntities'), + Documentation\Description::fromString(<<<'MARKDOWN' By default, this rule ignores Doctrine entities, because Doctrine creates proxies for lazy loading by extending them. When you use [native lazy objects](https://github.com/doctrine/orm/pull/11853) with `doctrine/orm:^3.4.0` on PHP 8.4 or later, Doctrine no longer extends entities, and you can set the `ignoreDoctrineEntities` parameter to `false` to require concrete methods in `abstract` Doctrine entities to be `final` as well. - MARKDOWN, - false, - ), - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/InvokeParentHookMethodRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/InvokeParentHookMethodRule.php index 40346e193..ed818a22a 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/InvokeParentHookMethodRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/InvokeParentHookMethodRule.php @@ -42,6 +42,7 @@ final class InvokeParentHookMethodRule implements * @var list */ private array $hookMethods; + private Documentation\RuleDefinition $ruleDefinition; /** * @param array> $hookMethods @@ -68,18 +69,15 @@ public function __construct( ), ), ); - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'invokeParentHookMethod', - 'This rule reports an error when a hook method that overrides a hook method in a parent class does not invoke the overridden hook method in the expected order.', - 'A hook method such as `setUp()` that overrides a hook method of a parent class needs to invoke the parent hook method in the expected order, or the parent class does not set up or tear down as intended.', - 'Move the invocation of the parent hook method to the expected position.', - Documentation\Parameter::create( - 'hookMethods', - <<<'MARKDOWN' + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('invokeParentHookMethod'), + Documentation\Description::fromString('This rule reports an error when a hook method that overrides a hook method in a parent class does not invoke the overridden hook method in the expected order.'), + Documentation\Rationale::fromString('A hook method such as `setUp()` that overrides a hook method of a parent class needs to invoke the parent hook method in the expected order, or the parent class does not set up or tear down as intended.'), + Documentation\Tip::fromString('Move the invocation of the parent hook method to the expected position.'), + Documentation\ParameterList::create(Documentation\Parameter::create( + Documentation\ParameterName::fromString('hookMethods'), + Documentation\Description::fromString(<<<'MARKDOWN' By default, this rule requires the following hook methods to be invoked before doing something in the overriding method: - [`Codeception\PHPUnit\TestCase::_setUp()`](https://github.com/Codeception/phpunit-wrapper/blob/9.0.0/src/TestCase.php#L11-L13) @@ -106,58 +104,62 @@ public function ruleDefinition(): Documentation\RuleDefinition - `hasContent`: one of `"yes"`, `"no"` - `invocation`: one of `"any"` (needs to be invoked), `"first"` (needs to be invoked before all other statements in the overriding hook method), `"last"` (needs to be invoked after all other statements in the overriding hook method) - `methodName`: name of the hook method - MARKDOWN, - [ - [ - 'className' => 'Example\\Test\\Functional\\AbstractCest', - 'hasContent' => 'yes', - 'invocation' => 'first', - 'methodName' => '_before', - ], - ], - ), - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - 'Example\\Test\\Functional\\AbstractCest', + 'hasContent' => 'yes', + 'invocation' => 'first', + 'methodName' => '_before', + ]), + )), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoConstructorParameterWithDefaultValueRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoConstructorParameterWithDefaultValueRule.php index bf307f12e..dba1124ab 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoConstructorParameterWithDefaultValueRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoConstructorParameterWithDefaultValueRule.php @@ -27,51 +27,60 @@ final class NoConstructorParameterWithDefaultValueRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noConstructorParameterWithDefaultValue', - 'This rule reports an error when a constructor has a parameter with a default value.', - 'A constructor parameter with a default value lets callers create an object without deciding on that value. Named constructors make each way of creating the object explicit.', - 'Remove the default value and add a named constructor for each way of creating the object.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noConstructorParameterWithDefaultValue'), + Documentation\Description::fromString('This rule reports an error when a constructor has a parameter with a default value.'), + Documentation\Rationale::fromString('A constructor parameter with a default value lets callers create an object without deciding on that value. Named constructors make each way of creating the object explicit.'), + Documentation\Tip::fromString('Remove the default value and add a named constructor for each way of creating the object.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + salutation = $salutation; - } - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - salutation = $salutation; + } + } + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + salutation = $salutation; + private string $salutation; + + public function __construct(string $salutation) + { + $this->salutation = $salutation; + } } - } - PHP), + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoNullableReturnTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoNullableReturnTypeDeclarationRule.php index 3f33ef028..96b1b297d 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoNullableReturnTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoNullableReturnTypeDeclarationRule.php @@ -29,59 +29,64 @@ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noNullableReturnTypeDeclaration', - 'This rule reports an error when a method uses a nullable return type declaration.', - 'A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the method in two keeps the callers simpler.', - 'Throw an exception, return a null object, or split the method in two instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noNullableReturnTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a method uses a nullable return type declaration.'), + Documentation\Rationale::fromString('A nullable return type forces every caller to handle `null`. Throwing an exception, returning a null object, or splitting the method in two keeps the callers simpler.'), + Documentation\Tip::fromString('Throw an exception, return a null object, or split the method in two instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterPassedByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterPassedByReferenceRule.php index bbddacdb8..fe02cebf5 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterPassedByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterPassedByReferenceRule.php @@ -27,47 +27,56 @@ final class NoParameterPassedByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noParameterPassedByReference', - 'This rule reports an error when a method has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).', - 'A parameter passed by reference lets a method change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.', - 'Return the new value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterPassedByReference'), + Documentation\Description::fromString('This rule reports an error when a method has a parameter that is [passed by reference](https://www.php.net/manual/en/language.references.pass.php).'), + Documentation\Rationale::fromString('A parameter passed by reference lets a method change a variable of its caller as a side effect, which makes the code harder to follow. Return the new value instead.'), + Documentation\Tip::fromString('Return the new value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithContainerTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithContainerTypeDeclarationRule.php index 76862191b..b57e6f5cf 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithContainerTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithContainerTypeDeclarationRule.php @@ -38,6 +38,7 @@ final class NoParameterWithContainerTypeDeclarationRule implements * @var list */ private array $methodsAllowedToUseContainerTypeDeclarations; + private Documentation\RuleDefinition $ruleDefinition; /** * @param list $interfacesImplementedByContainers @@ -58,82 +59,85 @@ static function (string $interfaceImplementedByContainer): bool { }, )); $this->methodsAllowedToUseContainerTypeDeclarations = $methodsAllowedToUseContainerTypeDeclarations; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noParameterWithContainerTypeDeclaration', - 'This rule reports an error when a method has a type declaration for a known dependency injection container or service locator.', - 'A method that receives a dependency injection container or service locator hides its actual dependencies. Inject the dependencies directly instead.', - 'Inject the dependencies directly instead.', - Documentation\Parameter::create( - 'interfacesImplementedByContainers', - <<<'MARKDOWN' - By default, this rule disallows the use of type declarations indicating an implementation of - - - [`Psr\Container\ContainerInterface`](https://github.com/php-fig/container/blob/1.0.0/src/ContainerInterface.php) - - is expected to be injected into a method. - - You can set the `interfacesImplementedByContainers` parameter to a list of interface names of additional containers and service locators. - MARKDOWN, - [ - 'Fancy\\DependencyInjection\\ContainerInterface', - 'Other\\ServiceLocatorInterface', - ], - ), - Documentation\Parameter::create( - 'methodsAllowedToUseContainerTypeDeclarations', - 'You can set the `methodsAllowedToUseContainerTypeDeclarations` parameter to a list of method names that are allowed to use parameters with container type declarations.', - [ - 'loadExtension', - ], + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithContainerTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a method has a type declaration for a known dependency injection container or service locator.'), + Documentation\Rationale::fromString('A method that receives a dependency injection container or service locator hides its actual dependencies. Inject the dependencies directly instead.'), + Documentation\Tip::fromString('Inject the dependencies directly instead.'), + Documentation\ParameterList::create( + Documentation\Parameter::create( + Documentation\ParameterName::fromString('interfacesImplementedByContainers'), + Documentation\Description::fromString(<<<'MARKDOWN' + By default, this rule disallows the use of type declarations indicating an implementation of + + - [`Psr\Container\ContainerInterface`](https://github.com/php-fig/container/blob/1.0.0/src/ContainerInterface.php) + + is expected to be injected into a method. + + You can set the `interfacesImplementedByContainers` parameter to a list of interface names of additional containers and service locators. + MARKDOWN), + Documentation\ParameterExample::fromStrings( + 'Fancy\\DependencyInjection\\ContainerInterface', + 'Other\\ServiceLocatorInterface', + ), + ), + Documentation\Parameter::create( + Documentation\ParameterName::fromString('methodsAllowedToUseContainerTypeDeclarations'), + Documentation\Description::fromString('You can set the `methodsAllowedToUseContainerTypeDeclarations` parameter to a list of method names that are allowed to use parameters with container type declarations.'), + Documentation\ParameterExample::fromStrings('loadExtension'), + ), ), - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - get('salutation'); + public function greet(Container\ContainerInterface $container): string + { + return $container->get('salutation'); + } } - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - toString(); + public function greet(Salutation $salutation): string + { + return $salutation->toString(); + } } - } - PHP), + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullDefaultValueRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullDefaultValueRule.php index fdffbf089..a2fc9948e 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullDefaultValueRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullDefaultValueRule.php @@ -29,59 +29,64 @@ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noParameterWithNullDefaultValue', - 'This rule reports an error when a method has a parameter with `null` as default value.', - 'A parameter with `null` as its default value makes the argument optional and nullable at once, so the method has to handle a missing value. Separate methods or a null object make each case explicit.', - 'Use separate methods or a null object instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullDefaultValue'), + Documentation\Description::fromString('This rule reports an error when a method has a parameter with `null` as default value.'), + Documentation\Rationale::fromString('A parameter with `null` as its default value makes the argument optional and nullable at once, so the method has to handle a missing value. Separate methods or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate methods or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullableTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullableTypeDeclarationRule.php index ef2756249..dd8c46432 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullableTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoParameterWithNullableTypeDeclarationRule.php @@ -29,59 +29,64 @@ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noParameterWithNullableTypeDeclaration', - 'This rule reports an error when a method has a parameter with a nullable type declaration.', - 'A parameter with a nullable type declaration makes the method handle two cases: a value and `null`. Separate methods or a null object make each case explicit.', - 'Use separate methods or a null object instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullableTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a method has a parameter with a nullable type declaration.'), + Documentation\Rationale::fromString('A parameter with a nullable type declaration makes the method handle two cases: a value and `null`. Separate methods or a null object make each case explicit.'), + Documentation\Tip::fromString('Use separate methods or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoReturnByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoReturnByReferenceRule.php index 067f94871..5b08106d4 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoReturnByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/NoReturnByReferenceRule.php @@ -27,51 +27,60 @@ final class NoReturnByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noReturnByReference', - 'This rule reports an error when a method [returns by reference](https://www.php.net/manual/en/language.references.return.php).', - 'Returning by reference lets the caller change state that the method keeps, which makes the code harder to follow. Return a value instead.', - 'Return a value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noReturnByReference'), + Documentation\Description::fromString('This rule reports an error when a method [returns by reference](https://www.php.net/manual/en/language.references.return.php).'), + Documentation\Rationale::fromString('Returning by reference lets the caller change state that the method keeps, which makes the code harder to follow. Return a value instead.'), + Documentation\Tip::fromString('Return a value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + values; - } - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - values; + } + } + PHP), + Documentation\CodeSample::notReported(<<<'PHP' + values; + private array $values = []; + + public function values(): array + { + return $this->values; + } } - } - PHP), + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/PrivateInFinalClassRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/PrivateInFinalClassRule.php index 7e324443d..2e3940727 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/PrivateInFinalClassRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Methods/PrivateInFinalClassRule.php @@ -50,53 +50,58 @@ final class PrivateInFinalClassRule implements Framework\Attributes\PreCondition::class, ]; private Type\FileTypeMapper $fileTypeMapper; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Type\FileTypeMapper $fileTypeMapper) { $this->fileTypeMapper = $fileTypeMapper; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'privateInFinalClass', - 'This rule reports an error when a method in a `final` class is `protected` but could be `private`.', - 'A `final` class cannot be extended, so a `protected` method in it can only be used like a `private` method. Declaring the method `private` makes that explicit.', - 'Declare the method `private` instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('privateInFinalClass'), + Documentation\Description::fromString('This rule reports an error when a method in a `final` class is `protected` but could be `private`.'), + Documentation\Rationale::fromString('A `final` class cannot be extended, so a `protected` method in it can only be used like a `private` method. Declaring the method `private` makes that explicit.'), + Documentation\Tip::fromString('Declare the method `private` instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoParameterWithNullableTypeDeclarationRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoParameterWithNullableTypeDeclarationRule.php index 947dac379..0c7f95267 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoParameterWithNullableTypeDeclarationRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoParameterWithNullableTypeDeclarationRule.php @@ -29,55 +29,60 @@ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { private Analyzer $analyzer; + private Documentation\RuleDefinition $ruleDefinition; public function __construct(Analyzer $analyzer) { $this->analyzer = $analyzer; - } - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noParameterWithNullableTypeDeclaration', - 'This rule reports an error when a [property hook](https://www.php.net/manual/en/language.oop5.property-hooks.php) has a parameter with a nullable type declaration.', - 'A parameter with a nullable type declaration makes the property hook handle two cases: a value and `null`. Separate properties or a null object make each case explicit.', - 'Use a separate property or a null object instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - salutation = (string) $value; + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noParameterWithNullableTypeDeclaration'), + Documentation\Description::fromString('This rule reports an error when a [property hook](https://www.php.net/manual/en/language.oop5.property-hooks.php) has a parameter with a nullable type declaration.'), + Documentation\Rationale::fromString('A parameter with a nullable type declaration makes the property hook handle two cases: a value and `null`. Separate properties or a null object make each case explicit.'), + Documentation\Tip::fromString('Use a separate property or a null object instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + salutation = (string) $value; + } } } - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - salutation = $value; + final class Greeting + { + public string $salutation = 'Hello' { + set(string $value) { + $this->salutation = $value; + } } } - } - PHP), + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return ClassPropertyNode::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoReturnByReferenceRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoReturnByReferenceRule.php index 4b76350a4..b8fbb1704 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoReturnByReferenceRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/PropertyHooks/NoReturnByReferenceRule.php @@ -27,49 +27,58 @@ final class NoReturnByReferenceRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition - { - return Documentation\RuleDefinition::create( - 'noReturnByReference', - 'This rule reports an error when a [property hook](https://www.php.net/manual/en/language.oop5.property-hooks.php) returns by reference.', - 'Returning by reference lets the caller change state that the property hook keeps, which makes the code harder to follow. Return a value instead.', - 'Return a value instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - $this->values; + public function __construct() + { + $this->ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noReturnByReference'), + Documentation\Description::fromString('This rule reports an error when a [property hook](https://www.php.net/manual/en/language.oop5.property-hooks.php) returns by reference.'), + Documentation\Rationale::fromString('Returning by reference lets the caller change state that the property hook keeps, which makes the code harder to follow. Return a value instead.'), + Documentation\Tip::fromString('Return a value instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + $this->values; + } } - } - PHP), - Documentation\CodeSample::notReported(<<<'PHP' - $this->values; + public array $salutations { + get => $this->values; + } } - } - PHP), + PHP), + ), ); } + public function ruleDefinition(): Documentation\RuleDefinition + { + return $this->ruleDefinition; + } + public function getNodeType(): string { return ClassPropertyNode::class; diff --git a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Statements/NoSwitchRule.php b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Statements/NoSwitchRule.php index 127876e73..89e4becf8 100644 --- a/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Statements/NoSwitchRule.php +++ b/tools/.phpstan/vendor/ergebnis/phpstan-rules/src/Statements/NoSwitchRule.php @@ -26,47 +26,56 @@ final class NoSwitchRule implements Documentation\HasRuleDefinition, Rules\Rule { - public function ruleDefinition(): Documentation\RuleDefinition + private Documentation\RuleDefinition $ruleDefinition; + + public function __construct() { - return Documentation\RuleDefinition::create( - 'noSwitch', - 'This rule reports an error when the statement [`switch()`](https://www.php.net/manual/control-structures.switch.php) is used.', - 'A `switch` statement compares loosely and falls through to the next case without `break`, which can cause subtle bugs. Use `if` statements or `match` instead.', - 'Use `if` statements or `match` instead.', - )->withCodeSamples( - Documentation\CodeSample::reported(<<<'PHP' - ruleDefinition = Documentation\RuleDefinition::create( + Documentation\ConfigurationKey::fromString('noSwitch'), + Documentation\Description::fromString('This rule reports an error when the statement [`switch()`](https://www.php.net/manual/control-structures.switch.php) is used.'), + Documentation\Rationale::fromString('A `switch` statement compares loosely and falls through to the next case without `break`, which can cause subtle bugs. Use `if` statements or `match` instead.'), + Documentation\Tip::fromString('Use `if` statements or `match` instead.'), + Documentation\ParameterList::create(), + Documentation\CodeSampleList::create( + Documentation\CodeSample::reported(<<<'PHP' + ruleDefinition; + } + public function getNodeType(): string { return Node\Stmt\Switch_::class; diff --git a/tools/.phpstan/vendor/ergebnis/version/CHANGELOG.md b/tools/.phpstan/vendor/ergebnis/version/CHANGELOG.md new file mode 100644 index 000000000..2a84af6c3 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/CHANGELOG.md @@ -0,0 +1,82 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +For a full diff see [`1.4.0...main`][1.4.0...main]. + +## [`1.4.0`][1.4.0] + +For a full diff see [`1.3.0...1.4.0`][1.3.0...1.4.0]. + +### Changed + +- Allowed installation on PHP 8.6 ([#357]), by [@localheinz] + +## [`1.3.0`][1.3.0] + +For a full diff see [`1.2.0...1.3.0`][1.2.0...1.3.0]. + +### Changed + +- Allowed installation on PHP 8.5 ([#214]), by [@localheinz] + +## [`1.2.0`][1.2.0] + +For a full diff see [`1.1.0...1.2.0`][1.1.0...1.2.0]. + +### Added + +- Added support for PHP 8.4 ([#167]), by [@localheinz] + +## [`1.1.0`][1.1.0] + +For a full diff see [`1.0.0...1.1.0`][1.0.0...1.1.0]. + +### Added + +- Added support for PHP 8.0 ([#77]), by [@localheinz] +- Added support for PHP 7.4 ([#78]), by [@localheinz] + +## [`1.0.0`][1.0.0] + +For a full diff see [`64ced12...1.0.0`][64ced12...1.0.0]. + +### Added + +- Added `Version` as a value object ([#1]), by [@localheinz] +- Added `Major` as a value object ([#3]), by [@localheinz] +- Added `Minor` as a value object ([#4]), by [@localheinz] +- Added `Patch` as a value object ([#5]), by [@localheinz] +- Added `PreRelease` as a value object ([#8]), by [@localheinz] +- Added `BuildMetaData` as a value object ([#9]), by [@localheinz] + +[1.0.0]: https://github.com/ergebnis/version/releases/tag/1.0.0 +[1.1.0]: https://github.com/ergebnis/version/releases/tag/1.1.0 +[1.2.0]: https://github.com/ergebnis/version/releases/tag/1.2.0 +[1.3.0]: https://github.com/ergebnis/version/releases/tag/1.3.0 + +[64ced12...1.0.0]: https://github.com/ergebnis/version/compare/64ced12...1.0.0 +[1.0.0...1.1.0]: https://github.com/ergebnis/version/compare/1.0.0...1.1.0 +[1.1.0...1.2.0]: https://github.com/ergebnis/version/compare/1.1.0...1.2.0 +[1.2.0...1.3.0]: https://github.com/ergebnis/version/compare/1.2.0...1.3.0 +[1.3.0...1.4.0]: https://github.com/ergebnis/version/compare/1.3.0...1.4.0 +[1.4.0]: https://github.com/ergebnis/version/releases/tag/1.4.0 +[1.4.0...main]: https://github.com/ergebnis/version/compare/1.4.0...main + +[#1]: https://github.com/ergebnis/version/pull/1 +[#3]: https://github.com/ergebnis/version/pull/3 +[#4]: https://github.com/ergebnis/version/pull/4 +[#5]: https://github.com/ergebnis/version/pull/5 +[#8]: https://github.com/ergebnis/version/pull/8 +[#9]: https://github.com/ergebnis/version/pull/9 +[#77]: https://github.com/ergebnis/version/pull/77 +[#78]: https://github.com/ergebnis/version/pull/78 +[#167]: https://github.com/ergebnis/version/pull/167 +[#214]: https://github.com/ergebnis/version/pull/214 +[#357]: https://github.com/ergebnis/version/pull/357 + +[@localheinz]: https://github.com/localheinz diff --git a/tools/.phpstan/vendor/ergebnis/version/LICENSE.md b/tools/.phpstan/vendor/ergebnis/version/LICENSE.md new file mode 100644 index 000000000..a222413b0 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/LICENSE.md @@ -0,0 +1,16 @@ +# The MIT License (MIT) + +Copyright (c) 2023-2026 Andreas Möller + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the _Software_), to deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED **AS IS**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tools/.phpstan/vendor/ergebnis/version/README.md b/tools/.phpstan/vendor/ergebnis/version/README.md new file mode 100644 index 000000000..0bcfeb0bf --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/README.md @@ -0,0 +1,523 @@ +# version + +[![Integrate](https://github.com/ergebnis/version/actions/workflows/integrate.yaml/badge.svg?branch=main)](https://github.com/ergebnis/version/actions/workflows/integrate.yaml) +[![Merge](https://github.com/ergebnis/version/actions/workflows/merge.yaml/badge.svg)](https://github.com/ergebnis/version/actions/workflows/merge.yaml) +[![Release](https://github.com/ergebnis/version/actions/workflows/release.yaml/badge.svg)](https://github.com/ergebnis/version/actions/workflows/release.yaml) +[![Renew](https://github.com/ergebnis/version/actions/workflows/renew.yaml/badge.svg)](https://github.com/ergebnis/version/actions/workflows/renew.yaml) + +[![Code Coverage](https://codecov.io/gh/ergebnis/version/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/version) + +[![Latest Stable Version](https://poser.pugx.org/ergebnis/version/v/stable)](https://packagist.org/packages/ergebnis/version) +[![Total Downloads](https://poser.pugx.org/ergebnis/version/downloads)](https://packagist.org/packages/ergebnis/version) +[![Monthly Downloads](https://poser.pugx.org/ergebnis/version/d/monthly)](https://packagist.org/packages/ergebnis/version) + +This project provides a [`composer`](https://getcomposer.org) package with an abstraction of a [semantic version](https://semver.org). + +## Installation + +Run + +```sh +composer require ergebnis/version +``` + +## Usage + +This project comes with the following components: + +- [`Ergebnis\Version\Version`](#version) +- [`Ergebnis\Version\Major`](#major) +- [`Ergebnis\Version\Minor`](#minor) +- [`Ergebnis\Version\Patch`](#patch) +- [`Ergebnis\Version\PreRelease`](#prerelease) +- [`Ergebnis\Version\BuildMetaData`](#buildmetadata) + +### `Version` + +#### Create a `Version` from a `string` + +```php +toString(); // 1.2.3 + +echo $version->major()->toString(); // 1 +echo $version->minor()->toString(); // 2 +echo $version->patch()->toString(); // 3 +echo $version->preRelease()->toString(); // alpha +echo $version->buildMetaData()->toString(); // build.9001 +``` + +#### Bump a `Version` + +```php +bumpMajor(); + +echo $one->toString(); // 2.0.0 + +$two = $version->bumpMinor(); + +echo $two->toString(); // 1.3.0 + +$three = $version->bumpPatch(); + +echo $three->toString(); // 1.2.4 +``` + +#### Bump a `Version` with `PreRelease` + +```php +bumpMajor(); + +echo $one->toString(); // 2.0.0 + +$two = $version->bumpMinor(); + +echo $two->toString(); // 1.3.0 + +$three = $version->bumpPatch(); + +echo $three->toString(); // 1.2.3 +``` + +#### Bump a `Version` with `BuildMetaData` + +```php +bumpMajor(); + +echo $one->toString(); // 2.0.0 + +$two = $version->bumpMinor(); + +echo $two->toString(); // 1.3.0 + +$three = $version->bumpPatch(); + +echo $three->toString(); // 1.2.4 +``` + +#### Compare a `Version` with another `Version` + +```php +compare($two); // -1 +$one->compare($one); // 0 +$three->compare($one); // 1 + +$one->isSmallerThan($one); // false +$one->isSmallerThan($two); // true +$one->isSmallerThan($three); // true +$one->isSmallerThan($four); // true + +$one->equals($two); // false +$one->equals($one); // true +$one->equals($three); // false +$three->equals($four); // true + +$one->isGreaterThan($one); // false +$two->isGreaterThan($one); // true +$three->isGreaterThan($one); // true +$four->isGreaterThan($one); // true +``` + +### `Major` + +#### Create a `Major` from an `int` + +```php +toString(); // 1 +``` + +#### Create a `Major` from a `string` + +```php +toString(); // 1 +``` + +#### Bump a `Major` + +```php +bump(); + +echo $two->toString(); // 2 +``` + +#### Compare a `Major` with another `Major` + +```php +compare($two); // -1 +$one->compare($one); // 0 +$two->compare($one); // 1 + +$one->isSmallerThan($one); // false +$one->isSmallerThan($two); // true + +$one->equals($two); // false +$one->equals($one); // true + +$one->isGreaterThan($one); // false +$two->isGreaterThan($one); // true +``` + +### `Minor` + +#### Create a `Minor` from an `int` + +```php +toString(); // 1 +``` + +#### Create a `Minor` from a `string` + +```php +toString(); // 1 +``` + +#### Bump a `Minor` + +```php +bump(); + +echo $two->toString(); // 2 +``` + +#### Compare a `Minor` with another `Minor` + +```php +compare($two); // -1 +$one->compare($one); // 0 +$two->compare($one); // 1 + +$one->isSmallerThan($one); // false +$one->isSmallerThan($two); // true + +$one->equals($two); // false +$one->equals($one); // true + +$one->isGreaterThan($one); // false +$two->isGreaterThan($one); // true +``` + +### `Patch` + +#### Create a `Patch` from an `int` + +```php +toString(); // 1 +``` + +#### Create a `Patch` from a `string` + +```php +toString(); // 1 +``` + +#### Bump a `Patch` + +```php +bump(); + +echo $two->toString(); // 2 +``` + +#### Compare a `Patch` with another `Patch` + +```php +compare($two); // -1 +$one->compare($one); // 0 +$two->compare($one); // 1 + +$one->isSmallerThan($one); // false +$one->isSmallerThan($two); // true + +$one->equals($two); // false +$one->equals($one); // true + +$one->isGreaterThan($one); // false +$two->isGreaterThan($one); // true +``` + +### `PreRelease` + +#### Create a `PreRelease` from a `string` + +```php +toString(); // alpha +``` + +#### Create an empty `PreRelease` + +```php +toString(); // empty +``` + +#### Compare a `PreRelease` with another `PreRelease` + +```php +compare($two); // -1 +$one->compare($one); // 0 +$two->compare($one); // 1 + +$one->isSmallerThan($one); // false +$one->isSmallerThan($two); // true + +$one->equals($two); // false +$one->equals($one); // true + +$one->isGreaterThan($one); // false +$two->isGreaterThan($one); // true +``` + +### `BuildMetaData` + +#### Create a `BuildMetaData` from a `string` + +```php +toString(); // build.9001 +``` + +#### Create an empty `BuildMetaData` + +```php +toString(); // empty +``` + +#### Compare a `BuildMetaData` with another `BuildMetaData` + +```php +equals($two); // false +$one->equals($one); // true +``` + +## Changelog + +The maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md). + +## Contributing + +The maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md). + +## Code of Conduct + +The maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md). + +## General Support Policy + +The maintainers of this project provide limited support. + +You can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis). + +## PHP Version Support Policy + +This project currently supports the following PHP versions: + +- [PHP 7.4](https://www.php.net/releases/#7.4.0) (has reached its end of life on November 28, 2022) +- [PHP 8.0](https://www.php.net/releases/#8.0.0) (has reached its end of life on November 26, 2023) +- [PHP 8.1](https://www.php.net/releases/#8.1.0) (has reached its end of life on December 31, 2025) +- [PHP 8.2](https://www.php.net/releases/#8.2.0) +- [PHP 8.3](https://www.php.net/releases/#8.3.0) +- [PHP 8.4](https://www.php.net/releases/#8.4.0) +- [PHP 8.5](https://www.php.net/releases/#8.5.0) + +The maintainers of this project add support for a PHP version following its initial release and _may_ drop support for a PHP version when it has reached its [end of life](https://www.php.net/supported-versions.php). + +## Security Policy + +This project has a [security policy](.github/SECURITY.md). + +## License + +This project uses the [MIT license](LICENSE.md). + +## Social + +Follow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter. diff --git a/tools/.phpstan/vendor/ergebnis/version/composer.json b/tools/.phpstan/vendor/ergebnis/version/composer.json new file mode 100644 index 000000000..c5a913dda --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/composer.json @@ -0,0 +1,82 @@ +{ + "name": "ergebnis/version", + "description": "Provides an abstraction of a semantic version.", + "license": "MIT", + "type": "library", + "keywords": [ + "semantic", + "version" + ], + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com", + "homepage": "https://localheinz.com" + } + ], + "homepage": "https://github.com/ergebnis/version", + "support": { + "issues": "https://github.com/ergebnis/version/issues", + "source": "https://github.com/ergebnis/version", + "security": "https://github.com/ergebnis/version/blob/main/.github/SECURITY.md" + }, + "require": { + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0" + }, + "require-dev": { + "ext-bcmath": "*", + "ergebnis/composer-normalize": "^2.53.0", + "ergebnis/data-provider": "^3.6.0", + "ergebnis/license": "^2.7.0", + "ergebnis/php-cs-fixer-config": "^6.63.2", + "ergebnis/phpunit-slow-test-detector": "^2.25.0", + "ergebnis/rector-rules": "^1.18.3", + "fakerphp/faker": "^1.24.1", + "infection/infection": "~0.26.6", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.2.14", + "phpstan/phpstan-deprecation-rules": "^2.0.5", + "phpstan/phpstan-phpunit": "^2.0.18", + "phpstan/phpstan-strict-rules": "^2.0.12", + "phpunit/phpunit": "^9.6.33", + "rector/rector": "^2.6.7" + }, + "suggest": { + "ext-bcmath": "If you want to bump Major, Minor, or Patch versions greater than PHP_MAX_INT." + }, + "autoload": { + "psr-4": { + "Ergebnis\\Version\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Ergebnis\\Version\\Test\\": "test/" + } + }, + "config": { + "allow-plugins": { + "composer/package-versions-deprecated": true, + "ergebnis/composer-normalize": true, + "infection/extension-installer": true, + "phpstan/extension-installer": true + }, + "audit": { + "abandoned": "report" + }, + "platform": { + "php": "7.4.33" + }, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-main": "1.4-dev" + }, + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/BuildMetaData.php b/tools/.phpstan/vendor/ergebnis/version/src/BuildMetaData.php new file mode 100644 index 000000000..844b7bcb4 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/BuildMetaData.php @@ -0,0 +1,56 @@ +[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)$/'; + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + /** + * @throws Exception\InvalidBuildMetaData + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value)) { + throw Exception\InvalidBuildMetaData::fromString($value); + } + + return new self($value); + } + + public static function empty(): self + { + return new self(''); + } + + public function toString(): string + { + return $this->value; + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/Exception/ExtensionMissing.php b/tools/.phpstan/vendor/ergebnis/version/src/Exception/ExtensionMissing.php new file mode 100644 index 000000000..2b4154211 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/Exception/ExtensionMissing.php @@ -0,0 +1,25 @@ +0|[1-9]\d*)$/'; + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + /** + * @throws Exception\InvalidMajor + */ + public static function fromInt(int $value): self + { + if (0 > $value) { + throw Exception\InvalidMajor::fromInt($value); + } + + return new self((string) $value); + } + + /** + * @throws Exception\InvalidMajor + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value)) { + throw Exception\InvalidMajor::fromString($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } + + /** + * @throws Exception\ExtensionMissing + */ + public function bump(): self + { + $valueCastedToInt = (int) $this->value; + + if (\PHP_INT_MAX === $valueCastedToInt) { + if (!\extension_loaded('bcmath')) { + throw Exception\ExtensionMissing::bcmath(); + } + + return new self(\bcadd( + $this->value, + '1', + )); + } + + return new self((string) ($valueCastedToInt + 1)); + } + + public function compare(self $other): int + { + return $this->value <=> $other->value; + } + + public function isSmallerThan(self $other): bool + { + return $this->value < $other->value; + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } + + public function isGreaterThan(self $other): bool + { + return $this->value > $other->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/Minor.php b/tools/.phpstan/vendor/ergebnis/version/src/Minor.php new file mode 100644 index 000000000..e6eb648d3 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/Minor.php @@ -0,0 +1,99 @@ +0|[1-9]\d*)$/'; + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + /** + * @throws Exception\InvalidMinor + */ + public static function fromInt(int $value): self + { + if (0 > $value) { + throw Exception\InvalidMinor::fromInt($value); + } + + return new self((string) $value); + } + + /** + * @throws Exception\InvalidMinor + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value)) { + throw Exception\InvalidMinor::fromString($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } + + /** + * @throws Exception\ExtensionMissing + */ + public function bump(): self + { + $valueCastedToInt = (int) $this->value; + + if (\PHP_INT_MAX === $valueCastedToInt) { + if (!\extension_loaded('bcmath')) { + throw Exception\ExtensionMissing::bcmath(); + } + + return new self(\bcadd( + $this->value, + '1', + )); + } + + return new self((string) ($valueCastedToInt + 1)); + } + + public function compare(self $other): int + { + return $this->value <=> $other->value; + } + + public function isSmallerThan(self $other): bool + { + return $this->value < $other->value; + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } + + public function isGreaterThan(self $other): bool + { + return $this->value > $other->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/Patch.php b/tools/.phpstan/vendor/ergebnis/version/src/Patch.php new file mode 100644 index 000000000..c338083de --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/Patch.php @@ -0,0 +1,99 @@ +0|[1-9]\d*)$/'; + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + /** + * @throws Exception\InvalidPatch + */ + public static function fromInt(int $value): self + { + if (0 > $value) { + throw Exception\InvalidPatch::fromInt($value); + } + + return new self((string) $value); + } + + /** + * @throws Exception\InvalidPatch + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value)) { + throw Exception\InvalidPatch::fromString($value); + } + + return new self($value); + } + + public function toString(): string + { + return $this->value; + } + + /** + * @throws Exception\ExtensionMissing + */ + public function bump(): self + { + $valueCastedToInt = (int) $this->value; + + if (\PHP_INT_MAX === $valueCastedToInt) { + if (!\extension_loaded('bcmath')) { + throw Exception\ExtensionMissing::bcmath(); + } + + return new self(\bcadd( + $this->value, + '1', + )); + } + + return new self((string) ($valueCastedToInt + 1)); + } + + public function compare(self $other): int + { + return $this->value <=> $other->value; + } + + public function isSmallerThan(self $other): bool + { + return $this->value < $other->value; + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } + + public function isGreaterThan(self $other): bool + { + return $this->value > $other->value; + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/PreRelease.php b/tools/.phpstan/vendor/ergebnis/version/src/PreRelease.php new file mode 100644 index 000000000..29c1bb7df --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/PreRelease.php @@ -0,0 +1,129 @@ +(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)$/'; + private string $value; + + private function __construct(string $value) + { + $this->value = $value; + } + + /** + * @throws Exception\InvalidPreRelease + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value)) { + throw Exception\InvalidPreRelease::fromString($value); + } + + return new self($value); + } + + public static function empty(): self + { + return new self(''); + } + + public function toString(): string + { + return $this->value; + } + + /** + * @see https://semver.org/#spec-item-11 + */ + public function compare(self $other): int + { + $identifiers = \explode( + '.', + $this->value, + ); + + $otherIdentifiers = \explode( + '.', + $other->value, + ); + + $maxCount = \max( + \count($identifiers), + \count($otherIdentifiers), + ); + + for ($i = 0; $maxCount > $i; ++$i) { + if (!\array_key_exists($i, $identifiers)) { + return -1; + } + + $identifier = $identifiers[$i]; + + if (!\array_key_exists($i, $otherIdentifiers)) { + return 1; + } + + $otherIdentifier = $otherIdentifiers[$i]; + + if ($identifier === $otherIdentifier) { + continue; + } + + if (self::isNumericIdentifier($identifier)) { + if (self::isNumericIdentifier($otherIdentifier)) { + return $identifier <=> $otherIdentifier; + } + + return -1; + } + + if (self::isNumericIdentifier($otherIdentifier)) { + return 1; + } + + return \strnatcmp( + $identifier, + $otherIdentifier, + ); + } + + return 0; + } + + public function isSmallerThan(self $other): bool + { + return -1 === $this->compare($other); + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } + + public function isGreaterThan(self $other): bool + { + return 1 === $this->compare($other); + } + + private static function isNumericIdentifier(string $value): bool + { + return 1 === \preg_match('/^\d+$/', $value); + } +} diff --git a/tools/.phpstan/vendor/ergebnis/version/src/Version.php b/tools/.phpstan/vendor/ergebnis/version/src/Version.php new file mode 100644 index 000000000..7af0401f9 --- /dev/null +++ b/tools/.phpstan/vendor/ergebnis/version/src/Version.php @@ -0,0 +1,238 @@ +0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/'; + private Major $major; + private Minor $minor; + private Patch $patch; + private PreRelease $preRelease; + private BuildMetaData $buildMetaData; + + private function __construct( + Major $major, + Minor $minor, + Patch $patch, + PreRelease $preRelease, + BuildMetaData $buildMetaData + ) { + $this->major = $major; + $this->minor = $minor; + $this->patch = $patch; + $this->preRelease = $preRelease; + $this->buildMetaData = $buildMetaData; + } + + /** + * @throws Exception\InvalidVersion + */ + public static function fromString(string $value): self + { + if (1 !== \preg_match(self::REGEX, $value, $matches)) { + throw Exception\InvalidVersion::fromString($value); + } + + $preRelease = PreRelease::empty(); + + if ( + \array_key_exists('prerelease', $matches) + && '' !== $matches['prerelease'] + ) { + $preRelease = PreRelease::fromString($matches['prerelease']); + } + + $buildMetaData = BuildMetaData::empty(); + + if ( + \array_key_exists('buildmetadata', $matches) + && '' !== $matches['buildmetadata'] + ) { + $buildMetaData = BuildMetaData::fromString($matches['buildmetadata']); + } + + return new self( + Major::fromString($matches['major']), + Minor::fromString($matches['minor']), + Patch::fromString($matches['patch']), + $preRelease, + $buildMetaData, + ); + } + + public function toString(): string + { + /** + * @see https://semver.org/#spec-item-2 + */ + $value = \sprintf( + '%s.%s.%s', + $this->major->toString(), + $this->minor->toString(), + $this->patch->toString(), + ); + + /** + * @see https://semver.org/#spec-item-9 + */ + if (!$this->preRelease->equals(PreRelease::empty())) { + $value = \sprintf( + '%s-%s', + $value, + $this->preRelease->toString(), + ); + } + + /** + * @see https://semver.org/#spec-item-10 + */ + if (!$this->buildMetaData->equals(BuildMetaData::empty())) { + $value = \sprintf( + '%s+%s', + $value, + $this->buildMetaData->toString(), + ); + } + + return $value; + } + + /** + * @see https://semver.org/#spec-item-8 + */ + public function bumpMajor(): self + { + return new self( + $this->major->bump(), + Minor::fromInt(0), + Patch::fromInt(0), + PreRelease::empty(), + BuildMetaData::empty(), + ); + } + + /** + * @see https://semver.org/#spec-item-7 + */ + public function bumpMinor(): self + { + return new self( + $this->major, + $this->minor->bump(), + Patch::fromInt(0), + PreRelease::empty(), + BuildMetaData::empty(), + ); + } + + /** + * @see https://semver.org/#spec-item-6 + */ + public function bumpPatch(): self + { + return new self( + $this->major, + $this->minor, + $this->patch->bump(), + PreRelease::empty(), + BuildMetaData::empty(), + ); + } + + public function compare(self $other): int + { + $major = $this->major->compare($other->major); + + if (0 !== $major) { + return $major; + } + + $minor = $this->minor->compare($other->minor); + + if (0 !== $minor) { + return $minor; + } + + $patch = $this->patch->compare($other->patch); + + if (0 !== $patch) { + return $patch; + } + + if ($this->preRelease->equals(PreRelease::empty())) { + if ($other->preRelease->equals(PreRelease::empty())) { + return 0; + } + + return 1; + } + + if ($other->preRelease->equals(PreRelease::empty())) { + return -1; + } + + $preRelease = $this->preRelease->compare($other->preRelease); + + if (0 !== $preRelease) { + return $preRelease; + } + + return 0; + } + + public function isSmallerThan(self $other): bool + { + return -1 === $this->compare($other); + } + + public function equals(self $other): bool + { + return 0 === $this->compare($other); + } + + public function isGreaterThan(self $other): bool + { + return 1 === $this->compare($other); + } + + public function major(): Major + { + return $this->major; + } + + public function minor(): Minor + { + return $this->minor; + } + + public function patch(): Patch + { + return $this->patch; + } + + public function preRelease(): PreRelease + { + return $this->preRelease; + } + + public function buildMetaData(): BuildMetaData + { + return $this->buildMetaData; + } +}