diff --git a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php index f2e12e8271e..6a86bf565e5 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php @@ -26,7 +26,6 @@ use Rector\BetterPhpDocParser\Annotation\AnnotationNaming; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode; use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder; -use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor; use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode; @@ -80,10 +79,6 @@ final class PhpDocInfo * @var \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode */ private $originalPhpDocNode; - /** - * @var bool - */ - private $hasChanged = \false; public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder) { $this->phpDocNode = $phpDocNode; @@ -341,26 +336,11 @@ final class PhpDocInfo * @deprecated Change doc block and print directly in the node instead * @internal * Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed - * Similar to missing original node in php-aprser + * + * @api */ public function markAsChanged() : void { - $this->hasChanged = \true; - } - public function hasChanged() : bool - { - if ($this->isNewNode()) { - return \true; - } - if ($this->hasChanged) { - return \true; - } - // has a single node with missing start_end - $phpDocNodeTraverser = new PhpDocNodeTraverser(); - $changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor(); - $phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor); - $phpDocNodeTraverser->traverse($this->phpDocNode); - return $changedPhpDocNodeVisitor->hasChanged(); } public function makeMultiLined() : void { diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php index e2ffd96f8e9..9b14d0b88b8 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php @@ -29,16 +29,17 @@ final class PhpDocClassRenamer * * @param string[] $oldToNewClasses */ - public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void + public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses, bool &$hasChanged) : bool { - $this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo); - $this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo); - $this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo); + $this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo, $hasChanged); + $this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo, $hasChanged); + $this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo, $hasChanged); + return $hasChanged; } /** * @param array $oldToNewClasses */ - private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void + private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo, bool &$hasChanged) : void { $assertChoiceDoctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice'); if (!$assertChoiceDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { @@ -66,24 +67,25 @@ final class PhpDocClassRenamer $classNameStringNode->value = $newClass; // trigger reprint $classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); + $hasChanged = \true; break; } } /** * @param array $oldToNewClasses */ - private function processDoctrineRelationTagValueNode(Node $node, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void + private function processDoctrineRelationTagValueNode(Node $node, array $oldToNewClasses, PhpDocInfo $phpDocInfo, bool &$hasChanged) : void { $doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']); if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { return; } - $this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses); + $this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses, $hasChanged); } /** * @param array $oldToNewClasses */ - private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void + private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo, bool &$hasChanged) : void { $doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('JMS\\Serializer\\Annotation\\Type'); if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) { @@ -99,6 +101,7 @@ final class PhpDocClassRenamer } $classNameStringNode->value = Strings::replace($classNameStringNode->value, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass); $classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); + $hasChanged = \true; } $currentTypeArrayItemNode = $doctrineAnnotationTagValueNode->getValue('type'); if (!$currentTypeArrayItemNode instanceof ArrayItemNode) { @@ -110,13 +113,14 @@ final class PhpDocClassRenamer } if ($currentTypeStringNode->value === $oldClass) { $currentTypeStringNode->value = $newClass; + $hasChanged = \true; } } } /** * @param array $oldToNewClasses */ - private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Node $node, array $oldToNewClasses) : void + private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Node $node, array $oldToNewClasses, bool &$hasChanged) : void { $classKey = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? 'class' : 'targetEntity'; $targetEntityArrayItemNode = $doctrineAnnotationTagValueNode->getValue($classKey); @@ -136,6 +140,7 @@ final class PhpDocClassRenamer } $targetEntityStringNode->value = $newClass; $targetEntityArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); + $hasChanged = \true; } } } diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php index c707462f3a3..92f2d2b763b 100644 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php +++ b/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php @@ -130,14 +130,14 @@ final class PhpDocTypeChanger $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike); return \true; } - public function changeParamType(FunctionLike $functionLike, PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : void + public function changeParamType(FunctionLike $functionLike, PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : bool { // better skip, could crash hard if ($phpDocInfo->hasInvalidTag('@param')) { - return; + return \false; } if (!$this->newPhpDocFromPHPStanTypeGuard->isLegal($newType)) { - return; + return \false; } $phpDocTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType); $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName); @@ -147,10 +147,10 @@ final class PhpDocTypeChanger $currentType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $param); // avoid overriding better type if ($this->typeComparator->isSubtype($currentType, $newType)) { - return; + return \false; } if ($this->typeComparator->areTypesEqual($currentType, $newType)) { - return; + return \false; } $paramTagValueNode->type = $phpDocTypeNode; } else { @@ -158,6 +158,7 @@ final class PhpDocTypeChanger $phpDocInfo->addTagValueNode($paramTagValueNode); } $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike); + return \true; } public function isAllowed(TypeNode $typeNode) : bool { diff --git a/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php b/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php deleted file mode 100644 index b184827ab43..00000000000 --- a/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php +++ /dev/null @@ -1,32 +0,0 @@ -phpDocInfoFactory = $phpDocInfoFactory; - } - public function renameParameterNameInDocBlock(ParamRename $paramRename) : void - { - $functionLike = $paramRename->getFunctionLike(); - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike); - $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramRename->getCurrentName()); - if (!$paramTagValueNode instanceof ParamTagValueNode) { - return; - } - $paramTagValueNode->parameterName = '$' . $paramRename->getExpectedName(); - $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); - } -} diff --git a/packages/Comments/NodeDocBlock/DocBlockUpdater.php b/packages/Comments/NodeDocBlock/DocBlockUpdater.php index 6d54646dde3..6cf4ccb1777 100644 --- a/packages/Comments/NodeDocBlock/DocBlockUpdater.php +++ b/packages/Comments/NodeDocBlock/DocBlockUpdater.php @@ -20,22 +20,6 @@ final class DocBlockUpdater { $this->phpDocInfoPrinter = $phpDocInfoPrinter; } - public function updateNodeWithPhpDocInfo(Node $node) : void - { - // nothing to change? don't save it - $phpDocInfo = $this->resolveChangedPhpDocInfo($node); - if (!$phpDocInfo instanceof PhpDocInfo) { - return; - } - $phpDoc = $this->printPhpDocInfoToString($phpDocInfo); - // make sure, that many separated comments are not removed - if ($phpDoc === '') { - $this->setCommentsAttribute($node); - return; - } - // this is needed to remove duplicated // commentsAsText - $node->setDocComment(new Doc($phpDoc)); - } public function updateRefactoredNodeWithPhpDocInfo(Node $node) : void { // nothing to change? don't save it @@ -58,17 +42,6 @@ final class DocBlockUpdater }); $node->setAttribute(AttributeKey::COMMENTS, $comments); } - private function resolveChangedPhpDocInfo(Node $node) : ?PhpDocInfo - { - $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); - if (!$phpDocInfo instanceof PhpDocInfo) { - return null; - } - if (!$phpDocInfo->hasChanged()) { - return null; - } - return $phpDocInfo; - } private function printPhpDocInfoToString(PhpDocInfo $phpDocInfo) : string { if ($phpDocInfo->isNewNode()) { diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php index 50aefa45858..67229408777 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockClassRenamer.php @@ -21,14 +21,15 @@ final class DocBlockClassRenamer /** * @param OldToNewType[] $oldToNewTypes */ - public function renamePhpDocType(PhpDocInfo $phpDocInfo, array $oldToNewTypes) : void + public function renamePhpDocType(PhpDocInfo $phpDocInfo, array $oldToNewTypes) : bool { if ($oldToNewTypes === []) { - return; + return \false; } $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->addPhpDocNodeVisitor($this->classRenamePhpDocNodeVisitor); $this->classRenamePhpDocNodeVisitor->setOldToNewTypes($oldToNewTypes); $phpDocNodeTraverser->traverse($phpDocInfo->getPhpDocNode()); + return $this->classRenamePhpDocNodeVisitor->hasChanged(); } } diff --git a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php index 96937d4948f..3e2b9369ac7 100644 --- a/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php +++ b/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php @@ -18,14 +18,15 @@ final class DocBlockNameImporter { $this->nameImportingPhpDocNodeVisitor = $nameImportingPhpDocNodeVisitor; } - public function importNames(PhpDocNode $phpDocNode, Node $node) : void + public function importNames(PhpDocNode $phpDocNode, Node $node) : bool { if ($phpDocNode->children === []) { - return; + return \false; } $this->nameImportingPhpDocNodeVisitor->setCurrentNode($node); $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->addPhpDocNodeVisitor($this->nameImportingPhpDocNodeVisitor); $phpDocNodeTraverser->traverse($phpDocNode); + return $this->nameImportingPhpDocNodeVisitor->hasChanged(); } } diff --git a/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php b/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php index 5b6d0e564b5..f9100f61313 100644 --- a/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php +++ b/packages/NodeTypeResolver/PhpDocNodeVisitor/ClassRenamePhpDocNodeVisitor.php @@ -45,6 +45,10 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor * @var OldToNewType[] */ private $oldToNewTypes = []; + /** + * @var bool + */ + private $hasChanged = \false; public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver) { $this->staticTypeMapper = $staticTypeMapper; @@ -56,6 +60,7 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor if ($this->oldToNewTypes === []) { throw new ShouldNotHappenException('Configure "$oldToNewClasses" first'); } + $this->hasChanged = \false; } public function enterNode(Node $node) : ?Node { @@ -91,6 +96,7 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor // mirror attributes $newTypeNode->setAttribute(PhpDocAttributeKey::PARENT, $parentType); } + $this->hasChanged = \true; return $newTypeNode; } return null; @@ -102,6 +108,10 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor { $this->oldToNewTypes = $oldToNewTypes; } + public function hasChanged() : bool + { + return $this->hasChanged; + } private function resolveNamespacedName(IdentifierTypeNode $identifierTypeNode, PhpParserNode $phpParserNode, string $name) : string { if (\strncmp($name, '\\', \strlen('\\')) === 0) { diff --git a/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php b/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php index 95166dc1793..45e5439f5f6 100644 --- a/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php +++ b/packages/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php @@ -54,6 +54,10 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor * @var PhpParserNode|null */ private $currentPhpParserNode; + /** + * @var bool + */ + private $hasChanged = \false; public function __construct(ClassNameImportSkipper $classNameImportSkipper, UseNodesToAddCollector $useNodesToAddCollector, CurrentFileProvider $currentFileProvider, ReflectionProvider $reflectionProvider, IdentifierTypeMapper $identifierTypeMapper) { $this->classNameImportSkipper = $classNameImportSkipper; @@ -99,8 +103,13 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor } public function setCurrentNode(PhpParserNode $phpParserNode) : void { + $this->hasChanged = \false; $this->currentPhpParserNode = $phpParserNode; } + public function hasChanged() : bool + { + return $this->hasChanged; + } private function processFqnNameImport(PhpParserNode $phpParserNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType, File $file) : ?IdentifierTypeNode { $parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT); @@ -108,6 +117,7 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor // might break return null; } + // standardize to FQN if (\strncmp($fullyQualifiedObjectType->getClassName(), '@', \strlen('@')) === 0) { $fullyQualifiedObjectType = new FullyQualifiedObjectType(\ltrim($fullyQualifiedObjectType->getClassName(), '@')); } @@ -121,6 +131,7 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor } if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) { $this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType); + $this->hasChanged = \true; return $newNode; } return null; diff --git a/packages/PostRector/Rector/NameImportingPostRector.php b/packages/PostRector/Rector/NameImportingPostRector.php index 3a262c99733..05d6d55126e 100644 --- a/packages/PostRector/Rector/NameImportingPostRector.php +++ b/packages/PostRector/Rector/NameImportingPostRector.php @@ -14,9 +14,11 @@ use PhpParser\Node\Stmt\InlineHTML; use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Use_; use PHPStan\Reflection\ReflectionProvider; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper; use Rector\CodingStyle\Node\NameImporter; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Parameter\SimpleParameterProvider; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; @@ -68,7 +70,12 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo * @var \Rector\Naming\Naming\AliasNameResolver */ private $aliasNameResolver; - public function __construct(NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, PhpDocInfoFactory $phpDocInfoFactory, ReflectionProvider $reflectionProvider, CurrentFileProvider $currentFileProvider, UseImportsResolver $useImportsResolver, AliasNameResolver $aliasNameResolver) + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; + public function __construct(NameImporter $nameImporter, DocBlockNameImporter $docBlockNameImporter, ClassNameImportSkipper $classNameImportSkipper, PhpDocInfoFactory $phpDocInfoFactory, ReflectionProvider $reflectionProvider, CurrentFileProvider $currentFileProvider, UseImportsResolver $useImportsResolver, AliasNameResolver $aliasNameResolver, DocBlockUpdater $docBlockUpdater) { $this->nameImporter = $nameImporter; $this->docBlockNameImporter = $docBlockNameImporter; @@ -78,6 +85,7 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo $this->currentFileProvider = $currentFileProvider; $this->useImportsResolver = $useImportsResolver; $this->aliasNameResolver = $aliasNameResolver; + $this->docBlockUpdater = $docBlockUpdater; } public function enterNode(Node $node) : ?Node { @@ -88,19 +96,30 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo if (!$file instanceof File) { return null; } - $currentStmt = \current($file->getNewStmts()); - if ($currentStmt instanceof FileWithoutNamespace && \current($currentStmt->stmts) instanceof InlineHTML) { + $firstStmt = \current($file->getNewStmts()); + if ($firstStmt instanceof FileWithoutNamespace && \current($firstStmt->stmts) instanceof InlineHTML) { return null; } if ($node instanceof Name) { return $this->processNodeName($node, $file); } - if (($node instanceof Stmt || $node instanceof Param) && SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES)) { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $this->docBlockNameImporter->importNames($phpDocInfo->getPhpDocNode(), $node); - return $node; + if (!$node instanceof Stmt && !$node instanceof Param) { + return null; } - return null; + $shouldImportDocBlocks = SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES); + if (!$shouldImportDocBlocks) { + return null; + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); + if (!$phpDocInfo instanceof PhpDocInfo) { + return null; + } + $hasDocChanged = $this->docBlockNameImporter->importNames($phpDocInfo->getPhpDocNode(), $node); + if (!$hasDocChanged) { + return null; + } + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return $node; } private function processNodeName(Name $name, File $file) : ?Node { diff --git a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php index 43a907b4223..586c34d8335 100644 --- a/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php +++ b/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php @@ -131,12 +131,9 @@ CODE_SAMPLE if ($this->hasNoComment($comments)) { return $rangeLine; } - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($nextStmt); - if ($phpDocInfo->hasChanged()) { - return $rangeLine; - } /** @var Comment[] $comments */ - $line = $comments[0]->getStartLine(); + $firstComment = $comments[0]; + $line = $firstComment->getStartLine(); return $line - $endLine; } /** @@ -144,10 +141,7 @@ CODE_SAMPLE */ private function hasNoComment(?array $comments) : bool { - if ($comments === null) { - return \true; - } - return !isset($comments[0]); + return $comments === null || $comments === []; } private function shouldSkip(Stmt $stmt) : bool { diff --git a/rules/Naming/ParamRenamer/ParamRenamer.php b/rules/Naming/ParamRenamer/ParamRenamer.php index 58a29770318..e62f1bf7e09 100644 --- a/rules/Naming/ParamRenamer/ParamRenamer.php +++ b/rules/Naming/ParamRenamer/ParamRenamer.php @@ -3,7 +3,11 @@ declare (strict_types=1); namespace Rector\Naming\ParamRenamer; -use Rector\BetterPhpDocParser\PhpDocManipulator\PropertyDocBlockManipulator; +use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; +use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Naming\ValueObject\ParamRename; use Rector\Naming\VariableRenamer; final class ParamRenamer @@ -15,13 +19,19 @@ final class ParamRenamer private $variableRenamer; /** * @readonly - * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PropertyDocBlockManipulator + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater */ - private $propertyDocBlockManipulator; - public function __construct(VariableRenamer $variableRenamer, PropertyDocBlockManipulator $propertyDocBlockManipulator) + private $docBlockUpdater; + /** + * @readonly + * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory + */ + private $phpDocInfoFactory; + public function __construct(VariableRenamer $variableRenamer, DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory) { $this->variableRenamer = $variableRenamer; - $this->propertyDocBlockManipulator = $propertyDocBlockManipulator; + $this->docBlockUpdater = $docBlockUpdater; + $this->phpDocInfoFactory = $phpDocInfoFactory; } public function rename(ParamRename $paramRename) : void { @@ -30,6 +40,21 @@ final class ParamRenamer // 2. rename param in the rest of the method $this->variableRenamer->renameVariableInFunctionLike($paramRename->getFunctionLike(), $paramRename->getCurrentName(), $paramRename->getExpectedName(), null); // 3. rename @param variable in docblock too - $this->propertyDocBlockManipulator->renameParameterNameInDocBlock($paramRename); + $this->renameParameterNameInDocBlock($paramRename); + } + private function renameParameterNameInDocBlock(ParamRename $paramRename) : void + { + $functionLike = $paramRename->getFunctionLike(); + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($functionLike); + if (!$phpDocInfo instanceof PhpDocInfo) { + return; + } + $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramRename->getCurrentName()); + if (!$paramTagValueNode instanceof ParamTagValueNode) { + return; + } + $paramTagValueNode->parameterName = '$' . $paramRename->getExpectedName(); + $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike); } } diff --git a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php index 7c94e6d0605..1c7512cd020 100644 --- a/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php @@ -13,6 +13,7 @@ use PhpParser\Node\Stmt\Interface_; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Php\PhpVersionProvider; use Rector\Core\ValueObject\MethodName; use Rector\Core\ValueObject\PhpVersionFeature; @@ -64,7 +65,12 @@ final class PropertyPromotionRenamer * @var \Rector\Naming\VariableRenamer */ private $variableRenamer; - public function __construct(PhpVersionProvider $phpVersionProvider, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, ParamRenameFactory $paramRenameFactory, PhpDocInfoFactory $phpDocInfoFactory, ParamRenamer $paramRenamer, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer, NodeNameResolver $nodeNameResolver, VariableRenamer $variableRenamer) + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; + public function __construct(PhpVersionProvider $phpVersionProvider, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, ParamRenameFactory $paramRenameFactory, PhpDocInfoFactory $phpDocInfoFactory, ParamRenamer $paramRenamer, \Rector\Naming\PropertyRenamer\PropertyFetchRenamer $propertyFetchRenamer, NodeNameResolver $nodeNameResolver, VariableRenamer $variableRenamer, DocBlockUpdater $docBlockUpdater) { $this->phpVersionProvider = $phpVersionProvider; $this->matchParamTypeExpectedNameResolver = $matchParamTypeExpectedNameResolver; @@ -74,6 +80,7 @@ final class PropertyPromotionRenamer $this->propertyFetchRenamer = $propertyFetchRenamer; $this->nodeNameResolver = $nodeNameResolver; $this->variableRenamer = $variableRenamer; + $this->docBlockUpdater = $docBlockUpdater; } /** * @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classLike @@ -125,7 +132,7 @@ final class PropertyPromotionRenamer $param->var = new Variable($desiredPropertyName); $this->variableRenamer->renameVariableInFunctionLike($classMethod, $paramVarName, $desiredPropertyName); } - private function renameParamDoc(PhpDocInfo $phpDocInfo, ClassMethod $classMethod, Param $param, string $paramVarName, string $desiredPropertyName) : void + public function renameParamDoc(PhpDocInfo $phpDocInfo, ClassMethod $classMethod, Param $param, string $paramVarName, string $desiredPropertyName) : void { $paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramVarName); if (!$paramTagValueNode instanceof ParamTagValueNode) { @@ -136,6 +143,7 @@ final class PropertyPromotionRenamer return; } $this->paramRenamer->rename($paramRename); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($classMethod); } /** * Sometimes the bare type is not enough. diff --git a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php index d9a8ba7ee72..ff90339bff2 100644 --- a/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php +++ b/rules/Naming/Rector/Assign/RenameVariableToMatchMethodCallReturnTypeRector.php @@ -10,6 +10,8 @@ use PhpParser\Node\Expr\Closure; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Function_; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Rector\AbstractRector; use Rector\Naming\Guard\BreakingVariableRenameGuard; use Rector\Naming\Matcher\VariableAndCallAssignMatcher; @@ -55,12 +57,17 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRect * @var \Rector\Naming\VariableRenamer */ private $variableRenamer; + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; /** * @var string * @see https://regex101.com/r/JG5w9j/1 */ private const OR_BETWEEN_WORDS_REGEX = '#[a-z]Or[A-Z]#'; - public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, NamingConventionAnalyzer $namingConventionAnalyzer, VarTagValueNodeRenamer $varTagValueNodeRenamer, VariableAndCallAssignMatcher $variableAndCallAssignMatcher, VariableRenamer $variableRenamer) + public function __construct(BreakingVariableRenameGuard $breakingVariableRenameGuard, ExpectedNameResolver $expectedNameResolver, NamingConventionAnalyzer $namingConventionAnalyzer, VarTagValueNodeRenamer $varTagValueNodeRenamer, VariableAndCallAssignMatcher $variableAndCallAssignMatcher, VariableRenamer $variableRenamer, DocBlockUpdater $docBlockUpdater) { $this->breakingVariableRenameGuard = $breakingVariableRenameGuard; $this->expectedNameResolver = $expectedNameResolver; @@ -68,6 +75,7 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRect $this->varTagValueNodeRenamer = $varTagValueNodeRenamer; $this->variableAndCallAssignMatcher = $variableAndCallAssignMatcher; $this->variableRenamer = $variableRenamer; + $this->docBlockUpdater = $docBlockUpdater; } public function getRuleDefinition() : RuleDefinition { @@ -139,7 +147,7 @@ CODE_SAMPLE if ($this->shouldSkip($variableAndCallAssign, $expectedName)) { continue; } - $this->renameVariable($variableAndCallAssign, $expectedName); + $this->renameVariable($variableAndCallAssign, $expectedName, $stmt); return $node; } return null; @@ -155,11 +163,14 @@ CODE_SAMPLE } return $this->breakingVariableRenameGuard->shouldSkipVariable($variableAndCallAssign->getVariableName(), $expectedName, $variableAndCallAssign->getFunctionLike(), $variableAndCallAssign->getVariable()); } - private function renameVariable(VariableAndCallAssign $variableAndCallAssign, string $expectedName) : void + private function renameVariable(VariableAndCallAssign $variableAndCallAssign, string $expectedName, Expression $expression) : void { - $assign = $variableAndCallAssign->getAssign(); - $assignPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($assign); - $this->varTagValueNodeRenamer->renameAssignVarTagVariableName($assignPhpDocInfo, $variableAndCallAssign->getVariableName(), $expectedName); $this->variableRenamer->renameVariableInFunctionLike($variableAndCallAssign->getFunctionLike(), $variableAndCallAssign->getVariableName(), $expectedName, $variableAndCallAssign->getAssign()); + $assignPhpDocInfo = $this->phpDocInfoFactory->createFromNode($expression); + if (!$assignPhpDocInfo instanceof PhpDocInfo) { + return; + } + $this->varTagValueNodeRenamer->renameAssignVarTagVariableName($assignPhpDocInfo, $variableAndCallAssign->getVariableName(), $expectedName); + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($expression); } } diff --git a/rules/Php80/DocBlock/PropertyPromotionDocBlockMerger.php b/rules/Php80/DocBlock/PropertyPromotionDocBlockMerger.php index 7a22a637d53..3f82ff6b318 100644 --- a/rules/Php80/DocBlock/PropertyPromotionDocBlockMerger.php +++ b/rules/Php80/DocBlock/PropertyPromotionDocBlockMerger.php @@ -12,6 +12,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\StaticTypeMapper\StaticTypeMapper; @@ -42,13 +43,19 @@ final class PropertyPromotionDocBlockMerger * @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter */ private $phpDocInfoPrinter; - public function __construct(PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, PhpDocTypeChanger $phpDocTypeChanger, VarTagRemover $varTagRemover, PhpDocInfoPrinter $phpDocInfoPrinter) + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; + public function __construct(PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, PhpDocTypeChanger $phpDocTypeChanger, VarTagRemover $varTagRemover, PhpDocInfoPrinter $phpDocInfoPrinter, DocBlockUpdater $docBlockUpdater) { $this->phpDocInfoFactory = $phpDocInfoFactory; $this->staticTypeMapper = $staticTypeMapper; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->varTagRemover = $varTagRemover; $this->phpDocInfoPrinter = $phpDocInfoPrinter; + $this->docBlockUpdater = $docBlockUpdater; } public function mergePropertyAndParamDocBlocks(Property $property, Param $param, ?ParamTagValueNode $paramTagValueNode) : void { @@ -65,6 +72,7 @@ final class PropertyPromotionDocBlockMerger $param->setAttribute(AttributeKey::COMMENTS, $mergedComments); } } + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($param); } public function decorateParamWithPropertyPhpDocInfo(ClassMethod $classMethod, Property $property, Param $param, string $paramName) : void { diff --git a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php index 7b3bcba1f69..72142c15a57 100644 --- a/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php +++ b/rules/Php80/Rector/Class_/ClassPropertyAssignToConstructorPromotionRector.php @@ -24,6 +24,7 @@ use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\ValueObject\MethodName; use Rector\Core\ValueObject\PhpVersionFeature; +use Rector\Naming\PropertyRenamer\PropertyPromotionRenamer; use Rector\Naming\VariableRenamer; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; @@ -76,6 +77,11 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect * @var \Rector\Core\Reflection\ReflectionResolver */ private $reflectionResolver; + /** + * @readonly + * @var \Rector\Naming\PropertyRenamer\PropertyPromotionRenamer + */ + private $propertyPromotionRenamer; /** * @api * @var string @@ -91,7 +97,7 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect * @var bool */ private $inlinePublic = \false; - public function __construct(PromotedPropertyCandidateResolver $promotedPropertyCandidateResolver, VariableRenamer $variableRenamer, ParamAnalyzer $paramAnalyzer, PropertyPromotionDocBlockMerger $propertyPromotionDocBlockMerger, MakePropertyPromotionGuard $makePropertyPromotionGuard, TypeComparator $typeComparator, ReflectionResolver $reflectionResolver) + public function __construct(PromotedPropertyCandidateResolver $promotedPropertyCandidateResolver, VariableRenamer $variableRenamer, ParamAnalyzer $paramAnalyzer, PropertyPromotionDocBlockMerger $propertyPromotionDocBlockMerger, MakePropertyPromotionGuard $makePropertyPromotionGuard, TypeComparator $typeComparator, ReflectionResolver $reflectionResolver, PropertyPromotionRenamer $propertyPromotionRenamer) { $this->promotedPropertyCandidateResolver = $promotedPropertyCandidateResolver; $this->variableRenamer = $variableRenamer; @@ -100,6 +106,7 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect $this->makePropertyPromotionGuard = $makePropertyPromotionGuard; $this->typeComparator = $typeComparator; $this->reflectionResolver = $reflectionResolver; + $this->propertyPromotionRenamer = $propertyPromotionRenamer; } public function getRuleDefinition() : RuleDefinition { @@ -180,8 +187,7 @@ CODE_SAMPLE if (!$paramTagValueNode instanceof ParamTagValueNode) { $this->propertyPromotionDocBlockMerger->decorateParamWithPropertyPhpDocInfo($constructClassMethod, $property, $param, $paramName); } elseif ($paramTagValueNode->parameterName !== '$' . $propertyName) { - $paramTagValueNode->parameterName = '$' . $propertyName; - $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); + $this->propertyPromotionRenamer->renameParamDoc($constructorPhpDocInfo, $constructClassMethod, $param, $paramTagValueNode->parameterName, $propertyName); } // property name has higher priority $paramName = $this->getName($property); diff --git a/rules/Renaming/NodeManipulator/ClassRenamer.php b/rules/Renaming/NodeManipulator/ClassRenamer.php index 5915d6f723a..1dc89564459 100644 --- a/rules/Renaming/NodeManipulator/ClassRenamer.php +++ b/rules/Renaming/NodeManipulator/ClassRenamer.php @@ -20,6 +20,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocClassRenamer; use Rector\BetterPhpDocParser\ValueObject\NodeTypes; use Rector\CodingStyle\Naming\ClassNaming; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\PhpParser\Node\BetterNodeFinder; use Rector\Core\Util\FileHasher; use Rector\NodeNameResolver\NodeNameResolver; @@ -75,6 +76,11 @@ final class ClassRenamer * @var \Rector\Core\Util\FileHasher */ private $fileHasher; + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; /** * @var string[] */ @@ -83,7 +89,7 @@ final class ClassRenamer * @var array */ private $oldToNewTypesByCacheKey = []; - public function __construct(BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassNaming $classNaming, NodeNameResolver $nodeNameResolver, PhpDocClassRenamer $phpDocClassRenamer, PhpDocInfoFactory $phpDocInfoFactory, DocBlockClassRenamer $docBlockClassRenamer, ReflectionProvider $reflectionProvider, FileHasher $fileHasher) + public function __construct(BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassNaming $classNaming, NodeNameResolver $nodeNameResolver, PhpDocClassRenamer $phpDocClassRenamer, PhpDocInfoFactory $phpDocInfoFactory, DocBlockClassRenamer $docBlockClassRenamer, ReflectionProvider $reflectionProvider, FileHasher $fileHasher, DocBlockUpdater $docBlockUpdater) { $this->betterNodeFinder = $betterNodeFinder; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; @@ -94,6 +100,7 @@ final class ClassRenamer $this->docBlockClassRenamer = $docBlockClassRenamer; $this->reflectionProvider = $reflectionProvider; $this->fileHasher = $fileHasher; + $this->docBlockUpdater = $docBlockUpdater; } /** * @param array $oldToNewClasses @@ -104,33 +111,40 @@ final class ClassRenamer if ($node instanceof Name) { return $this->refactorName($node, $oldToNewClasses); } - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - $this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses, $phpDocInfo); + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); + if ($phpDocInfo instanceof PhpDocInfo) { + $hasPhpDocChanged = $this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses, $phpDocInfo); + if ($hasPhpDocChanged) { + return $node; + } + } if ($node instanceof Namespace_) { return $this->refactorNamespace($node, $oldToNewClasses); } if ($node instanceof ClassLike) { return $this->refactorClassLike($node, $oldToNewClasses, $scope); } - if ($phpDocInfo->hasChanged()) { - return $node; - } return null; } /** * @param OldToNewType[] $oldToNewTypes * @param array $oldToNewClasses */ - private function refactorPhpDoc(Node $node, array $oldToNewTypes, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void + private function refactorPhpDoc(Node $node, array $oldToNewTypes, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : bool { if (!$phpDocInfo->hasByTypes(NodeTypes::TYPE_AWARE_NODES) && !$phpDocInfo->hasByAnnotationClasses(NodeTypes::TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES)) { - return; + return \false; } if ($node instanceof AttributeGroup) { - return; + return \false; } - $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes); - $this->phpDocClassRenamer->changeTypeInAnnotationTypes($node, $phpDocInfo, $oldToNewClasses); + $hasChanged = $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes); + $hasChanged = $this->phpDocClassRenamer->changeTypeInAnnotationTypes($node, $phpDocInfo, $oldToNewClasses, $hasChanged); + if ($hasChanged) { + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); + return \true; + } + return \false; } private function shouldSkip(string $newName, Name $name) : bool { diff --git a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php index 1ed8badd327..4fbbea7bf17 100644 --- a/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php +++ b/rules/Renaming/Rector/ClassMethod/RenameAnnotationRector.php @@ -8,6 +8,8 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Property; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; +use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Contract\Rector\ConfigurableRectorInterface; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer; @@ -26,13 +28,19 @@ final class RenameAnnotationRector extends AbstractRector implements Configurabl * @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer */ private $docBlockTagReplacer; + /** + * @readonly + * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater + */ + private $docBlockUpdater; /** * @var RenameAnnotationInterface[] */ private $renameAnnotations = []; - public function __construct(DocBlockTagReplacer $docBlockTagReplacer) + public function __construct(DocBlockTagReplacer $docBlockTagReplacer, DocBlockUpdater $docBlockUpdater) { $this->docBlockTagReplacer = $docBlockTagReplacer; + $this->docBlockUpdater = $docBlockUpdater; } public function getRuleDefinition() : RuleDefinition { @@ -76,31 +84,25 @@ CODE_SAMPLE */ public function refactor(Node $node) : ?Node { - $hasChanged = \false; if ($node instanceof Expression) { - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); - foreach ($this->renameAnnotations as $renameAnnotation) { - $hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation()); - if ($hasDocBlockChanged) { - $hasChanged = \true; - } - } - if ($hasChanged) { - return $node; - } - return null; + return $this->refactorExpression($node); } + $hasChanged = \false; foreach ($node->stmts as $stmt) { if (!$stmt instanceof ClassMethod && !$stmt instanceof Property) { continue; } - $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($stmt); + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($stmt); + if (!$phpDocInfo instanceof PhpDocInfo) { + continue; + } foreach ($this->renameAnnotations as $renameAnnotation) { if ($renameAnnotation instanceof RenameAnnotationByType && !$this->isObjectType($node, $renameAnnotation->getObjectType())) { continue; } $hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation()); if ($hasDocBlockChanged) { + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($stmt); $hasChanged = \true; } } @@ -118,4 +120,20 @@ CODE_SAMPLE Assert::allIsAOf($configuration, RenameAnnotationInterface::class); $this->renameAnnotations = $configuration; } + private function refactorExpression(Expression $expression) : ?Expression + { + $hasChanged = \false; + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($expression); + foreach ($this->renameAnnotations as $renameAnnotation) { + $hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation()); + if ($hasDocBlockChanged) { + $hasChanged = \true; + } + } + if ($hasChanged) { + $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($expression); + return $expression; + } + return null; + } } diff --git a/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php b/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php index 8f8c8b84ad1..41bda5c0507 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/AddParamTypeSplFixedArrayRector.php @@ -77,6 +77,7 @@ CODE_SAMPLE return null; } $functionLikePhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); + $hasChanged = \false; foreach ($node->getParams() as $param) { if ($param->type === null) { continue; @@ -96,9 +97,12 @@ CODE_SAMPLE continue; } $paramName = $this->getName($param); - $this->phpDocTypeChanger->changeParamType($node, $functionLikePhpDocInfo, $genericParamType, $param, $paramName); + $changedParamType = $this->phpDocTypeChanger->changeParamType($node, $functionLikePhpDocInfo, $genericParamType, $param, $paramName); + if ($changedParamType) { + $hasChanged = \true; + } } - if ($functionLikePhpDocInfo->hasChanged()) { + if ($hasChanged) { return $node; } return null; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 93a6fdc3e1b..0836926aa4f 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '596bbc98a25903c525914b4d16ea5f9c76b500fb'; + public const PACKAGE_VERSION = 'a2f70054a7d976acd2c73b06789095b998829be6'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-09-11 20:30:55'; + public const RELEASE_DATE = '2023-09-12 04:28:02'; /** * @var int */ diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index cd62fa33204..d531569c27b 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -19,7 +19,6 @@ use PhpParser\Node\Scalar\DNumber; use PhpParser\Node\Scalar\EncapsedStringPart; use PhpParser\Node\Scalar\LNumber; use PhpParser\Node\Scalar\String_; -use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Declare_; @@ -27,7 +26,6 @@ use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Use_; use PhpParser\PrettyPrinter\Standard; use PHPStan\Node\Expr\AlwaysRememberedExpr; -use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Parameter\SimpleParameterProvider; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; @@ -39,11 +37,6 @@ use Rector\NodeTypeResolver\Node\AttributeKey; */ final class BetterStandardPrinter extends Standard { - /** - * @readonly - * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater - */ - private $docBlockUpdater; /** * @var string * @see https://regex101.com/r/DrsMY4/1 @@ -60,9 +53,8 @@ final class BetterStandardPrinter extends Standard * @var string */ private const REPLACE_COLON_WITH_SPACE_REGEX = '#(^.*function .*\\(.*\\)) : #'; - public function __construct(DocBlockUpdater $docBlockUpdater) + public function __construct() { - $this->docBlockUpdater = $docBlockUpdater; parent::__construct(['shortArraySyntax' => \true]); // print return type double colon right after the bracket "function(): string" $this->initializeInsertionMap(); @@ -187,7 +179,6 @@ final class BetterStandardPrinter extends Standard { // reindex positions for printer $nodes = \array_values($nodes); - $this->moveCommentsFromAttributeObjectToCommentsAttribute($nodes); $content = parent::pArray($nodes, $origNodes, $pos, $indentAdjustment, $parentNodeType, $subNodeName, $fixup); if ($content === null) { return $content; @@ -406,19 +397,6 @@ final class BetterStandardPrinter extends Standard } return $stmts; } - /** - * @param array $nodes - */ - private function moveCommentsFromAttributeObjectToCommentsAttribute(array $nodes) : void - { - // move phpdoc from node to "comment" attribute - foreach ($nodes as $node) { - if (!$node instanceof Stmt && !$node instanceof Param) { - continue; - } - $this->docBlockUpdater->updateNodeWithPhpDocInfo($node); - } - } /** * @param Node[] $nodes */ diff --git a/vendor/autoload.php b/vendor/autoload.php index edc2cf2ea89..eb81e5567e6 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433::getLoader(); +return ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 2d4ef068da0..2f7f4f21d0e 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -951,7 +951,6 @@ return array( 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocClassRenamer' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php', 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php', 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTypeChanger' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php', - 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PropertyDocBlockManipulator' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeFinder\\PhpDocNodeByTypeFinder' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 8a4fab06038..ab9552416ce 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433 +class ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitc2db957c3ce342c948d5b630218dd433::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 044261edc96..40937b56390 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitc2db957c3ce342c948d5b630218dd433 +class ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -1171,7 +1171,6 @@ class ComposerStaticInitc2db957c3ce342c948d5b630218dd433 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocClassRenamer' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php', 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php', 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTypeChanger' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php', - 'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PropertyDocBlockManipulator' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PropertyDocBlockManipulator.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeFinder\\PhpDocNodeByTypeFinder' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php', 'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php', @@ -2593,9 +2592,9 @@ class ComposerStaticInitc2db957c3ce342c948d5b630218dd433 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 08023be3cee..02433521d7f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1744,12 +1744,12 @@ "source": { "type": "git", "url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git", - "reference": "c8420dcc698c05de5f85fc7d21bd05b66ceb60dc" + "reference": "7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c8420dcc698c05de5f85fc7d21bd05b66ceb60dc", - "reference": "c8420dcc698c05de5f85fc7d21bd05b66ceb60dc", + "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6", + "reference": "7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6", "shasum": "" }, "require": { @@ -1774,7 +1774,7 @@ "tomasvotruba\/type-coverage": "^0.2", "tomasvotruba\/unused-public": "^0.3" }, - "time": "2023-09-11T18:26:33+00:00", + "time": "2023-09-11T18:44:21+00:00", "default-branch": true, "type": "rector-extension", "extra": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 4c2a2621363..2b1606612b8 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -2,4 +2,4 @@ namespace RectorPrefix202309; -return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.1.0', 'version' => '3.1.0.0', 'reference' => '4bff79ddd77851fe3cdd11616ed3f92841ba5bd2', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.0', 'version' => '3.4.0.0', 'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => 'f9301a5b2fb1216b2b08f02ba04dc45423db6bff', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '0.5.1', 'version' => '0.5.1.0', 'reference' => 'b58e5a3933e541dc286cc91fc4f3898bbc6f1623', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v10.22.0', 'version' => '10.22.0.0', 'reference' => 'ddc26273085fad3c471b2602ad820e0097ff7939', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v10.22.0', 'version' => '10.22.0.0', 'reference' => 'eb1a7e72e159136a832f2c0467de5570bdc208ae', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v3.2.10', 'version' => '3.2.10.0', 'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.17.1', 'version' => '4.17.1.0', 'reference' => 'a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.1.0', 'version' => '4.1.0.0', 'reference' => '8a4b664e916df82ff26a44709942dfd593fa6f30', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.24.0', 'version' => '1.24.0.0', 'reference' => '3510b0a6274cc42f7219367cb3abfc123ffa09d6', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('pretty_version' => '1.10.33', 'version' => '1.10.33.0', 'reference' => '03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.5', 'version' => '0.6.5.0', 'reference' => 'e71eb1aa55f057c7a4a0d08d06b0b0a484bead43', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.11.0', 'version' => '1.11.0.0', 'reference' => '3be0fc8f1eb37d6875cd6f0c6c7d0be81435de9f', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.4.0', 'version' => '1.4.0.0', 'reference' => '6e7e587714fff7a83dcc7025aee42ab3b265ae05', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.10.0', 'version' => '2.10.0.0', 'reference' => 'f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.14.0', 'version' => '1.14.0.0', 'reference' => '21591111d3ea62e31f2254280ca0656bc2b1bda6', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '6fbc9672905c7d5a885f2da2fc696f65840f4a66', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c8420dcc698c05de5f85fc7d21bd05b66ceb60dc', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '86f57eee49e0beae650cbef6ff70841849cca6a0', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'd4ca7d7e4d5d6d9d61d8aa1695010a6a6df50f47', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6ef9eb731559a91c170f27c6432a0b76176f5655', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '5.0.3', 'version' => '5.0.3.0', 'reference' => '912dc2fbe3e3c1e7873313cc801b100b6c68c87b', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.3.4', 'version' => '6.3.4.0', 'reference' => 'eca495f2ee845130855ddf1cf18460c38966c8b6', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/filesystem' => array('pretty_version' => 'v6.3.1', 'version' => '6.3.1.0', 'reference' => 'edd36776956f2a6fcf577edb5b05eb0e3bdc52ae', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.3.3', 'version' => '6.3.3.0', 'reference' => '9915db259f67d21eefee768c1abcf1cc61b1fc9e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.28.0', 'version' => '1.28.0.0', 'reference' => '42292d99c55abe617799667f454222c54c60e229', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.3.4', 'version' => '6.3.4.0', 'reference' => '0b5c29118f2e980d455d2e34a5659f4579847c54', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.3.0', 'version' => '3.3.0.0', 'reference' => '40da9cc13ec349d9e4966ce18b5fbcd724ab10a4', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symplify/easy-parallel' => array('pretty_version' => '11.1.27', 'version' => '11.1.27.0', 'reference' => '28911142f6a0f4127271f745e2403bb84fcd2b87', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.1.26', 'version' => '11.1.26.0', 'reference' => '3e66b3fec678b74a076395ec629d535fb95293b5', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); +return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.1.0', 'version' => '3.1.0.0', 'reference' => '4bff79ddd77851fe3cdd11616ed3f92841ba5bd2', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.0', 'version' => '3.4.0.0', 'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'ced299686f41dce890debac69273b47ffe98a40c', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => 'f9301a5b2fb1216b2b08f02ba04dc45423db6bff', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '0.5.1', 'version' => '0.5.1.0', 'reference' => 'b58e5a3933e541dc286cc91fc4f3898bbc6f1623', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v10.22.0', 'version' => '10.22.0.0', 'reference' => 'ddc26273085fad3c471b2602ad820e0097ff7939', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v10.22.0', 'version' => '10.22.0.0', 'reference' => 'eb1a7e72e159136a832f2c0467de5570bdc208ae', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v3.2.10', 'version' => '3.2.10.0', 'reference' => 'a4175c62652f2300c8017fb7e640f9ccb11648d2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v4.17.1', 'version' => '4.17.1.0', 'reference' => 'a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.1.0', 'version' => '4.1.0.0', 'reference' => '8a4b664e916df82ff26a44709942dfd593fa6f30', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '1.24.0', 'version' => '1.24.0.0', 'reference' => '3510b0a6274cc42f7219367cb3abfc123ffa09d6', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('pretty_version' => '1.10.33', 'version' => '1.10.33.0', 'reference' => '03b1cf9f814ba0863c4e9affea49a4d1ed9a2ed1', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpstan', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.5', 'version' => '0.6.5.0', 'reference' => 'e71eb1aa55f057c7a4a0d08d06b0b0a484bead43', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.11.0', 'version' => '1.11.0.0', 'reference' => '3be0fc8f1eb37d6875cd6f0c6c7d0be81435de9f', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.4.0', 'version' => '1.4.0.0', 'reference' => '6e7e587714fff7a83dcc7025aee42ab3b265ae05', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v2.10.0', 'version' => '2.10.0.0', 'reference' => 'f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.14.0', 'version' => '1.14.0.0', 'reference' => '21591111d3ea62e31f2254280ca0656bc2b1bda6', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '6fbc9672905c7d5a885f2da2fc696f65840f4a66', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '86f57eee49e0beae650cbef6ff70841849cca6a0', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'd4ca7d7e4d5d6d9d61d8aa1695010a6a6df50f47', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6ef9eb731559a91c170f27c6432a0b76176f5655', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '5.0.3', 'version' => '5.0.3.0', 'reference' => '912dc2fbe3e3c1e7873313cc801b100b6c68c87b', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.3.4', 'version' => '6.3.4.0', 'reference' => 'eca495f2ee845130855ddf1cf18460c38966c8b6', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/filesystem' => array('pretty_version' => 'v6.3.1', 'version' => '6.3.1.0', 'reference' => 'edd36776956f2a6fcf577edb5b05eb0e3bdc52ae', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.3.3', 'version' => '6.3.3.0', 'reference' => '9915db259f67d21eefee768c1abcf1cc61b1fc9e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.28.0', 'version' => '1.28.0.0', 'reference' => '42292d99c55abe617799667f454222c54c60e229', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.3.4', 'version' => '6.3.4.0', 'reference' => '0b5c29118f2e980d455d2e34a5659f4579847c54', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.3.0', 'version' => '3.3.0.0', 'reference' => '40da9cc13ec349d9e4966ce18b5fbcd724ab10a4', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symplify/easy-parallel' => array('pretty_version' => '11.1.27', 'version' => '11.1.27.0', 'reference' => '28911142f6a0f4127271f745e2403bb84fcd2b87', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.1.26', 'version' => '11.1.26.0', 'reference' => '3e66b3fec678b74a076395ec629d535fb95293b5', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); diff --git a/vendor/rector/extension-installer/src/GeneratedConfig.php b/vendor/rector/extension-installer/src/GeneratedConfig.php index 0f11ecfc9a9..666224cbdbd 100644 --- a/vendor/rector/extension-installer/src/GeneratedConfig.php +++ b/vendor/rector/extension-installer/src/GeneratedConfig.php @@ -9,7 +9,7 @@ namespace Rector\RectorInstaller; */ final class GeneratedConfig { - public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main c8420dc'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 86f57ee'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main d4ca7d7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 6ef9eb7')); + public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 7f9e132'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 86f57ee'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main d4ca7d7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 6ef9eb7')); private function __construct() { }