From b31ec711763a3a0c0a126e41d15f7b3eb8009324 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 2 Feb 2022 10:21:52 +0000 Subject: [PATCH] Update dependency slevomat/coding-standard to v7 --- .gitignore | 2 +- build-cs/.gitignore | 1 - build-cs/composer.json | 2 +- build-cs/composer.lock | 327 ++++++++++++++++++ phpcs.xml | 172 +++++---- .../ContainerInterfacePrivateServiceRule.php | 10 +- .../ContainerInterfaceUnknownServiceRule.php | 13 +- .../InvalidArgumentDefaultValueRule.php | 11 +- .../Symfony/InvalidOptionDefaultValueRule.php | 11 +- src/Rules/Symfony/UndefinedArgumentRule.php | 14 +- src/Rules/Symfony/UndefinedOptionRule.php | 14 +- src/Symfony/ConsoleApplicationResolver.php | 8 +- src/Symfony/DefaultParameterMap.php | 6 +- src/Symfony/DefaultServiceMap.php | 6 +- src/Symfony/FakeParameterMap.php | 2 +- src/Symfony/FakeServiceMap.php | 2 +- src/Symfony/InputBagStubFilesExtension.php | 1 + src/Symfony/Parameter.php | 1 - src/Symfony/ParameterMap.php | 2 +- src/Symfony/ServiceMap.php | 2 +- .../XmlContainerNotExistsException.php | 4 +- src/Symfony/XmlParameterMapFactory.php | 19 +- src/Symfony/XmlServiceMapFactory.php | 8 +- .../ArgumentTypeSpecifyingExtension.php | 4 +- ...andGetHelperDynamicReturnTypeExtension.php | 2 +- ...ionPrototypeDynamicReturnTypeExtension.php | 2 + ...ParentObjectDynamicReturnTypeExtension.php | 2 +- ...ReturnParentDynamicReturnTypeExtension.php | 2 +- .../TreeBuilderDynamicReturnTypeExtension.php | 4 +- .../Symfony/EnvelopeReturnTypeExtension.php | 1 + .../InputBagDynamicReturnTypeExtension.php | 1 + ...eGetArgumentDynamicReturnTypeExtension.php | 2 +- ...aceGetOptionDynamicReturnTypeExtension.php | 2 +- ...eHasArgumentDynamicReturnTypeExtension.php | 2 +- ...aceHasOptionDynamicReturnTypeExtension.php | 2 +- .../Symfony/OptionTypeSpecifyingExtension.php | 4 +- .../ParameterDynamicReturnTypeExtension.php | 17 +- .../SerializerDynamicReturnTypeExtension.php | 1 + .../ServiceDynamicReturnTypeExtension.php | 2 +- .../ServiceTypeSpecifyingExtension.php | 4 +- tests/Rules/NonexistentInputBagClassTest.php | 2 +- ...nerInterfacePrivateServiceRuleFakeTest.php | 2 + ...ntainerInterfacePrivateServiceRuleTest.php | 2 + ...nerInterfaceUnknownServiceRuleFakeTest.php | 4 +- ...ntainerInterfaceUnknownServiceRuleTest.php | 2 + .../Symfony/ExampleAbstractController.php | 3 +- tests/Rules/Symfony/ExampleController.php | 3 +- .../Symfony/ExampleServiceSubscriber.php | 3 +- tests/Symfony/DefaultParameterMapTest.php | 28 +- tests/Symfony/DefaultServiceMapTest.php | 18 +- tests/Type/Symfony/ExtensionTest.php | 4 +- .../Symfony/ExtensionTestWithoutContainer.php | 3 +- .../ImpossibleCheckTypeMethodCallRuleTest.php | 5 +- .../Symfony/console_application_loader.php | 2 +- 54 files changed, 576 insertions(+), 197 deletions(-) create mode 100644 build-cs/composer.lock diff --git a/.gitignore b/.gitignore index d6a83e59..2db21315 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /tests/tmp /vendor -composer.lock +/composer.lock .phpunit.result.cache diff --git a/build-cs/.gitignore b/build-cs/.gitignore index ff72e2d0..61ead866 100644 --- a/build-cs/.gitignore +++ b/build-cs/.gitignore @@ -1,2 +1 @@ -/composer.lock /vendor diff --git a/build-cs/composer.json b/build-cs/composer.json index cc6a4983..e3079710 100644 --- a/build-cs/composer.json +++ b/build-cs/composer.json @@ -2,7 +2,7 @@ "require-dev": { "consistence-community/coding-standard": "^3.10", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "slevomat/coding-standard": "^6.4" + "slevomat/coding-standard": "^7.0" }, "config": { "allow-plugins": { diff --git a/build-cs/composer.lock b/build-cs/composer.lock new file mode 100644 index 00000000..70af78f9 --- /dev/null +++ b/build-cs/composer.lock @@ -0,0 +1,327 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "4485bbedba7bcc71ace5f69dbb9b6c47", + "packages": [], + "packages-dev": [ + { + "name": "consistence-community/coding-standard", + "version": "3.11.1", + "source": { + "type": "git", + "url": "https://github.com/consistence-community/coding-standard.git", + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "slevomat/coding-standard": "~7.0", + "squizlabs/php_codesniffer": "~3.6.0" + }, + "replace": { + "consistence/coding-standard": "3.10.*" + }, + "require-dev": { + "phing/phing": "2.16.4", + "php-parallel-lint/php-parallel-lint": "1.3.0", + "phpunit/phpunit": "9.5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Consistence\\": [ + "Consistence" + ] + }, + "classmap": [ + "Consistence" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "VaĊĦek Purchart", + "email": "me@vasekpurchart.cz", + "homepage": "http://vasekpurchart.cz" + } + ], + "description": "Consistence - Coding Standard - PHP Code Sniffer rules", + "keywords": [ + "Coding Standard", + "PHPCodeSniffer", + "codesniffer", + "coding", + "cs", + "phpcs", + "ruleset", + "sniffer", + "standard" + ], + "support": { + "issues": "https://github.com/consistence-community/coding-standard/issues", + "source": "https://github.com/consistence-community/coding-standard/tree/3.11.1" + }, + "time": "2021-05-03T18:13:22+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/dbc093d7af60eff5cd575d2ed761b15ed40bd08e", + "reference": "dbc093d7af60eff5cd575d2ed761b15ed40bd08e", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.2.0" + }, + "time": "2021-09-16T20:46:02+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "7.0.18", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", + "reference": "b81ac84f41a4797dc25c8ede1b0718e2a74be0fc", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.1 || ^8.0", + "phpstan/phpdoc-parser": "^1.0.0", + "squizlabs/php_codesniffer": "^3.6.1" + }, + "require-dev": { + "phing/phing": "2.17.0", + "php-parallel-lint/php-parallel-lint": "1.3.1", + "phpstan/phpstan": "1.2.0", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0", + "phpstan/phpstan-strict-rules": "1.1.0", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.10" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/7.0.18" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2021-12-07T17:19:06+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/phpcs.xml b/phpcs.xml index 2807efec..3412c956 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,66 +1,112 @@ - - - - - - - - src - tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tests/tmp + + + + + + + + + src + tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + 10 + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + tests/*/data + tests/tmp diff --git a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php index 4c9a6af1..0a3a3d3e 100644 --- a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Symfony\ServiceMap; use PHPStan\TrinaryLogic; use PHPStan\Type\ObjectType; @@ -33,16 +33,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - } - if (!$node->name instanceof Node\Identifier) { return []; } diff --git a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php index cb0ae4e6..417f51f5 100644 --- a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php @@ -7,10 +7,11 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Symfony\ServiceMap; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; +use function sprintf; /** * @implements Rule @@ -21,7 +22,7 @@ final class ContainerInterfaceUnknownServiceRule implements Rule /** @var ServiceMap */ private $serviceMap; - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; public function __construct(ServiceMap $symfonyServiceMap, Standard $printer) @@ -36,16 +37,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - } - if (!$node->name instanceof Node\Identifier) { return []; } diff --git a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php index c29f11ed..51d7c3bc 100644 --- a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Type\ArrayType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\IntegerType; @@ -16,6 +16,7 @@ use PHPStan\Type\TypeUtils; use PHPStan\Type\UnionType; use PHPStan\Type\VerbosityLevel; +use function count; use function sprintf; /** @@ -30,16 +31,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - }; - if (!(new ObjectType('Symfony\Component\Console\Command\Command'))->isSuperTypeOf($scope->getType($node->var))->yes()) { return []; } diff --git a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php index 3eb2df1b..ab52d626 100644 --- a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Type\ArrayType; use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantIntegerType; @@ -18,6 +18,7 @@ use PHPStan\Type\TypeUtils; use PHPStan\Type\UnionType; use PHPStan\Type\VerbosityLevel; +use function count; use function sprintf; /** @@ -32,16 +33,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - }; - if (!(new ObjectType('Symfony\Component\Console\Command\Command'))->isSuperTypeOf($scope->getType($node->var))->yes()) { return []; } diff --git a/src/Rules/Symfony/UndefinedArgumentRule.php b/src/Rules/Symfony/UndefinedArgumentRule.php index 59f71ed6..52f90241 100644 --- a/src/Rules/Symfony/UndefinedArgumentRule.php +++ b/src/Rules/Symfony/UndefinedArgumentRule.php @@ -8,7 +8,7 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; @@ -22,10 +22,10 @@ final class UndefinedArgumentRule implements Rule { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer) @@ -40,16 +40,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - }; - $classReflection = $scope->getClassReflection(); if ($classReflection === null) { return []; diff --git a/src/Rules/Symfony/UndefinedOptionRule.php b/src/Rules/Symfony/UndefinedOptionRule.php index 29e08819..00dd750e 100644 --- a/src/Rules/Symfony/UndefinedOptionRule.php +++ b/src/Rules/Symfony/UndefinedOptionRule.php @@ -8,7 +8,7 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\ShouldNotHappenException; +use PHPStan\Rules\RuleError; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; @@ -22,10 +22,10 @@ final class UndefinedOptionRule implements Rule { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver, Standard $printer) @@ -40,16 +40,10 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node $node - * @param \PHPStan\Analyser\Scope $scope - * @return (string|\PHPStan\Rules\RuleError)[] errors + * @return (string|RuleError)[] errors */ public function processNode(Node $node, Scope $scope): array { - if (!$node instanceof MethodCall) { - throw new ShouldNotHappenException(); - }; - $classReflection = $scope->getClassReflection(); if ($classReflection === null) { return []; diff --git a/src/Symfony/ConsoleApplicationResolver.php b/src/Symfony/ConsoleApplicationResolver.php index efee6292..6d4ec810 100644 --- a/src/Symfony/ConsoleApplicationResolver.php +++ b/src/Symfony/ConsoleApplicationResolver.php @@ -5,16 +5,18 @@ use PHPStan\Reflection\ClassReflection; use PHPStan\ShouldNotHappenException; use PHPStan\Type\ObjectType; +use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use function file_exists; use function get_class; use function is_readable; +use function method_exists; use function sprintf; final class ConsoleApplicationResolver { - /** @var \Symfony\Component\Console\Application|null */ + /** @var Application|null */ private $consoleApplication; public function __construct(Configuration $configuration) @@ -27,7 +29,7 @@ public function __construct(Configuration $configuration) } /** - * @return \Symfony\Component\Console\Application|null + * @return Application|null * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint */ private function loadConsoleApplication(string $consoleApplicationLoader) @@ -42,7 +44,7 @@ private function loadConsoleApplication(string $consoleApplicationLoader) } /** - * @return \Symfony\Component\Console\Command\Command[] + * @return Command[] */ public function findCommands(ClassReflection $classReflection): array { diff --git a/src/Symfony/DefaultParameterMap.php b/src/Symfony/DefaultParameterMap.php index a58ed9fc..fe29b34f 100644 --- a/src/Symfony/DefaultParameterMap.php +++ b/src/Symfony/DefaultParameterMap.php @@ -10,11 +10,11 @@ final class DefaultParameterMap implements ParameterMap { - /** @var \PHPStan\Symfony\ParameterDefinition[] */ + /** @var ParameterDefinition[] */ private $parameters; /** - * @param \PHPStan\Symfony\ParameterDefinition[] $parameters + * @param ParameterDefinition[] $parameters */ public function __construct(array $parameters) { @@ -22,7 +22,7 @@ public function __construct(array $parameters) } /** - * @return \PHPStan\Symfony\ParameterDefinition[] + * @return ParameterDefinition[] */ public function getParameters(): array { diff --git a/src/Symfony/DefaultServiceMap.php b/src/Symfony/DefaultServiceMap.php index 6339b450..cb8259d2 100644 --- a/src/Symfony/DefaultServiceMap.php +++ b/src/Symfony/DefaultServiceMap.php @@ -10,11 +10,11 @@ final class DefaultServiceMap implements ServiceMap { - /** @var \PHPStan\Symfony\ServiceDefinition[] */ + /** @var ServiceDefinition[] */ private $services; /** - * @param \PHPStan\Symfony\ServiceDefinition[] $services + * @param ServiceDefinition[] $services */ public function __construct(array $services) { @@ -22,7 +22,7 @@ public function __construct(array $services) } /** - * @return \PHPStan\Symfony\ServiceDefinition[] + * @return ServiceDefinition[] */ public function getServices(): array { diff --git a/src/Symfony/FakeParameterMap.php b/src/Symfony/FakeParameterMap.php index 7e723411..0bf450e7 100644 --- a/src/Symfony/FakeParameterMap.php +++ b/src/Symfony/FakeParameterMap.php @@ -9,7 +9,7 @@ final class FakeParameterMap implements ParameterMap { /** - * @return \PHPStan\Symfony\ParameterDefinition[] + * @return ParameterDefinition[] */ public function getParameters(): array { diff --git a/src/Symfony/FakeServiceMap.php b/src/Symfony/FakeServiceMap.php index d05fe8ed..88f9edac 100644 --- a/src/Symfony/FakeServiceMap.php +++ b/src/Symfony/FakeServiceMap.php @@ -9,7 +9,7 @@ final class FakeServiceMap implements ServiceMap { /** - * @return \PHPStan\Symfony\ServiceDefinition[] + * @return ServiceDefinition[] */ public function getServices(): array { diff --git a/src/Symfony/InputBagStubFilesExtension.php b/src/Symfony/InputBagStubFilesExtension.php index 94fd2104..834ca228 100644 --- a/src/Symfony/InputBagStubFilesExtension.php +++ b/src/Symfony/InputBagStubFilesExtension.php @@ -3,6 +3,7 @@ namespace PHPStan\Symfony; use PHPStan\PhpDoc\StubFilesExtension; +use function class_exists; class InputBagStubFilesExtension implements StubFilesExtension { diff --git a/src/Symfony/Parameter.php b/src/Symfony/Parameter.php index 1df679bc..8ff3f7a8 100644 --- a/src/Symfony/Parameter.php +++ b/src/Symfony/Parameter.php @@ -12,7 +12,6 @@ final class Parameter implements ParameterDefinition private $value; /** - * @param string $key * @param array|bool|float|int|string $value */ public function __construct( diff --git a/src/Symfony/ParameterMap.php b/src/Symfony/ParameterMap.php index fc14fb2c..c768e2f2 100644 --- a/src/Symfony/ParameterMap.php +++ b/src/Symfony/ParameterMap.php @@ -9,7 +9,7 @@ interface ParameterMap { /** - * @return \PHPStan\Symfony\ParameterDefinition[] + * @return ParameterDefinition[] */ public function getParameters(): array; diff --git a/src/Symfony/ServiceMap.php b/src/Symfony/ServiceMap.php index b954dc72..6665ede0 100644 --- a/src/Symfony/ServiceMap.php +++ b/src/Symfony/ServiceMap.php @@ -9,7 +9,7 @@ interface ServiceMap { /** - * @return \PHPStan\Symfony\ServiceDefinition[] + * @return ServiceDefinition[] */ public function getServices(): array; diff --git a/src/Symfony/XmlContainerNotExistsException.php b/src/Symfony/XmlContainerNotExistsException.php index 7238cc6e..59b600de 100644 --- a/src/Symfony/XmlContainerNotExistsException.php +++ b/src/Symfony/XmlContainerNotExistsException.php @@ -2,7 +2,9 @@ namespace PHPStan\Symfony; -final class XmlContainerNotExistsException extends \InvalidArgumentException +use InvalidArgumentException; + +final class XmlContainerNotExistsException extends InvalidArgumentException { } diff --git a/src/Symfony/XmlParameterMapFactory.php b/src/Symfony/XmlParameterMapFactory.php index 9b34d14d..0891423a 100644 --- a/src/Symfony/XmlParameterMapFactory.php +++ b/src/Symfony/XmlParameterMapFactory.php @@ -2,7 +2,14 @@ namespace PHPStan\Symfony; +use InvalidArgumentException; +use SimpleXMLElement; +use function base64_decode; +use function file_get_contents; +use function is_numeric; +use function simplexml_load_string; use function sprintf; +use function strpos; final class XmlParameterMapFactory implements ParameterMapFactory { @@ -31,10 +38,10 @@ public function create(): ParameterMap throw new XmlContainerNotExistsException(sprintf('Container %s cannot be parsed', $this->containerXml)); } - /** @var \PHPStan\Symfony\Parameter[] $parameters */ + /** @var Parameter[] $parameters */ $parameters = []; foreach ($xml->parameters->parameter as $def) { - /** @var \SimpleXMLElement $attrs */ + /** @var SimpleXMLElement $attrs */ $attrs = $def->attributes(); $parameter = new Parameter( @@ -51,9 +58,9 @@ public function create(): ParameterMap /** * @return array|bool|float|int|string */ - private function getNodeValue(\SimpleXMLElement $def) + private function getNodeValue(SimpleXMLElement $def) { - /** @var \SimpleXMLElement $attrs */ + /** @var SimpleXMLElement $attrs */ $attrs = $def->attributes(); $value = null; @@ -61,7 +68,7 @@ private function getNodeValue(\SimpleXMLElement $def) case 'collection': $value = []; foreach ($def->children() as $child) { - /** @var \SimpleXMLElement $childAttrs */ + /** @var SimpleXMLElement $childAttrs */ $childAttrs = $child->attributes(); if (isset($childAttrs->key)) { @@ -79,7 +86,7 @@ private function getNodeValue(\SimpleXMLElement $def) case 'binary': $value = base64_decode((string) $def, true); if ($value === false) { - throw new \InvalidArgumentException(sprintf('Parameter "%s" of binary type is not valid base64 encoded string.', (string) $attrs->key)); + throw new InvalidArgumentException(sprintf('Parameter "%s" of binary type is not valid base64 encoded string.', (string) $attrs->key)); } break; diff --git a/src/Symfony/XmlServiceMapFactory.php b/src/Symfony/XmlServiceMapFactory.php index 60af1326..ad52c373 100644 --- a/src/Symfony/XmlServiceMapFactory.php +++ b/src/Symfony/XmlServiceMapFactory.php @@ -2,6 +2,8 @@ namespace PHPStan\Symfony; +use SimpleXMLElement; +use function file_get_contents; use function simplexml_load_string; use function sprintf; use function strpos; @@ -34,12 +36,12 @@ public function create(): ServiceMap throw new XmlContainerNotExistsException(sprintf('Container %s cannot be parsed', $this->containerXml)); } - /** @var \PHPStan\Symfony\Service[] $services */ + /** @var Service[] $services */ $services = []; - /** @var \PHPStan\Symfony\Service[] $aliases */ + /** @var Service[] $aliases */ $aliases = []; foreach ($xml->services->service as $def) { - /** @var \SimpleXMLElement $attrs */ + /** @var SimpleXMLElement $attrs */ $attrs = $def->attributes(); if (!isset($attrs->id)) { continue; diff --git a/src/Type/Symfony/ArgumentTypeSpecifyingExtension.php b/src/Type/Symfony/ArgumentTypeSpecifyingExtension.php index 74b6981f..b57f3c35 100644 --- a/src/Type/Symfony/ArgumentTypeSpecifyingExtension.php +++ b/src/Type/Symfony/ArgumentTypeSpecifyingExtension.php @@ -15,10 +15,10 @@ final class ArgumentTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; - /** @var \PHPStan\Analyser\TypeSpecifier */ + /** @var TypeSpecifier */ private $typeSpecifier; public function __construct(Standard $printer) diff --git a/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php b/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php index e9b6ed7e..db2348e3 100644 --- a/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php @@ -18,7 +18,7 @@ final class CommandGetHelperDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver) diff --git a/src/Type/Symfony/Config/ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension.php b/src/Type/Symfony/Config/ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension.php index cd1d4e51..828b000e 100644 --- a/src/Type/Symfony/Config/ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/Config/ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension.php @@ -11,6 +11,8 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeUtils; use PHPStan\Type\VerbosityLevel; +use function count; +use function in_array; final class ArrayNodeDefinitionPrototypeDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { diff --git a/src/Type/Symfony/Config/PassParentObjectDynamicReturnTypeExtension.php b/src/Type/Symfony/Config/PassParentObjectDynamicReturnTypeExtension.php index 5d19b60f..6ef28bbd 100644 --- a/src/Type/Symfony/Config/PassParentObjectDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/Config/PassParentObjectDynamicReturnTypeExtension.php @@ -10,6 +10,7 @@ use PHPStan\Type\Symfony\Config\ValueObject\ParentObjectType; use PHPStan\Type\Type; use PHPStan\Type\VerbosityLevel; +use function in_array; final class PassParentObjectDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { @@ -21,7 +22,6 @@ final class PassParentObjectDynamicReturnTypeExtension implements DynamicMethodR private $methods; /** - * @param string $className * @param string[] $methods */ public function __construct(string $className, array $methods) diff --git a/src/Type/Symfony/Config/ReturnParentDynamicReturnTypeExtension.php b/src/Type/Symfony/Config/ReturnParentDynamicReturnTypeExtension.php index 8dd47a90..4babdcd7 100644 --- a/src/Type/Symfony/Config/ReturnParentDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/Config/ReturnParentDynamicReturnTypeExtension.php @@ -9,6 +9,7 @@ use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Symfony\Config\ValueObject\ParentObjectType; use PHPStan\Type\Type; +use function in_array; final class ReturnParentDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { @@ -20,7 +21,6 @@ final class ReturnParentDynamicReturnTypeExtension implements DynamicMethodRetur private $methods; /** - * @param string $className * @param string[] $methods */ public function __construct(string $className, array $methods) diff --git a/src/Type/Symfony/Config/TreeBuilderDynamicReturnTypeExtension.php b/src/Type/Symfony/Config/TreeBuilderDynamicReturnTypeExtension.php index a5f4f724..8cf3170a 100644 --- a/src/Type/Symfony/Config/TreeBuilderDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/Config/TreeBuilderDynamicReturnTypeExtension.php @@ -6,10 +6,12 @@ use PhpParser\Node\Name; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; +use PHPStan\ShouldNotHappenException; use PHPStan\Type\DynamicStaticMethodReturnTypeExtension; use PHPStan\Type\Symfony\Config\ValueObject\TreeBuilderType; use PHPStan\Type\Type; use PHPStan\Type\TypeUtils; +use function count; final class TreeBuilderDynamicReturnTypeExtension implements DynamicStaticMethodReturnTypeExtension { @@ -37,7 +39,7 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): Type { if (!$methodCall->class instanceof Name) { - throw new \PHPStan\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } $className = $scope->resolveName($methodCall->class); diff --git a/src/Type/Symfony/EnvelopeReturnTypeExtension.php b/src/Type/Symfony/EnvelopeReturnTypeExtension.php index e4e6a34c..5ac61c2f 100644 --- a/src/Type/Symfony/EnvelopeReturnTypeExtension.php +++ b/src/Type/Symfony/EnvelopeReturnTypeExtension.php @@ -11,6 +11,7 @@ use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; +use function count; final class EnvelopeReturnTypeExtension implements DynamicMethodReturnTypeExtension { diff --git a/src/Type/Symfony/InputBagDynamicReturnTypeExtension.php b/src/Type/Symfony/InputBagDynamicReturnTypeExtension.php index b4875829..af35a548 100644 --- a/src/Type/Symfony/InputBagDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputBagDynamicReturnTypeExtension.php @@ -18,6 +18,7 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; use PHPStan\Type\UnionType; +use function in_array; final class InputBagDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { diff --git a/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php index 15e75d0e..a8c35200 100644 --- a/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php @@ -20,7 +20,7 @@ final class InputInterfaceGetArgumentDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver) diff --git a/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php index fb397311..7b543a16 100644 --- a/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php @@ -22,7 +22,7 @@ final class InputInterfaceGetOptionDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver) diff --git a/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php index 112a2bcf..dc933e14 100644 --- a/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php @@ -18,7 +18,7 @@ final class InputInterfaceHasArgumentDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver) diff --git a/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php index eec7201c..3f239fe6 100644 --- a/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php @@ -18,7 +18,7 @@ final class InputInterfaceHasOptionDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { - /** @var \PHPStan\Symfony\ConsoleApplicationResolver */ + /** @var ConsoleApplicationResolver */ private $consoleApplicationResolver; public function __construct(ConsoleApplicationResolver $consoleApplicationResolver) diff --git a/src/Type/Symfony/OptionTypeSpecifyingExtension.php b/src/Type/Symfony/OptionTypeSpecifyingExtension.php index 347cf591..98e0e3fd 100644 --- a/src/Type/Symfony/OptionTypeSpecifyingExtension.php +++ b/src/Type/Symfony/OptionTypeSpecifyingExtension.php @@ -15,10 +15,10 @@ final class OptionTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension { - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; - /** @var \PHPStan\Analyser\TypeSpecifier */ + /** @var TypeSpecifier */ private $typeSpecifier; public function __construct(Standard $printer) diff --git a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php index 0de91de1..0fa8e7bc 100644 --- a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php @@ -27,7 +27,17 @@ use PHPStan\Type\TypeTraverser; use PHPStan\Type\UnionType; use Symfony\Component\DependencyInjection\EnvVarProcessor; +use function array_filter; +use function array_keys; +use function array_map; +use function array_values; +use function class_exists; +use function count; use function in_array; +use function is_array; +use function is_string; +use function preg_match; +use function strlen; final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { @@ -44,10 +54,10 @@ final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTy /** @var bool */ private $constantHassers; - /** @var \PHPStan\Symfony\ParameterMap */ + /** @var ParameterMap */ private $parameterMap; - /** @var \PHPStan\PhpDoc\TypeStringResolver */ + /** @var TypeStringResolver */ private $typeStringResolver; public function __construct( @@ -74,7 +84,7 @@ public function getClass(): string public function isMethodSupported(MethodReflection $methodReflection): bool { - $methods = array_filter([$this->methodGet, $this->methodHas], function (?string $method): bool { + $methods = array_filter([$this->methodGet, $this->methodHas], static function (?string $method): bool { return $method !== null; }); @@ -124,7 +134,6 @@ private function getGetTypeFromMethodCall( } /** - * @param Scope $scope * @param array|bool|float|int|string $value */ private function generalizeTypeFromValue(Scope $scope, $value): Type diff --git a/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php b/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php index fda9b048..5525a770 100755 --- a/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php @@ -11,6 +11,7 @@ use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; +use function substr; class SerializerDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension { diff --git a/src/Type/Symfony/ServiceDynamicReturnTypeExtension.php b/src/Type/Symfony/ServiceDynamicReturnTypeExtension.php index 41c3a394..04608c17 100644 --- a/src/Type/Symfony/ServiceDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/ServiceDynamicReturnTypeExtension.php @@ -24,7 +24,7 @@ final class ServiceDynamicReturnTypeExtension implements DynamicMethodReturnType /** @var bool */ private $constantHassers; - /** @var \PHPStan\Symfony\ServiceMap */ + /** @var ServiceMap */ private $serviceMap; public function __construct(string $className, Configuration $configuration, ServiceMap $symfonyServiceMap) diff --git a/src/Type/Symfony/ServiceTypeSpecifyingExtension.php b/src/Type/Symfony/ServiceTypeSpecifyingExtension.php index a5aad54e..b52c1531 100644 --- a/src/Type/Symfony/ServiceTypeSpecifyingExtension.php +++ b/src/Type/Symfony/ServiceTypeSpecifyingExtension.php @@ -18,10 +18,10 @@ final class ServiceTypeSpecifyingExtension implements MethodTypeSpecifyingExtens /** @var string */ private $className; - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; - /** @var \PHPStan\Analyser\TypeSpecifier */ + /** @var TypeSpecifier */ private $typeSpecifier; public function __construct(string $className, Standard $printer) diff --git a/tests/Rules/NonexistentInputBagClassTest.php b/tests/Rules/NonexistentInputBagClassTest.php index 6619a8c7..5dc674d4 100644 --- a/tests/Rules/NonexistentInputBagClassTest.php +++ b/tests/Rules/NonexistentInputBagClassTest.php @@ -11,7 +11,7 @@ class NonexistentInputBagClassTest extends RuleTestCase { - protected function getRule(): \PHPStan\Rules\Rule + protected function getRule(): Rule { return self::getContainer()->getByType(CallMethodsRule::class); } diff --git a/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php b/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php index 23bdd4e6..4551accd 100644 --- a/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php +++ b/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php @@ -6,6 +6,8 @@ use PHPStan\Symfony\Configuration; use PHPStan\Symfony\XmlServiceMapFactory; use PHPStan\Testing\RuleTestCase; +use function class_exists; +use function interface_exists; /** * @extends RuleTestCase diff --git a/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php b/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php index c349b695..49afaff5 100644 --- a/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php +++ b/tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php @@ -6,6 +6,8 @@ use PHPStan\Symfony\Configuration; use PHPStan\Symfony\XmlServiceMapFactory; use PHPStan\Testing\RuleTestCase; +use function class_exists; +use function interface_exists; /** * @extends RuleTestCase diff --git a/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php b/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php index 46ea3b63..f975a179 100644 --- a/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php +++ b/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php @@ -7,7 +7,9 @@ use PHPStan\Symfony\Configuration; use PHPStan\Symfony\XmlServiceMapFactory; use PHPStan\Testing\RuleTestCase; +use PHPStan\Type\MethodTypeSpecifyingExtension; use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension; +use function class_exists; /** * @extends RuleTestCase @@ -21,7 +23,7 @@ protected function getRule(): Rule } /** - * @return \PHPStan\Type\MethodTypeSpecifyingExtension[] + * @return MethodTypeSpecifyingExtension[] */ protected function getMethodTypeSpecifyingExtensions(): array { diff --git a/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php b/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php index e433a233..12893bab 100644 --- a/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php +++ b/tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php @@ -7,6 +7,8 @@ use PHPStan\Symfony\Configuration; use PHPStan\Symfony\XmlServiceMapFactory; use PHPStan\Testing\RuleTestCase; +use function class_exists; +use function interface_exists; /** * @extends RuleTestCase diff --git a/tests/Rules/Symfony/ExampleAbstractController.php b/tests/Rules/Symfony/ExampleAbstractController.php index 4f0d2abd..22e5900e 100644 --- a/tests/Rules/Symfony/ExampleAbstractController.php +++ b/tests/Rules/Symfony/ExampleAbstractController.php @@ -3,6 +3,7 @@ namespace PHPStan\Rules\Symfony; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Bundle\FrameworkBundle\Test\TestContainer; final class ExampleAbstractController extends AbstractController { @@ -14,7 +15,7 @@ public function privateService(): void public function privateServiceInTestContainer(): void { - /** @var \Symfony\Bundle\FrameworkBundle\Test\TestContainer $container */ + /** @var TestContainer $container */ $container = doFoo(); $container->get('private'); } diff --git a/tests/Rules/Symfony/ExampleController.php b/tests/Rules/Symfony/ExampleController.php index edbdaaf5..5b9e1ca4 100644 --- a/tests/Rules/Symfony/ExampleController.php +++ b/tests/Rules/Symfony/ExampleController.php @@ -3,6 +3,7 @@ namespace PHPStan\Rules\Symfony; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Test\TestContainer; final class ExampleController extends Controller { @@ -14,7 +15,7 @@ public function privateService(): void public function privateServiceInTestContainer(): void { - /** @var \Symfony\Bundle\FrameworkBundle\Test\TestContainer $container */ + /** @var TestContainer $container */ $container = doFoo(); $container->get('private'); } diff --git a/tests/Rules/Symfony/ExampleServiceSubscriber.php b/tests/Rules/Symfony/ExampleServiceSubscriber.php index 3d7f294d..9005cf60 100644 --- a/tests/Rules/Symfony/ExampleServiceSubscriber.php +++ b/tests/Rules/Symfony/ExampleServiceSubscriber.php @@ -3,6 +3,7 @@ namespace PHPStan\Rules\Symfony; use Psr\Container\ContainerInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag; use Symfony\Contracts\Service\ServiceSubscriberInterface; final class ExampleServiceSubscriber implements ServiceSubscriberInterface @@ -24,7 +25,7 @@ public function privateService(): void public function containerParameter(): void { - /** @var \Symfony\Component\DependencyInjection\ParameterBag\ContainerBag $containerBag */ + /** @var ContainerBag $containerBag */ $containerBag = doFoo(); $containerBag->get('parameter_name'); } diff --git a/tests/Symfony/DefaultParameterMapTest.php b/tests/Symfony/DefaultParameterMapTest.php index caab6f97..8e2e5b58 100644 --- a/tests/Symfony/DefaultParameterMapTest.php +++ b/tests/Symfony/DefaultParameterMapTest.php @@ -26,19 +26,19 @@ public function testGetParameterEscapedPath(): void } /** - * @return \Iterator + * @return Iterator */ public function getParameterProvider(): Iterator { yield [ 'unknown', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNull($parameter); }, ]; yield [ 'app.string', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.string', $parameter->getKey()); self::assertSame('abcdef', $parameter->getValue()); @@ -46,7 +46,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.int', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.int', $parameter->getKey()); self::assertSame(123, $parameter->getValue()); @@ -54,7 +54,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.int_as_string', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.int_as_string', $parameter->getKey()); self::assertSame('123', $parameter->getValue()); @@ -62,7 +62,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.float', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.float', $parameter->getKey()); self::assertSame(123.45, $parameter->getValue()); @@ -70,7 +70,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.float_as_string', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.float_as_string', $parameter->getKey()); self::assertSame('123.45', $parameter->getValue()); @@ -78,7 +78,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.boolean', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.boolean', $parameter->getKey()); self::assertTrue($parameter->getValue()); @@ -86,7 +86,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.boolean_as_string', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.boolean_as_string', $parameter->getKey()); self::assertSame('true', $parameter->getValue()); @@ -94,7 +94,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.list', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.list', $parameter->getKey()); self::assertEquals(['en', 'es', 'fr'], $parameter->getValue()); @@ -102,7 +102,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.list_of_list', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.list_of_list', $parameter->getKey()); self::assertEquals([ @@ -113,7 +113,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.map', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.map', $parameter->getKey()); self::assertEquals([ @@ -125,7 +125,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.binary', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.binary', $parameter->getKey()); self::assertSame('This is a Bell char ', $parameter->getValue()); @@ -133,7 +133,7 @@ function (?Parameter $parameter): void { ]; yield [ 'app.constant', - function (?Parameter $parameter): void { + static function (?Parameter $parameter): void { self::assertNotNull($parameter); self::assertSame('app.constant', $parameter->getKey()); self::assertSame('Y-m-d\TH:i:sP', $parameter->getValue()); diff --git a/tests/Symfony/DefaultServiceMapTest.php b/tests/Symfony/DefaultServiceMapTest.php index 0ffbb457..dc8487e5 100644 --- a/tests/Symfony/DefaultServiceMapTest.php +++ b/tests/Symfony/DefaultServiceMapTest.php @@ -26,19 +26,19 @@ public function testGetContainerEscapedPath(): void } /** - * @return \Iterator + * @return Iterator */ public function getServiceProvider(): Iterator { yield [ 'unknown', - function (?Service $service): void { + static function (?Service $service): void { self::assertNull($service); }, ]; yield [ 'withoutClass', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('withoutClass', $service->getId()); self::assertNull($service->getClass()); @@ -49,7 +49,7 @@ function (?Service $service): void { ]; yield [ 'withClass', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('withClass', $service->getId()); self::assertSame('Foo', $service->getClass()); @@ -60,7 +60,7 @@ function (?Service $service): void { ]; yield [ 'withoutPublic', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('withoutPublic', $service->getId()); self::assertSame('Foo', $service->getClass()); @@ -71,7 +71,7 @@ function (?Service $service): void { ]; yield [ 'publicNotTrue', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('publicNotTrue', $service->getId()); self::assertSame('Foo', $service->getClass()); @@ -82,7 +82,7 @@ function (?Service $service): void { ]; yield [ 'public', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('public', $service->getId()); self::assertSame('Foo', $service->getClass()); @@ -93,7 +93,7 @@ function (?Service $service): void { ]; yield [ 'synthetic', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('synthetic', $service->getId()); self::assertSame('Foo', $service->getClass()); @@ -104,7 +104,7 @@ function (?Service $service): void { ]; yield [ 'alias', - function (?Service $service): void { + static function (?Service $service): void { self::assertNotNull($service); self::assertSame('alias', $service->getId()); self::assertSame('Foo', $service->getClass()); diff --git a/tests/Type/Symfony/ExtensionTest.php b/tests/Type/Symfony/ExtensionTest.php index c0aa7f94..a0bb8115 100644 --- a/tests/Type/Symfony/ExtensionTest.php +++ b/tests/Type/Symfony/ExtensionTest.php @@ -5,6 +5,8 @@ use PHPStan\Testing\TypeInferenceTestCase; use ReflectionMethod; use Symfony\Component\HttpFoundation\Request; +use function class_exists; +use function strpos; class ExtensionTest extends TypeInferenceTestCase { @@ -58,8 +60,6 @@ public function dataFileAsserts(): iterable /** * @dataProvider dataFileAsserts - * @param string $assertType - * @param string $file * @param mixed ...$args */ public function testFileAsserts( diff --git a/tests/Type/Symfony/ExtensionTestWithoutContainer.php b/tests/Type/Symfony/ExtensionTestWithoutContainer.php index 997b7e02..fd1785c7 100644 --- a/tests/Type/Symfony/ExtensionTestWithoutContainer.php +++ b/tests/Type/Symfony/ExtensionTestWithoutContainer.php @@ -3,6 +3,7 @@ namespace PHPStan\Type\Symfony; use PHPStan\Testing\TypeInferenceTestCase; +use function class_exists; class ExtensionTestWithoutContainer extends TypeInferenceTestCase { @@ -30,8 +31,6 @@ public function dataAbstractController(): iterable /** * @dataProvider dataExampleController * @dataProvider dataAbstractController - * @param string $assertType - * @param string $file * @param mixed ...$args */ public function testFileAsserts( diff --git a/tests/Type/Symfony/ImpossibleCheckTypeMethodCallRuleTest.php b/tests/Type/Symfony/ImpossibleCheckTypeMethodCallRuleTest.php index ab247b9f..bde62b57 100644 --- a/tests/Type/Symfony/ImpossibleCheckTypeMethodCallRuleTest.php +++ b/tests/Type/Symfony/ImpossibleCheckTypeMethodCallRuleTest.php @@ -4,11 +4,12 @@ use PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class ImpossibleCheckTypeMethodCallRuleTest extends \PHPStan\Testing\RuleTestCase +class ImpossibleCheckTypeMethodCallRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Type/Symfony/console_application_loader.php b/tests/Type/Symfony/console_application_loader.php index 0ef2e0ae..b6755aea 100644 --- a/tests/Type/Symfony/console_application_loader.php +++ b/tests/Type/Symfony/console_application_loader.php @@ -15,7 +15,7 @@ $application->add(new ExampleOptionCommand()); if (class_exists(LazyCommand::class)) { - $application->add(new LazyCommand('lazy-example-option', [], '', false, function () { + $application->add(new LazyCommand('lazy-example-option', [], '', false, static function () { return new ExampleOptionLazyCommand(); })); } else {