From 1950ded5571a5e2fc4cae31cf8f1d9d2adcf9520 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Mon, 4 May 2020 23:45:26 +0200 Subject: [PATCH] fixup! fixup! fixup! Add test case for #3222 --- .github/inactive_workflows/update_documentation.yaml | 1 - .../src/PhpDocInfo/PhpDocInfoFactory.php | 10 ++++++---- .../src/PhpDoc/NodeAnalyzer/DocBlockManipulator.php | 2 +- .../dead-code/src/Rector/Stmt/RemoveDeadStmtRector.php | 1 - .../src/Rector/Class_/SluggableBehaviorRector.php | 6 ++---- .../src/Rector/Class_/TranslationBehaviorRector.php | 1 - .../src/Rector/Assign/PHPStormVarAnnotationRector.php | 1 - .../FrameworkExtraBundle/TemplateAnnotationRector.php | 1 + .../Fixture/replace_in_args.php.inc | 3 +++ .../Class_/EventListenerToEventSubscriberRector.php | 1 - 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/inactive_workflows/update_documentation.yaml b/.github/inactive_workflows/update_documentation.yaml index 8b03023423ef..695d5bdf320a 100644 --- a/.github/inactive_workflows/update_documentation.yaml +++ b/.github/inactive_workflows/update_documentation.yaml @@ -1,6 +1,5 @@ name: Update Documentation - on: push: branches: diff --git a/packages/better-php-doc-parser/src/PhpDocInfo/PhpDocInfoFactory.php b/packages/better-php-doc-parser/src/PhpDocInfo/PhpDocInfoFactory.php index c075801bcbfd..b0e44607e273 100644 --- a/packages/better-php-doc-parser/src/PhpDocInfo/PhpDocInfoFactory.php +++ b/packages/better-php-doc-parser/src/PhpDocInfo/PhpDocInfoFactory.php @@ -86,7 +86,6 @@ public function createFromNode(Node $node): ?PhpDocInfo if ($node->getComments() !== []) { return null; } -// // create empty node $content = ''; $tokens = []; @@ -99,7 +98,6 @@ public function createFromNode(Node $node): ?PhpDocInfo } return $this->createFromPhpDocNode($phpDocNode, $content, $tokens, $node); - } public function createEmpty(Node $node): PhpDocInfo @@ -143,8 +141,12 @@ private function setPositionOfLastToken(AttributeAwarePhpDocNode $attributeAware } } - private function createFromPhpDocNode(AttributeAwarePhpDocNode $phpDocNode, string $content, array $tokens, Node $node): PhpDocInfo - { + private function createFromPhpDocNode( + AttributeAwarePhpDocNode $phpDocNode, + string $content, + array $tokens, + Node $node + ): PhpDocInfo { /** @var AttributeAwarePhpDocNode $phpDocNode */ $phpDocNode = $this->attributeAwareNodeFactory->createFromNode($phpDocNode, $content); diff --git a/packages/node-type-resolver/src/PhpDoc/NodeAnalyzer/DocBlockManipulator.php b/packages/node-type-resolver/src/PhpDoc/NodeAnalyzer/DocBlockManipulator.php index 151537896c50..d57042d138a8 100644 --- a/packages/node-type-resolver/src/PhpDoc/NodeAnalyzer/DocBlockManipulator.php +++ b/packages/node-type-resolver/src/PhpDoc/NodeAnalyzer/DocBlockManipulator.php @@ -99,7 +99,7 @@ public function updateNodeWithPhpDocInfo(Node $node): void if ($phpDoc === '') { if ($phpDocInfo->getOriginalPhpDocNode()->children !== []) { // all comments were removed → null -// $node->setAttribute('comments', null); + $node->setAttribute('comments', null); } return; diff --git a/rules/dead-code/src/Rector/Stmt/RemoveDeadStmtRector.php b/rules/dead-code/src/Rector/Stmt/RemoveDeadStmtRector.php index 1751b4a3b596..6c5105efc606 100644 --- a/rules/dead-code/src/Rector/Stmt/RemoveDeadStmtRector.php +++ b/rules/dead-code/src/Rector/Stmt/RemoveDeadStmtRector.php @@ -8,7 +8,6 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Nop; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\Core\Rector\AbstractRector; use Rector\Core\RectorDefinition\CodeSample; use Rector\Core\RectorDefinition\RectorDefinition; diff --git a/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/SluggableBehaviorRector.php b/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/SluggableBehaviorRector.php index 485bb49b506f..66f07b4134d3 100644 --- a/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/SluggableBehaviorRector.php +++ b/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/SluggableBehaviorRector.php @@ -12,7 +12,6 @@ use PHPStan\Type\ArrayType; use PHPStan\Type\MixedType; use PHPStan\Type\StringType; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocNode\Gedmo\SlugTagValueNode; use Rector\Core\PhpParser\Node\Manipulator\ClassInsertManipulator; use Rector\Core\Rector\AbstractRector; @@ -33,9 +32,8 @@ final class SluggableBehaviorRector extends AbstractRector */ private $classInsertManipulator; - public function __construct( - ClassInsertManipulator $classInsertManipulator - ) { + public function __construct(ClassInsertManipulator $classInsertManipulator) + { $this->classInsertManipulator = $classInsertManipulator; } diff --git a/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/TranslationBehaviorRector.php b/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/TranslationBehaviorRector.php index f5833e454a63..6f97a46735c0 100644 --- a/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/TranslationBehaviorRector.php +++ b/rules/doctrine-gedmo-to-knplabs/src/Rector/Class_/TranslationBehaviorRector.php @@ -9,7 +9,6 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Namespace_; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Class_\EntityTagValueNode; use Rector\BetterPhpDocParser\PhpDocNode\Gedmo\LocaleTagValueNode; use Rector\BetterPhpDocParser\PhpDocNode\Gedmo\TranslatableTagValueNode; diff --git a/rules/phpstan/src/Rector/Assign/PHPStormVarAnnotationRector.php b/rules/phpstan/src/Rector/Assign/PHPStormVarAnnotationRector.php index 032ba949af30..dcac45df0d3a 100644 --- a/rules/phpstan/src/Rector/Assign/PHPStormVarAnnotationRector.php +++ b/rules/phpstan/src/Rector/Assign/PHPStormVarAnnotationRector.php @@ -11,7 +11,6 @@ use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Nop; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\Core\Rector\AbstractRector; use Rector\Core\RectorDefinition\CodeSample; use Rector\Core\RectorDefinition\RectorDefinition; diff --git a/rules/sensio/src/Rector/FrameworkExtraBundle/TemplateAnnotationRector.php b/rules/sensio/src/Rector/FrameworkExtraBundle/TemplateAnnotationRector.php index 37a160e6a3f3..e36353fb79c1 100644 --- a/rules/sensio/src/Rector/FrameworkExtraBundle/TemplateAnnotationRector.php +++ b/rules/sensio/src/Rector/FrameworkExtraBundle/TemplateAnnotationRector.php @@ -128,6 +128,7 @@ private function replaceTemplateAnnotation(ClassMethod $classMethod): ?Node private function classHasTemplateAnnotations(Class_ $node): bool { foreach ($node->getMethods() as $classMethod) { + /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $classMethod->getAttribute(AttributeKey::PHP_DOC_INFO); if ($phpDocInfo === null) { continue; diff --git a/rules/solid/tests/Rector/ClassMethod/ChangeReadOnlyVariableWithDefaultValueToConstantRector/Fixture/replace_in_args.php.inc b/rules/solid/tests/Rector/ClassMethod/ChangeReadOnlyVariableWithDefaultValueToConstantRector/Fixture/replace_in_args.php.inc index f76cad5482ce..7f24272efc39 100644 --- a/rules/solid/tests/Rector/ClassMethod/ChangeReadOnlyVariableWithDefaultValueToConstantRector/Fixture/replace_in_args.php.inc +++ b/rules/solid/tests/Rector/ClassMethod/ChangeReadOnlyVariableWithDefaultValueToConstantRector/Fixture/replace_in_args.php.inc @@ -36,6 +36,9 @@ use Nette\Utils\Strings; class ReplaceInArgs { // this prevents miss matching like "aMethoda" + /** + * @var string[] + */ private const POSSIBLE_DELIMITERS = ['#', '~', '/']; public function isRegexPattern(string $name): bool { diff --git a/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php b/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php index 30e8fda94ab2..458d22d599bb 100644 --- a/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php +++ b/rules/symfony-code-quality/src/Rector/Class_/EventListenerToEventSubscriberRector.php @@ -19,7 +19,6 @@ use PhpParser\Node\Stmt\Return_; use PHPStan\Type\ArrayType; use PHPStan\Type\MixedType; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\Core\Rector\AbstractRector; use Rector\Core\RectorDefinition\CodeSample; use Rector\Core\RectorDefinition\RectorDefinition;