From 3d3655b6f746b5bb84c852043a0397f8046e34b9 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 1 Feb 2022 22:11:11 +0000 Subject: [PATCH] chore(deps): 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 | 99 ++++-- .../BooleanInBooleanAndRule.php | 10 +- .../BooleanInBooleanNotRule.php | 14 +- .../BooleanInBooleanOrRule.php | 10 +- .../BooleanInElseIfConditionRule.php | 14 +- .../BooleanInIfConditionRule.php | 14 +- .../BooleanInTernaryOperatorRule.php | 14 +- .../BooleanRuleHelper.php | 4 +- src/Rules/Cast/UselessCastRule.php | 7 +- .../RequireParentConstructCallRule.php | 19 +- .../DisallowedBacktickRule.php | 10 +- .../DisallowedEmptyRule.php | 9 +- .../DisallowedImplicitArrayCreationRule.php | 22 +- .../DisallowedShortTernaryRule.php | 8 +- .../OverwriteVariablesWithForLoopInitRule.php | 5 +- .../OverwriteVariablesWithForeachRule.php | 8 +- src/Rules/Functions/ClosureUsesThisRule.php | 2 + .../WrongCaseOfInheritedMethodRule.php | 11 +- ...ndInArithmeticIncrementOrDecrementRule.php | 12 +- .../OperandInArithmeticPostDecrementRule.php | 4 +- .../OperandInArithmeticPostIncrementRule.php | 4 +- .../OperandInArithmeticPreDecrementRule.php | 4 +- .../OperandInArithmeticPreIncrementRule.php | 4 +- .../OperandsInArithmeticAdditionRule.php | 15 +- .../OperandsInArithmeticDivisionRule.php | 15 +- ...OperandsInArithmeticExponentiationRule.php | 15 +- .../OperandsInArithmeticModuloRule.php | 15 +- ...OperandsInArithmeticMultiplicationRule.php | 15 +- .../OperandsInArithmeticSubtractionRule.php | 15 +- src/Rules/Operators/OperatorRuleHelper.php | 7 +- ...DynamicCallOnStaticMethodsCallableRule.php | 10 +- .../DynamicCallOnStaticMethodsRule.php | 11 +- .../StrictCalls/StrictFunctionCallsRule.php | 24 +- .../MatchingTypeInSwitchCaseConditionRule.php | 18 +- .../VariableMethodCallRule.php | 5 +- .../VariableMethodCallableRule.php | 1 + .../VariablePropertyFetchRule.php | 6 +- .../VariableStaticMethodCallRule.php | 5 +- .../VariableStaticMethodCallableRule.php | 1 + .../VariableStaticPropertyFetchRule.php | 5 +- .../VariableVariablesRule.php | 5 +- tests/Levels/LevelsIntegrationTest.php | 4 +- .../BooleanInBooleanAndRuleTest.php | 5 +- .../BooleanInBooleanNotRuleTest.php | 3 +- .../BooleanInBooleanOrRuleTest.php | 5 +- .../BooleanInElseIfConditionRuleTest.php | 3 +- .../BooleanInIfConditionRuleTest.php | 3 +- .../BooleanInTernaryOperatorRuleTest.php | 3 +- tests/Rules/Cast/UselessCastRuleTest.php | 7 +- .../RequireParentConstructCallRuleTest.php | 6 +- .../DisallowedBacktickRuleTest.php | 3 +- .../DisallowedEmptyRuleTest.php | 3 +- ...isallowedImplicitArrayCreationRuleTest.php | 3 +- .../DisallowedShortTernaryRuleTest.php | 5 +- .../WrongCaseOfInheritedMethodRuleTest.php | 7 +- ...ArithmeticIncrementOrDecrementRuleTest.php | 3 +- .../OperandsInArithmeticAdditionRuleTest.php | 3 +- .../OperandsInArithmeticDivisionRuleTest.php | 3 +- ...andsInArithmeticExponentiationRuleTest.php | 3 +- .../OperandsInArithmeticModuloRuleTest.php | 3 +- ...andsInArithmeticMultiplicationRuleTest.php | 3 +- ...perandsInArithmeticSubtractionRuleTest.php | 3 +- ...micCallOnStaticMethodsCallableRuleTest.php | 6 +- .../DynamicCallOnStaticMethodsRuleTest.php | 3 +- .../StrictFunctionCallsRuleTest.php | 3 +- ...chingTypeInSwitchCaseConditionRuleTest.php | 8 +- .../VariableMethodCallableRuleTest.php | 1 + 71 files changed, 723 insertions(+), 207 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 067a6a8e..95032a6e 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,6 @@ - + + @@ -8,59 +9,103 @@ src tests + - - + + - + + + + + - + - - - - - - + + + + + 10 - - - + + 10 + - - - + + + + + 10 + + + - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - tests/tmp + + tests/*/data diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php index 93f7ee63..53140ccf 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php @@ -2,13 +2,17 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PHPStan\Analyser\Scope; use PHPStan\Node\BooleanAndNode; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; /** - * @implements \PHPStan\Rules\Rule + * @implements Rule */ -class BooleanInBooleanAndRule implements \PHPStan\Rules\Rule +class BooleanInBooleanAndRule implements Rule { /** @var BooleanRuleHelper */ @@ -24,7 +28,7 @@ public function getNodeType(): string return BooleanAndNode::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $originalNode = $node->getOriginalNode(); $messages = []; diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php index 7a492e82..0e53c873 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php @@ -2,9 +2,14 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PhpParser\Node\Expr\BooleanNot; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class BooleanInBooleanNotRule implements \PHPStan\Rules\Rule +class BooleanInBooleanNotRule implements Rule { /** @var BooleanRuleHelper */ @@ -17,15 +22,14 @@ public function __construct(BooleanRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BooleanNot::class; + return BooleanNot::class; } /** - * @param \PhpParser\Node\Expr\BooleanNot $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanNot $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { if ($this->helper->passesAsBoolean($scope, $node->expr)) { return []; diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php index a95738b0..bf98c5cd 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php @@ -2,13 +2,17 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PHPStan\Analyser\Scope; use PHPStan\Node\BooleanOrNode; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; /** - * @implements \PHPStan\Rules\Rule + * @implements Rule */ -class BooleanInBooleanOrRule implements \PHPStan\Rules\Rule +class BooleanInBooleanOrRule implements Rule { /** @var BooleanRuleHelper */ @@ -24,7 +28,7 @@ public function getNodeType(): string return BooleanOrNode::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $originalNode = $node->getOriginalNode(); $messages = []; diff --git a/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php b/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php index 0553f31c..8dfe3dac 100644 --- a/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php +++ b/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php @@ -2,9 +2,14 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PhpParser\Node\Stmt\ElseIf_; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class BooleanInElseIfConditionRule implements \PHPStan\Rules\Rule +class BooleanInElseIfConditionRule implements Rule { /** @var BooleanRuleHelper */ @@ -17,15 +22,14 @@ public function __construct(BooleanRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Stmt\ElseIf_::class; + return ElseIf_::class; } /** - * @param \PhpParser\Node\Stmt\ElseIf_ $node - * @param \PHPStan\Analyser\Scope $scope + * @param ElseIf_ $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { if ($this->helper->passesAsBoolean($scope, $node->cond)) { return []; diff --git a/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php b/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php index a77cad92..7b1cbfb8 100644 --- a/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php +++ b/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php @@ -2,9 +2,14 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PhpParser\Node\Stmt\If_; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class BooleanInIfConditionRule implements \PHPStan\Rules\Rule +class BooleanInIfConditionRule implements Rule { /** @var BooleanRuleHelper */ @@ -17,15 +22,14 @@ public function __construct(BooleanRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Stmt\If_::class; + return If_::class; } /** - * @param \PhpParser\Node\Stmt\If_ $node - * @param \PHPStan\Analyser\Scope $scope + * @param If_ $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { if ($this->helper->passesAsBoolean($scope, $node->cond)) { return []; diff --git a/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php b/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php index 08e4f838..5d389b7a 100644 --- a/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php +++ b/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php @@ -2,9 +2,14 @@ namespace PHPStan\Rules\BooleansInConditions; +use PhpParser\Node; +use PhpParser\Node\Expr\Ternary; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class BooleanInTernaryOperatorRule implements \PHPStan\Rules\Rule +class BooleanInTernaryOperatorRule implements Rule { /** @var BooleanRuleHelper */ @@ -17,15 +22,14 @@ public function __construct(BooleanRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\Ternary::class; + return Ternary::class; } /** - * @param \PhpParser\Node\Expr\Ternary $node - * @param \PHPStan\Analyser\Scope $scope + * @param Ternary $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { if ($node->if === null) { return []; // elvis ?: diff --git a/src/Rules/BooleansInConditions/BooleanRuleHelper.php b/src/Rules/BooleansInConditions/BooleanRuleHelper.php index 98457542..9b167588 100644 --- a/src/Rules/BooleansInConditions/BooleanRuleHelper.php +++ b/src/Rules/BooleansInConditions/BooleanRuleHelper.php @@ -13,7 +13,7 @@ class BooleanRuleHelper { - /** @var \PHPStan\Rules\RuleLevelHelper */ + /** @var RuleLevelHelper */ private $ruleLevelHelper; public function __construct(RuleLevelHelper $ruleLevelHelper) @@ -31,7 +31,7 @@ public function passesAsBoolean(Scope $scope, Expr $expr): bool $scope, $expr, '', - function (Type $type): bool { + static function (Type $type): bool { return $type instanceof BooleanType; } ); diff --git a/src/Rules/Cast/UselessCastRule.php b/src/Rules/Cast/UselessCastRule.php index 1766c1c2..70f762f6 100644 --- a/src/Rules/Cast/UselessCastRule.php +++ b/src/Rules/Cast/UselessCastRule.php @@ -5,14 +5,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\Cast; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Rules\RuleError; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\ErrorType; use PHPStan\Type\GeneralizePrecision; use PHPStan\Type\TypeUtils; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class UselessCastRule implements \PHPStan\Rules\Rule +class UselessCastRule implements Rule { /** @var bool */ @@ -29,8 +31,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\Cast $node - * @param \PHPStan\Analyser\Scope $scope + * @param Cast $node * @return RuleError[] errors */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/Classes/RequireParentConstructCallRule.php b/src/Rules/Classes/RequireParentConstructCallRule.php index d3420ad4..fd386b2e 100644 --- a/src/Rules/Classes/RequireParentConstructCallRule.php +++ b/src/Rules/Classes/RequireParentConstructCallRule.php @@ -3,11 +3,16 @@ namespace PHPStan\Rules\Classes; use PhpParser\Node; +use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name; use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use PHPStan\ShouldNotHappenException; +use ReflectionClass; +use function sprintf; -class RequireParentConstructCallRule implements \PHPStan\Rules\Rule +class RequireParentConstructCallRule implements Rule { public function getNodeType(): string @@ -16,14 +21,13 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Stmt\ClassMethod $node - * @param \PHPStan\Analyser\Scope $scope + * @param ClassMethod $node * @return string[] */ public function processNode(Node $node, Scope $scope): array { if (!$scope->isInClass()) { - throw new \PHPStan\ShouldNotHappenException(); + throw new ShouldNotHappenException(); } if ($scope->isInTrait()) { @@ -85,7 +89,7 @@ private function callsParentConstruct(Node $parserNode): bool } $statement = $this->ignoreErrorSuppression($statement); - if ($statement instanceof \PhpParser\Node\Expr\StaticCall) { + if ($statement instanceof StaticCall) { if ( $statement->class instanceof Name && ((string) $statement->class === 'parent') @@ -105,10 +109,9 @@ private function callsParentConstruct(Node $parserNode): bool } /** - * @param \ReflectionClass $classReflection - * @return \ReflectionClass|false + * @return ReflectionClass|false */ - private function getParentConstructorClass(\ReflectionClass $classReflection) + private function getParentConstructorClass(ReflectionClass $classReflection) { while ($classReflection->getParentClass() !== false) { $constructor = $classReflection->getParentClass()->hasMethod('__construct') ? $classReflection->getParentClass()->getMethod('__construct') : null; diff --git a/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php b/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php index e90dfc9c..aab3824d 100644 --- a/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php @@ -3,19 +3,21 @@ namespace PHPStan\Rules\DisallowedConstructs; use PhpParser\Node; +use PhpParser\Node\Expr\Empty_; +use PhpParser\Node\Expr\ShellExec; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; -class DisallowedBacktickRule implements \PHPStan\Rules\Rule +class DisallowedBacktickRule implements Rule { public function getNodeType(): string { - return \PhpParser\Node\Expr\ShellExec::class; + return ShellExec::class; } /** - * @param \PhpParser\Node\Expr\Empty_ $node - * @param \PHPStan\Analyser\Scope $scope + * @param Empty_ $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php b/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php index 547d5ecb..9a867cd5 100644 --- a/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php @@ -3,19 +3,20 @@ namespace PHPStan\Rules\DisallowedConstructs; use PhpParser\Node; +use PhpParser\Node\Expr\Empty_; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; -class DisallowedEmptyRule implements \PHPStan\Rules\Rule +class DisallowedEmptyRule implements Rule { public function getNodeType(): string { - return \PhpParser\Node\Expr\Empty_::class; + return Empty_::class; } /** - * @param \PhpParser\Node\Expr\Empty_ $node - * @param \PHPStan\Analyser\Scope $scope + * @param Empty_ $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php b/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php index 4aa7c1c4..322d0dac 100644 --- a/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php @@ -2,33 +2,39 @@ namespace PHPStan\Rules\DisallowedConstructs; +use PhpParser\Node; +use PhpParser\Node\Expr\ArrayDimFetch; +use PhpParser\Node\Expr\Assign; +use PhpParser\Node\Expr\Variable; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; +use function is_string; +use function sprintf; -class DisallowedImplicitArrayCreationRule implements \PHPStan\Rules\Rule +class DisallowedImplicitArrayCreationRule implements Rule { public function getNodeType(): string { - return \PhpParser\Node\Expr\Assign::class; + return Assign::class; } /** - * @param \PhpParser\Node\Expr\Assign $node - * @param \PHPStan\Analyser\Scope $scope + * @param Assign $node * @return string[] */ - public function processNode(\PhpParser\Node $node, Scope $scope): array + public function processNode(Node $node, Scope $scope): array { - if (!$node->var instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + if (!$node->var instanceof ArrayDimFetch) { return []; } $node = $node->var; - while ($node instanceof \PhpParser\Node\Expr\ArrayDimFetch) { + while ($node instanceof ArrayDimFetch) { $node = $node->var; } - if (!$node instanceof \PhpParser\Node\Expr\Variable) { + if (!$node instanceof Variable) { return []; } diff --git a/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php b/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php index a42e7cb8..59db24ac 100644 --- a/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php @@ -3,17 +3,19 @@ namespace PHPStan\Rules\DisallowedConstructs; use PhpParser\Node; +use PhpParser\Node\Expr\Ternary; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; /** - * @implements \PHPStan\Rules\Rule<\PhpParser\Node\Expr\Ternary> + * @implements Rule */ -class DisallowedShortTernaryRule implements \PHPStan\Rules\Rule +class DisallowedShortTernaryRule implements Rule { public function getNodeType(): string { - return \PhpParser\Node\Expr\Ternary::class; + return Ternary::class; } public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php b/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php index 286cab20..ca8f631c 100644 --- a/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php +++ b/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php @@ -8,6 +8,8 @@ use PhpParser\Node\Stmt\For_; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; +use function is_string; +use function sprintf; /** * @implements Rule @@ -22,7 +24,6 @@ public function getNodeType(): string /** * @param For_ $node - * @param Scope $scope * @return string[] */ public function processNode(Node $node, Scope $scope): array @@ -42,8 +43,6 @@ public function processNode(Node $node, Scope $scope): array } /** - * @param Scope $scope - * @param Expr $expr * @return string[] */ private function checkValueVar(Scope $scope, Expr $expr): array diff --git a/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php b/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php index 2bb5ccb6..dbf16d25 100644 --- a/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php +++ b/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php @@ -4,8 +4,11 @@ use PhpParser\Node; use PhpParser\Node\Expr; +use PhpParser\Node\Stmt\Foreach_; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; +use function is_string; +use function sprintf; class OverwriteVariablesWithForeachRule implements Rule { @@ -16,8 +19,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Stmt\Foreach_ $node - * @param \PHPStan\Analyser\Scope $scope + * @param Foreach_ $node * @return string[] */ public function processNode(Node $node, Scope $scope): array @@ -39,8 +41,6 @@ public function processNode(Node $node, Scope $scope): array } /** - * @param Scope $scope - * @param Expr $expr * @return string[] */ private function checkValueVar(Scope $scope, Expr $expr): array diff --git a/src/Rules/Functions/ClosureUsesThisRule.php b/src/Rules/Functions/ClosureUsesThisRule.php index 60018f45..eab861db 100644 --- a/src/Rules/Functions/ClosureUsesThisRule.php +++ b/src/Rules/Functions/ClosureUsesThisRule.php @@ -7,6 +7,8 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\ThisType; +use function is_string; +use function sprintf; /** * @implements Rule diff --git a/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php b/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php index 76310a78..09388a2d 100644 --- a/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php +++ b/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php @@ -2,12 +2,16 @@ namespace PHPStan\Rules\Methods; +use PhpParser\Node; +use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassMethodNode; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; +use PHPStan\Rules\Rule; +use function sprintf; -class WrongCaseOfInheritedMethodRule implements \PHPStan\Rules\Rule +class WrongCaseOfInheritedMethodRule implements Rule { public function getNodeType(): string @@ -16,12 +20,11 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Stmt\ClassMethod $node - * @param \PHPStan\Analyser\Scope $scope + * @param ClassMethod $node * @return string[] */ public function processNode( - \PhpParser\Node $node, + Node $node, Scope $scope ): array { diff --git a/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php b/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php index 2822d19c..c11b6eaa 100644 --- a/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php @@ -2,8 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\PostDec; +use PhpParser\Node\Expr\PostInc; +use PhpParser\Node\Expr\PreDec; +use PhpParser\Node\Expr\PreInc; +use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; abstract class OperandInArithmeticIncrementOrDecrementRule implements Rule { @@ -17,11 +24,10 @@ public function __construct(OperatorRuleHelper $helper) } /** - * @param \PhpParser\Node\Expr\PreInc|\PhpParser\Node\Expr\PreDec|\PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node - * @param \PHPStan\Analyser\Scope $scope + * @param PreInc|PreDec|PostInc|PostDec $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $varType = $scope->getType($node->var); diff --git a/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php b/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php index 1bdaf989..d96763a0 100644 --- a/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php @@ -2,12 +2,14 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node\Expr\PostDec; + class OperandInArithmeticPostDecrementRule extends OperandInArithmeticIncrementOrDecrementRule { public function getNodeType(): string { - return \PhpParser\Node\Expr\PostDec::class; + return PostDec::class; } protected function describeOperation(): string diff --git a/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php b/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php index d1fe3f30..a4e15eec 100644 --- a/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php @@ -2,12 +2,14 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node\Expr\PostInc; + class OperandInArithmeticPostIncrementRule extends OperandInArithmeticIncrementOrDecrementRule { public function getNodeType(): string { - return \PhpParser\Node\Expr\PostInc::class; + return PostInc::class; } protected function describeOperation(): string diff --git a/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php b/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php index 74f67efb..e5da2efa 100644 --- a/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php @@ -2,12 +2,14 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node\Expr\PreDec; + class OperandInArithmeticPreDecrementRule extends OperandInArithmeticIncrementOrDecrementRule { public function getNodeType(): string { - return \PhpParser\Node\Expr\PreDec::class; + return PreDec::class; } protected function describeOperation(): string diff --git a/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php b/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php index dbb2cfa1..32fb2474 100644 --- a/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php @@ -2,12 +2,14 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node\Expr\PreInc; + class OperandInArithmeticPreIncrementRule extends OperandInArithmeticIncrementOrDecrementRule { public function getNodeType(): string { - return \PhpParser\Node\Expr\PreInc::class; + return PreInc::class; } protected function describeOperation(): string diff --git a/src/Rules/Operators/OperandsInArithmeticAdditionRule.php b/src/Rules/Operators/OperandsInArithmeticAdditionRule.php index e5ae9977..c0e5ca32 100644 --- a/src/Rules/Operators/OperandsInArithmeticAdditionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticAdditionRule.php @@ -2,11 +2,17 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Plus; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\ArrayType; use PHPStan\Type\MixedType; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticAdditionRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticAdditionRule implements Rule { /** @var OperatorRuleHelper */ @@ -19,15 +25,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Plus::class; + return Plus::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $leftType = $scope->getType($node->left); $rightType = $scope->getType($node->right); diff --git a/src/Rules/Operators/OperandsInArithmeticDivisionRule.php b/src/Rules/Operators/OperandsInArithmeticDivisionRule.php index 7c1a9fa7..43656eaa 100644 --- a/src/Rules/Operators/OperandsInArithmeticDivisionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticDivisionRule.php @@ -2,9 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Div; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticDivisionRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticDivisionRule implements Rule { /** @var OperatorRuleHelper */ @@ -17,15 +23,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Div::class; + return Div::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $leftType = $scope->getType($node->left); diff --git a/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php b/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php index 65ea2b41..59e55f14 100644 --- a/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php +++ b/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php @@ -2,9 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Pow; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticExponentiationRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticExponentiationRule implements Rule { /** @var OperatorRuleHelper */ @@ -17,15 +23,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Pow::class; + return Pow::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $leftType = $scope->getType($node->left); diff --git a/src/Rules/Operators/OperandsInArithmeticModuloRule.php b/src/Rules/Operators/OperandsInArithmeticModuloRule.php index 8f17353c..b89c8515 100644 --- a/src/Rules/Operators/OperandsInArithmeticModuloRule.php +++ b/src/Rules/Operators/OperandsInArithmeticModuloRule.php @@ -2,9 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Mod; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticModuloRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticModuloRule implements Rule { /** @var OperatorRuleHelper */ @@ -17,15 +23,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Mod::class; + return Mod::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $leftType = $scope->getType($node->left); diff --git a/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php b/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php index 46b0120b..c1e16ae8 100644 --- a/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php +++ b/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php @@ -2,9 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Mul; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticMultiplicationRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticMultiplicationRule implements Rule { /** @var OperatorRuleHelper */ @@ -17,15 +23,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Mul::class; + return Mul::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $leftType = $scope->getType($node->left); diff --git a/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php b/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php index 093876db..d5907ae5 100644 --- a/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php @@ -2,9 +2,15 @@ namespace PHPStan\Rules\Operators; +use PhpParser\Node; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Minus; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; -class OperandsInArithmeticSubtractionRule implements \PHPStan\Rules\Rule +class OperandsInArithmeticSubtractionRule implements Rule { /** @var OperatorRuleHelper */ @@ -17,15 +23,14 @@ public function __construct(OperatorRuleHelper $helper) public function getNodeType(): string { - return \PhpParser\Node\Expr\BinaryOp\Minus::class; + return Minus::class; } /** - * @param \PhpParser\Node\Expr\BinaryOp\BooleanAnd $node - * @param \PHPStan\Analyser\Scope $scope + * @param BooleanAnd $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $leftType = $scope->getType($node->left); diff --git a/src/Rules/Operators/OperatorRuleHelper.php b/src/Rules/Operators/OperatorRuleHelper.php index be071571..ca7b2349 100644 --- a/src/Rules/Operators/OperatorRuleHelper.php +++ b/src/Rules/Operators/OperatorRuleHelper.php @@ -6,6 +6,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\Accessory\AccessoryNumericStringType; +use PHPStan\Type\BenevolentUnionType; use PHPStan\Type\ErrorType; use PHPStan\Type\FloatType; use PHPStan\Type\IntegerType; @@ -18,7 +19,7 @@ class OperatorRuleHelper { - /** @var \PHPStan\Rules\RuleLevelHelper */ + /** @var RuleLevelHelper */ private $ruleLevelHelper; public function __construct(RuleLevelHelper $ruleLevelHelper) @@ -59,7 +60,7 @@ private function isSubtypeOfNumber(Scope $scope, Expr $expr): bool $scope, $expr, '', - function (Type $type) use ($acceptedType): bool { + static function (Type $type) use ($acceptedType): bool { return $acceptedType->isSuperTypeOf($type)->yes(); } )->getType(); @@ -69,7 +70,7 @@ function (Type $type) use ($acceptedType): bool { } $isSuperType = $acceptedType->isSuperTypeOf($type); - if ($type instanceof \PHPStan\Type\BenevolentUnionType) { + if ($type instanceof BenevolentUnionType) { return !$isSuperType->no(); } diff --git a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php index 6aefe622..95e27fec 100644 --- a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php +++ b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php @@ -5,17 +5,19 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\MethodCallableNode; +use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; +use function sprintf; /** - * @implements \PHPStan\Rules\Rule + * @implements Rule */ -class DynamicCallOnStaticMethodsCallableRule implements \PHPStan\Rules\Rule +class DynamicCallOnStaticMethodsCallableRule implements Rule { - /** @var \PHPStan\Rules\RuleLevelHelper */ + /** @var RuleLevelHelper */ private $ruleLevelHelper; public function __construct(RuleLevelHelper $ruleLevelHelper) @@ -39,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array $scope, $node->getVar(), '', - function (Type $type) use ($name): bool { + static function (Type $type) use ($name): bool { return $type->canCallMethods()->yes() && $type->hasMethod($name)->yes(); } )->getType(); diff --git a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php index 1ae402a1..c412cb2b 100644 --- a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php +++ b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php @@ -5,14 +5,16 @@ use PhpParser\Node; use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Type\ErrorType; use PHPStan\Type\Type; +use function sprintf; -class DynamicCallOnStaticMethodsRule implements \PHPStan\Rules\Rule +class DynamicCallOnStaticMethodsRule implements Rule { - /** @var \PHPStan\Rules\RuleLevelHelper */ + /** @var RuleLevelHelper */ private $ruleLevelHelper; public function __construct(RuleLevelHelper $ruleLevelHelper) @@ -26,8 +28,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\MethodCall $node - * @param \PHPStan\Analyser\Scope $scope + * @param MethodCall $node * @return string[] */ public function processNode(Node $node, Scope $scope): array @@ -41,7 +42,7 @@ public function processNode(Node $node, Scope $scope): array $scope, $node->var, '', - function (Type $type) use ($name): bool { + static function (Type $type) use ($name): bool { return $type->canCallMethods()->yes() && $type->hasMethod($name)->yes(); } )->getType(); diff --git a/src/Rules/StrictCalls/StrictFunctionCallsRule.php b/src/Rules/StrictCalls/StrictFunctionCallsRule.php index 1aeb900d..9a50e548 100644 --- a/src/Rules/StrictCalls/StrictFunctionCallsRule.php +++ b/src/Rules/StrictCalls/StrictFunctionCallsRule.php @@ -2,9 +2,18 @@ namespace PHPStan\Rules\StrictCalls; +use PhpParser\Node; +use PhpParser\Node\Expr\FuncCall; +use PhpParser\Node\Name; +use PHPStan\Analyser\Scope; +use PHPStan\Broker\Broker; +use PHPStan\Rules\Rule; use PHPStan\Type\Constant\ConstantBooleanType; +use function array_key_exists; +use function sprintf; +use function strtolower; -class StrictFunctionCallsRule implements \PHPStan\Rules\Rule +class StrictFunctionCallsRule implements Rule { /** @var int[] */ @@ -15,27 +24,26 @@ class StrictFunctionCallsRule implements \PHPStan\Rules\Rule 'array_keys' => 2, ]; - /** @var \PHPStan\Broker\Broker */ + /** @var Broker */ private $broker; - public function __construct(\PHPStan\Broker\Broker $broker) + public function __construct(Broker $broker) { $this->broker = $broker; } public function getNodeType(): string { - return \PhpParser\Node\Expr\FuncCall::class; + return FuncCall::class; } /** - * @param \PhpParser\Node\Expr\FuncCall $node - * @param \PHPStan\Analyser\Scope $scope + * @param FuncCall $node * @return string[] errors */ - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { - if (!$node->name instanceof \PhpParser\Node\Name) { + if (!$node->name instanceof Name) { return []; } diff --git a/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php b/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php index cdd61e82..bb4bebbf 100644 --- a/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php +++ b/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php @@ -2,29 +2,35 @@ namespace PHPStan\Rules\SwitchConditions; +use PhpParser\Node; +use PhpParser\Node\Stmt\Switch_; +use PhpParser\PrettyPrinter\Standard; +use PHPStan\Analyser\Scope; +use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\VerbosityLevel; +use function sprintf; /** - * @implements \PHPStan\Rules\Rule<\PhpParser\Node\Stmt\Switch_> + * @implements Rule */ -class MatchingTypeInSwitchCaseConditionRule implements \PHPStan\Rules\Rule +class MatchingTypeInSwitchCaseConditionRule implements Rule { - /** @var \PhpParser\PrettyPrinter\Standard */ + /** @var Standard */ private $printer; - public function __construct(\PhpParser\PrettyPrinter\Standard $printer) + public function __construct(Standard $printer) { $this->printer = $printer; } public function getNodeType(): string { - return \PhpParser\Node\Stmt\Switch_::class; + return Switch_::class; } - public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope): array + public function processNode(Node $node, Scope $scope): array { $messages = []; $conditionType = $scope->getType($node->cond); diff --git a/src/Rules/VariableVariables/VariableMethodCallRule.php b/src/Rules/VariableVariables/VariableMethodCallRule.php index 8733f15f..4221cfa8 100644 --- a/src/Rules/VariableVariables/VariableMethodCallRule.php +++ b/src/Rules/VariableVariables/VariableMethodCallRule.php @@ -3,9 +3,11 @@ namespace PHPStan\Rules\VariableVariables; use PhpParser\Node; +use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; class VariableMethodCallRule implements Rule { @@ -16,8 +18,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\MethodCall $node - * @param \PHPStan\Analyser\Scope $scope + * @param MethodCall $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/VariableVariables/VariableMethodCallableRule.php b/src/Rules/VariableVariables/VariableMethodCallableRule.php index 12e03563..f293b562 100644 --- a/src/Rules/VariableVariables/VariableMethodCallableRule.php +++ b/src/Rules/VariableVariables/VariableMethodCallableRule.php @@ -7,6 +7,7 @@ use PHPStan\Node\MethodCallableNode; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; /** * @implements Rule diff --git a/src/Rules/VariableVariables/VariablePropertyFetchRule.php b/src/Rules/VariableVariables/VariablePropertyFetchRule.php index d872c6a5..3195c16f 100644 --- a/src/Rules/VariableVariables/VariablePropertyFetchRule.php +++ b/src/Rules/VariableVariables/VariablePropertyFetchRule.php @@ -3,12 +3,14 @@ namespace PHPStan\Rules\VariableVariables; use PhpParser\Node; +use PhpParser\Node\Expr\PropertyFetch; use PHPStan\Analyser\Scope; use PHPStan\Broker\Broker; use PHPStan\Reflection\ClassReflection; use PHPStan\Rules\Rule; use PHPStan\Type\TypeUtils; use PHPStan\Type\VerbosityLevel; +use function sprintf; class VariablePropertyFetchRule implements Rule { @@ -20,7 +22,6 @@ class VariablePropertyFetchRule implements Rule private $universalObjectCratesClasses; /** - * @param Broker $broker * @param string[] $universalObjectCratesClasses */ public function __construct(Broker $broker, array $universalObjectCratesClasses) @@ -35,8 +36,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\PropertyFetch $node - * @param \PHPStan\Analyser\Scope $scope + * @param PropertyFetch $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/VariableVariables/VariableStaticMethodCallRule.php b/src/Rules/VariableVariables/VariableStaticMethodCallRule.php index 5887a4df..0d6b8202 100644 --- a/src/Rules/VariableVariables/VariableStaticMethodCallRule.php +++ b/src/Rules/VariableVariables/VariableStaticMethodCallRule.php @@ -3,9 +3,11 @@ namespace PHPStan\Rules\VariableVariables; use PhpParser\Node; +use PhpParser\Node\Expr\StaticCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; class VariableStaticMethodCallRule implements Rule { @@ -16,8 +18,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\StaticCall $node - * @param \PHPStan\Analyser\Scope $scope + * @param StaticCall $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php b/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php index 5ea5afe4..8ede1f00 100644 --- a/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php +++ b/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php @@ -7,6 +7,7 @@ use PHPStan\Node\StaticMethodCallableNode; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; /** * @implements Rule diff --git a/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php b/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php index 7e457f93..4b410a7f 100644 --- a/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php +++ b/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php @@ -3,9 +3,11 @@ namespace PHPStan\Rules\VariableVariables; use PhpParser\Node; +use PhpParser\Node\Expr\StaticPropertyFetch; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; use PHPStan\Type\VerbosityLevel; +use function sprintf; class VariableStaticPropertyFetchRule implements Rule { @@ -16,8 +18,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\StaticPropertyFetch $node - * @param \PHPStan\Analyser\Scope $scope + * @param StaticPropertyFetch $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/src/Rules/VariableVariables/VariableVariablesRule.php b/src/Rules/VariableVariables/VariableVariablesRule.php index b250742b..9768f21b 100644 --- a/src/Rules/VariableVariables/VariableVariablesRule.php +++ b/src/Rules/VariableVariables/VariableVariablesRule.php @@ -3,8 +3,10 @@ namespace PHPStan\Rules\VariableVariables; use PhpParser\Node; +use PhpParser\Node\Expr\Variable; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; +use function is_string; class VariableVariablesRule implements Rule { @@ -15,8 +17,7 @@ public function getNodeType(): string } /** - * @param \PhpParser\Node\Expr\Variable $node - * @param \PHPStan\Analyser\Scope $scope + * @param Variable $node * @return string[] */ public function processNode(Node $node, Scope $scope): array diff --git a/tests/Levels/LevelsIntegrationTest.php b/tests/Levels/LevelsIntegrationTest.php index e492ae8d..d1e57d7e 100644 --- a/tests/Levels/LevelsIntegrationTest.php +++ b/tests/Levels/LevelsIntegrationTest.php @@ -2,7 +2,9 @@ namespace PHPStan\Levels; -class LevelsIntegrationTest extends \PHPStan\Testing\LevelsTestCase +use PHPStan\Testing\LevelsTestCase; + +class LevelsIntegrationTest extends LevelsTestCase { /** diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php index 0c7a6f58..c9244204 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanAndRuleTest.php @@ -4,11 +4,12 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class BooleanInBooleanAndRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInBooleanAndRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php index eb887e7f..33dd205c 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanNotRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class BooleanInBooleanNotRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInBooleanNotRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php index bfecfd1f..1a4fafb0 100644 --- a/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInBooleanOrRuleTest.php @@ -4,11 +4,12 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class BooleanInBooleanOrRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInBooleanOrRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php index 880ca900..b2df79fc 100644 --- a/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInElseIfConditionRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class BooleanInElseIfConditionRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInElseIfConditionRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php index 1922a0d5..196af111 100644 --- a/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInIfConditionRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class BooleanInIfConditionRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInIfConditionRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php b/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php index 17c3fdd7..76bd4ad0 100644 --- a/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php +++ b/tests/Rules/BooleansInConditions/BooleanInTernaryOperatorRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class BooleanInTernaryOperatorRuleTest extends \PHPStan\Testing\RuleTestCase +class BooleanInTernaryOperatorRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Cast/UselessCastRuleTest.php b/tests/Rules/Cast/UselessCastRuleTest.php index 9d8bcf0a..92bf98cb 100644 --- a/tests/Rules/Cast/UselessCastRuleTest.php +++ b/tests/Rules/Cast/UselessCastRuleTest.php @@ -2,13 +2,16 @@ namespace PHPStan\Rules\Cast; -class UselessCastRuleTest extends \PHPStan\Testing\RuleTestCase +use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; + +class UselessCastRuleTest extends RuleTestCase { /** @var bool */ private $treatPhpDocTypesAsCertain; - protected function getRule(): \PHPStan\Rules\Rule + protected function getRule(): Rule { return new UselessCastRule($this->treatPhpDocTypesAsCertain); } diff --git a/tests/Rules/Classes/RequireParentConstructCallRuleTest.php b/tests/Rules/Classes/RequireParentConstructCallRuleTest.php index a390d998..caeee5c8 100644 --- a/tests/Rules/Classes/RequireParentConstructCallRuleTest.php +++ b/tests/Rules/Classes/RequireParentConstructCallRuleTest.php @@ -2,12 +2,14 @@ namespace PHPStan\Rules\Classes; +use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; use const PHP_VERSION_ID; -class RequireParentConstructCallRuleTest extends \PHPStan\Testing\RuleTestCase +class RequireParentConstructCallRuleTest extends RuleTestCase { - protected function getRule(): \PHPStan\Rules\Rule + protected function getRule(): Rule { return new RequireParentConstructCallRule(); } diff --git a/tests/Rules/DisallowedConstructs/DisallowedBacktickRuleTest.php b/tests/Rules/DisallowedConstructs/DisallowedBacktickRuleTest.php index 996f2c6e..1b697e0a 100644 --- a/tests/Rules/DisallowedConstructs/DisallowedBacktickRuleTest.php +++ b/tests/Rules/DisallowedConstructs/DisallowedBacktickRuleTest.php @@ -3,8 +3,9 @@ namespace PHPStan\Rules\DisallowedConstructs; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; -class DisallowedBacktickRuleTest extends \PHPStan\Testing\RuleTestCase +class DisallowedBacktickRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/DisallowedConstructs/DisallowedEmptyRuleTest.php b/tests/Rules/DisallowedConstructs/DisallowedEmptyRuleTest.php index 5b9e8188..5ffc7f67 100644 --- a/tests/Rules/DisallowedConstructs/DisallowedEmptyRuleTest.php +++ b/tests/Rules/DisallowedConstructs/DisallowedEmptyRuleTest.php @@ -3,8 +3,9 @@ namespace PHPStan\Rules\DisallowedConstructs; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; -class DisallowedEmptyRuleTest extends \PHPStan\Testing\RuleTestCase +class DisallowedEmptyRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRuleTest.php b/tests/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRuleTest.php index 7b446a82..6092a5f4 100644 --- a/tests/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRuleTest.php +++ b/tests/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRuleTest.php @@ -3,8 +3,9 @@ namespace PHPStan\Rules\DisallowedConstructs; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; -class DisallowedImplicitArrayCreationRuleTest extends \PHPStan\Testing\RuleTestCase +class DisallowedImplicitArrayCreationRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/DisallowedConstructs/DisallowedShortTernaryRuleTest.php b/tests/Rules/DisallowedConstructs/DisallowedShortTernaryRuleTest.php index 8d143c3b..3f3b944a 100644 --- a/tests/Rules/DisallowedConstructs/DisallowedShortTernaryRuleTest.php +++ b/tests/Rules/DisallowedConstructs/DisallowedShortTernaryRuleTest.php @@ -3,11 +3,12 @@ namespace PHPStan\Rules\DisallowedConstructs; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class DisallowedShortTernaryRuleTest extends \PHPStan\Testing\RuleTestCase +class DisallowedShortTernaryRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Methods/WrongCaseOfInheritedMethodRuleTest.php b/tests/Rules/Methods/WrongCaseOfInheritedMethodRuleTest.php index c120af9b..b2425faf 100644 --- a/tests/Rules/Methods/WrongCaseOfInheritedMethodRuleTest.php +++ b/tests/Rules/Methods/WrongCaseOfInheritedMethodRuleTest.php @@ -2,10 +2,13 @@ namespace PHPStan\Rules\Methods; -class WrongCaseOfInheritedMethodRuleTest extends \PHPStan\Testing\RuleTestCase +use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; + +class WrongCaseOfInheritedMethodRuleTest extends RuleTestCase { - protected function getRule(): \PHPStan\Rules\Rule + protected function getRule(): Rule { return new WrongCaseOfInheritedMethodRule(); } diff --git a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php index 4d041683..490ff939 100644 --- a/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php +++ b/tests/Rules/Operators/OperandInArithmeticIncrementOrDecrementRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -abstract class OperandInArithmeticIncrementOrDecrementRuleTest extends \PHPStan\Testing\RuleTestCase +abstract class OperandInArithmeticIncrementOrDecrementRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php index f163e537..95b92b39 100644 --- a/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticAdditionRuleTest.php @@ -4,9 +4,10 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; use const PHP_VERSION_ID; -class OperandsInArithmeticAdditionRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticAdditionRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php index ece89c07..4e2d3055 100644 --- a/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticDivisionRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class OperandsInArithmeticDivisionRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticDivisionRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php index dc7395c7..53b8d1b8 100644 --- a/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticExponentiationRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class OperandsInArithmeticExponentiationRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticExponentiationRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php index cbf12e7e..f8490466 100644 --- a/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticModuloRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class OperandsInArithmeticModuloRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticModuloRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php index 5d7ac620..c4b6f25b 100644 --- a/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticMultiplicationRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class OperandsInArithmeticMultiplicationRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticMultiplicationRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php index f62e0a28..f7643fd5 100644 --- a/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php +++ b/tests/Rules/Operators/OperandsInArithmeticSubtractionRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class OperandsInArithmeticSubtractionRuleTest extends \PHPStan\Testing\RuleTestCase +class OperandsInArithmeticSubtractionRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRuleTest.php b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRuleTest.php index e570adcf..53be1727 100644 --- a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRuleTest.php +++ b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRuleTest.php @@ -4,11 +4,13 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; +use const PHP_VERSION_ID; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class DynamicCallOnStaticMethodsCallableRuleTest extends \PHPStan\Testing\RuleTestCase +class DynamicCallOnStaticMethodsCallableRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php index f9b0a93b..a35919a2 100644 --- a/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php +++ b/tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php @@ -4,8 +4,9 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; +use PHPStan\Testing\RuleTestCase; -class DynamicCallOnStaticMethodsRuleTest extends \PHPStan\Testing\RuleTestCase +class DynamicCallOnStaticMethodsRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/StrictCalls/StrictFunctionCallsRuleTest.php b/tests/Rules/StrictCalls/StrictFunctionCallsRuleTest.php index 1a7d0f35..b1d34ba8 100644 --- a/tests/Rules/StrictCalls/StrictFunctionCallsRuleTest.php +++ b/tests/Rules/StrictCalls/StrictFunctionCallsRuleTest.php @@ -3,8 +3,9 @@ namespace PHPStan\Rules\StrictCalls; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; -class StrictFunctionCallsRuleTest extends \PHPStan\Testing\RuleTestCase +class StrictFunctionCallsRuleTest extends RuleTestCase { protected function getRule(): Rule diff --git a/tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php b/tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php index 40b61d0e..553cba5e 100644 --- a/tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php +++ b/tests/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRuleTest.php @@ -2,17 +2,19 @@ namespace PHPStan\Rules\SwitchConditions; +use PhpParser\PrettyPrinter\Standard; use PHPStan\Rules\Rule; +use PHPStan\Testing\RuleTestCase; /** - * @extends \PHPStan\Testing\RuleTestCase + * @extends RuleTestCase */ -class MatchingTypeInSwitchCaseConditionRuleTest extends \PHPStan\Testing\RuleTestCase +class MatchingTypeInSwitchCaseConditionRuleTest extends RuleTestCase { protected function getRule(): Rule { - return new MatchingTypeInSwitchCaseConditionRule(new \PhpParser\PrettyPrinter\Standard()); + return new MatchingTypeInSwitchCaseConditionRule(new Standard()); } public function testRule(): void diff --git a/tests/Rules/VariableVariables/VariableMethodCallableRuleTest.php b/tests/Rules/VariableVariables/VariableMethodCallableRuleTest.php index b1654ce3..8fc1e418 100644 --- a/tests/Rules/VariableVariables/VariableMethodCallableRuleTest.php +++ b/tests/Rules/VariableVariables/VariableMethodCallableRuleTest.php @@ -4,6 +4,7 @@ use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; +use const PHP_VERSION_ID; /** * @extends RuleTestCase