mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit a2f70054a7d976acd2c73b06789095b998829be6
a2f70054a7
[DocBlock] Update docblock contents right in the rule (#4999)
This commit is contained in:
parent
35a66f9d23
commit
3c6c1c03f8
|
@ -26,7 +26,6 @@ use Rector\BetterPhpDocParser\Annotation\AnnotationNaming;
|
||||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||||
use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode;
|
use Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode;
|
||||||
use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder;
|
use Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder;
|
||||||
use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor;
|
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode;
|
||||||
|
@ -80,10 +79,6 @@ final class PhpDocInfo
|
||||||
* @var \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
* @var \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||||
*/
|
*/
|
||||||
private $originalPhpDocNode;
|
private $originalPhpDocNode;
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private $hasChanged = \false;
|
|
||||||
public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
|
public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
|
||||||
{
|
{
|
||||||
$this->phpDocNode = $phpDocNode;
|
$this->phpDocNode = $phpDocNode;
|
||||||
|
@ -341,26 +336,11 @@ final class PhpDocInfo
|
||||||
* @deprecated Change doc block and print directly in the node instead
|
* @deprecated Change doc block and print directly in the node instead
|
||||||
* @internal
|
* @internal
|
||||||
* Should be handled by attributes of phpdoc node - if stard_and_end is missing in one of nodes, it has been changed
|
* 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
|
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
|
public function makeMultiLined() : void
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,16 +29,17 @@ final class PhpDocClassRenamer
|
||||||
*
|
*
|
||||||
* @param string[] $oldToNewClasses
|
* @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->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo, $hasChanged);
|
||||||
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo, $hasChanged);
|
||||||
$this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo);
|
$this->processSerializerTypeTagValueNode($oldToNewClasses, $phpDocInfo, $hasChanged);
|
||||||
|
return $hasChanged;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $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');
|
$assertChoiceDoctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
|
||||||
if (!$assertChoiceDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
if (!$assertChoiceDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
|
@ -66,24 +67,25 @@ final class PhpDocClassRenamer
|
||||||
$classNameStringNode->value = $newClass;
|
$classNameStringNode->value = $newClass;
|
||||||
// trigger reprint
|
// trigger reprint
|
||||||
$classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
$classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||||
|
$hasChanged = \true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $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']);
|
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']);
|
||||||
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses, $hasChanged);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $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');
|
$doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
|
||||||
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
|
@ -99,6 +101,7 @@ final class PhpDocClassRenamer
|
||||||
}
|
}
|
||||||
$classNameStringNode->value = Strings::replace($classNameStringNode->value, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
$classNameStringNode->value = Strings::replace($classNameStringNode->value, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
||||||
$classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
$classNameArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||||
|
$hasChanged = \true;
|
||||||
}
|
}
|
||||||
$currentTypeArrayItemNode = $doctrineAnnotationTagValueNode->getValue('type');
|
$currentTypeArrayItemNode = $doctrineAnnotationTagValueNode->getValue('type');
|
||||||
if (!$currentTypeArrayItemNode instanceof ArrayItemNode) {
|
if (!$currentTypeArrayItemNode instanceof ArrayItemNode) {
|
||||||
|
@ -110,13 +113,14 @@ final class PhpDocClassRenamer
|
||||||
}
|
}
|
||||||
if ($currentTypeStringNode->value === $oldClass) {
|
if ($currentTypeStringNode->value === $oldClass) {
|
||||||
$currentTypeStringNode->value = $newClass;
|
$currentTypeStringNode->value = $newClass;
|
||||||
|
$hasChanged = \true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $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';
|
$classKey = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? 'class' : 'targetEntity';
|
||||||
$targetEntityArrayItemNode = $doctrineAnnotationTagValueNode->getValue($classKey);
|
$targetEntityArrayItemNode = $doctrineAnnotationTagValueNode->getValue($classKey);
|
||||||
|
@ -136,6 +140,7 @@ final class PhpDocClassRenamer
|
||||||
}
|
}
|
||||||
$targetEntityStringNode->value = $newClass;
|
$targetEntityStringNode->value = $newClass;
|
||||||
$targetEntityArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
$targetEntityArrayItemNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||||
|
$hasChanged = \true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,14 +130,14 @@ final class PhpDocTypeChanger
|
||||||
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike);
|
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike);
|
||||||
return \true;
|
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
|
// better skip, could crash hard
|
||||||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
if (!$this->newPhpDocFromPHPStanTypeGuard->isLegal($newType)) {
|
if (!$this->newPhpDocFromPHPStanTypeGuard->isLegal($newType)) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
$phpDocTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
$phpDocTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType);
|
||||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
||||||
|
@ -147,10 +147,10 @@ final class PhpDocTypeChanger
|
||||||
$currentType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $param);
|
$currentType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $param);
|
||||||
// avoid overriding better type
|
// avoid overriding better type
|
||||||
if ($this->typeComparator->isSubtype($currentType, $newType)) {
|
if ($this->typeComparator->isSubtype($currentType, $newType)) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
if ($this->typeComparator->areTypesEqual($currentType, $newType)) {
|
if ($this->typeComparator->areTypesEqual($currentType, $newType)) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
$paramTagValueNode->type = $phpDocTypeNode;
|
$paramTagValueNode->type = $phpDocTypeNode;
|
||||||
} else {
|
} else {
|
||||||
|
@ -158,6 +158,7 @@ final class PhpDocTypeChanger
|
||||||
$phpDocInfo->addTagValueNode($paramTagValueNode);
|
$phpDocInfo->addTagValueNode($paramTagValueNode);
|
||||||
}
|
}
|
||||||
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike);
|
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike);
|
||||||
|
return \true;
|
||||||
}
|
}
|
||||||
public function isAllowed(TypeNode $typeNode) : bool
|
public function isAllowed(TypeNode $typeNode) : bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare (strict_types=1);
|
|
||||||
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
|
||||||
|
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
|
||||||
use Rector\Naming\ValueObject\ParamRename;
|
|
||||||
final class PropertyDocBlockManipulator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
|
||||||
*/
|
|
||||||
private $phpDocInfoFactory;
|
|
||||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
|
||||||
{
|
|
||||||
$this->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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,22 +20,6 @@ final class DocBlockUpdater
|
||||||
{
|
{
|
||||||
$this->phpDocInfoPrinter = $phpDocInfoPrinter;
|
$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
|
public function updateRefactoredNodeWithPhpDocInfo(Node $node) : void
|
||||||
{
|
{
|
||||||
// nothing to change? don't save it
|
// nothing to change? don't save it
|
||||||
|
@ -58,17 +42,6 @@ final class DocBlockUpdater
|
||||||
});
|
});
|
||||||
$node->setAttribute(AttributeKey::COMMENTS, $comments);
|
$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
|
private function printPhpDocInfoToString(PhpDocInfo $phpDocInfo) : string
|
||||||
{
|
{
|
||||||
if ($phpDocInfo->isNewNode()) {
|
if ($phpDocInfo->isNewNode()) {
|
||||||
|
|
|
@ -21,14 +21,15 @@ final class DocBlockClassRenamer
|
||||||
/**
|
/**
|
||||||
* @param OldToNewType[] $oldToNewTypes
|
* @param OldToNewType[] $oldToNewTypes
|
||||||
*/
|
*/
|
||||||
public function renamePhpDocType(PhpDocInfo $phpDocInfo, array $oldToNewTypes) : void
|
public function renamePhpDocType(PhpDocInfo $phpDocInfo, array $oldToNewTypes) : bool
|
||||||
{
|
{
|
||||||
if ($oldToNewTypes === []) {
|
if ($oldToNewTypes === []) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($this->classRenamePhpDocNodeVisitor);
|
$phpDocNodeTraverser->addPhpDocNodeVisitor($this->classRenamePhpDocNodeVisitor);
|
||||||
$this->classRenamePhpDocNodeVisitor->setOldToNewTypes($oldToNewTypes);
|
$this->classRenamePhpDocNodeVisitor->setOldToNewTypes($oldToNewTypes);
|
||||||
$phpDocNodeTraverser->traverse($phpDocInfo->getPhpDocNode());
|
$phpDocNodeTraverser->traverse($phpDocInfo->getPhpDocNode());
|
||||||
|
return $this->classRenamePhpDocNodeVisitor->hasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,15 @@ final class DocBlockNameImporter
|
||||||
{
|
{
|
||||||
$this->nameImportingPhpDocNodeVisitor = $nameImportingPhpDocNodeVisitor;
|
$this->nameImportingPhpDocNodeVisitor = $nameImportingPhpDocNodeVisitor;
|
||||||
}
|
}
|
||||||
public function importNames(PhpDocNode $phpDocNode, Node $node) : void
|
public function importNames(PhpDocNode $phpDocNode, Node $node) : bool
|
||||||
{
|
{
|
||||||
if ($phpDocNode->children === []) {
|
if ($phpDocNode->children === []) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
$this->nameImportingPhpDocNodeVisitor->setCurrentNode($node);
|
$this->nameImportingPhpDocNodeVisitor->setCurrentNode($node);
|
||||||
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($this->nameImportingPhpDocNodeVisitor);
|
$phpDocNodeTraverser->addPhpDocNodeVisitor($this->nameImportingPhpDocNodeVisitor);
|
||||||
$phpDocNodeTraverser->traverse($phpDocNode);
|
$phpDocNodeTraverser->traverse($phpDocNode);
|
||||||
|
return $this->nameImportingPhpDocNodeVisitor->hasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
* @var OldToNewType[]
|
* @var OldToNewType[]
|
||||||
*/
|
*/
|
||||||
private $oldToNewTypes = [];
|
private $oldToNewTypes = [];
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $hasChanged = \false;
|
||||||
public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver)
|
public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver)
|
||||||
{
|
{
|
||||||
$this->staticTypeMapper = $staticTypeMapper;
|
$this->staticTypeMapper = $staticTypeMapper;
|
||||||
|
@ -56,6 +60,7 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
if ($this->oldToNewTypes === []) {
|
if ($this->oldToNewTypes === []) {
|
||||||
throw new ShouldNotHappenException('Configure "$oldToNewClasses" first');
|
throw new ShouldNotHappenException('Configure "$oldToNewClasses" first');
|
||||||
}
|
}
|
||||||
|
$this->hasChanged = \false;
|
||||||
}
|
}
|
||||||
public function enterNode(Node $node) : ?Node
|
public function enterNode(Node $node) : ?Node
|
||||||
{
|
{
|
||||||
|
@ -91,6 +96,7 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
// mirror attributes
|
// mirror attributes
|
||||||
$newTypeNode->setAttribute(PhpDocAttributeKey::PARENT, $parentType);
|
$newTypeNode->setAttribute(PhpDocAttributeKey::PARENT, $parentType);
|
||||||
}
|
}
|
||||||
|
$this->hasChanged = \true;
|
||||||
return $newTypeNode;
|
return $newTypeNode;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -102,6 +108,10 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
{
|
{
|
||||||
$this->oldToNewTypes = $oldToNewTypes;
|
$this->oldToNewTypes = $oldToNewTypes;
|
||||||
}
|
}
|
||||||
|
public function hasChanged() : bool
|
||||||
|
{
|
||||||
|
return $this->hasChanged;
|
||||||
|
}
|
||||||
private function resolveNamespacedName(IdentifierTypeNode $identifierTypeNode, PhpParserNode $phpParserNode, string $name) : string
|
private function resolveNamespacedName(IdentifierTypeNode $identifierTypeNode, PhpParserNode $phpParserNode, string $name) : string
|
||||||
{
|
{
|
||||||
if (\strncmp($name, '\\', \strlen('\\')) === 0) {
|
if (\strncmp($name, '\\', \strlen('\\')) === 0) {
|
||||||
|
|
|
@ -54,6 +54,10 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
* @var PhpParserNode|null
|
* @var PhpParserNode|null
|
||||||
*/
|
*/
|
||||||
private $currentPhpParserNode;
|
private $currentPhpParserNode;
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $hasChanged = \false;
|
||||||
public function __construct(ClassNameImportSkipper $classNameImportSkipper, UseNodesToAddCollector $useNodesToAddCollector, CurrentFileProvider $currentFileProvider, ReflectionProvider $reflectionProvider, IdentifierTypeMapper $identifierTypeMapper)
|
public function __construct(ClassNameImportSkipper $classNameImportSkipper, UseNodesToAddCollector $useNodesToAddCollector, CurrentFileProvider $currentFileProvider, ReflectionProvider $reflectionProvider, IdentifierTypeMapper $identifierTypeMapper)
|
||||||
{
|
{
|
||||||
$this->classNameImportSkipper = $classNameImportSkipper;
|
$this->classNameImportSkipper = $classNameImportSkipper;
|
||||||
|
@ -99,8 +103,13 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
}
|
}
|
||||||
public function setCurrentNode(PhpParserNode $phpParserNode) : void
|
public function setCurrentNode(PhpParserNode $phpParserNode) : void
|
||||||
{
|
{
|
||||||
|
$this->hasChanged = \false;
|
||||||
$this->currentPhpParserNode = $phpParserNode;
|
$this->currentPhpParserNode = $phpParserNode;
|
||||||
}
|
}
|
||||||
|
public function hasChanged() : bool
|
||||||
|
{
|
||||||
|
return $this->hasChanged;
|
||||||
|
}
|
||||||
private function processFqnNameImport(PhpParserNode $phpParserNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType, File $file) : ?IdentifierTypeNode
|
private function processFqnNameImport(PhpParserNode $phpParserNode, IdentifierTypeNode $identifierTypeNode, FullyQualifiedObjectType $fullyQualifiedObjectType, File $file) : ?IdentifierTypeNode
|
||||||
{
|
{
|
||||||
$parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
|
$parentNode = $identifierTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
|
||||||
|
@ -108,6 +117,7 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
// might break
|
// might break
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// standardize to FQN
|
||||||
if (\strncmp($fullyQualifiedObjectType->getClassName(), '@', \strlen('@')) === 0) {
|
if (\strncmp($fullyQualifiedObjectType->getClassName(), '@', \strlen('@')) === 0) {
|
||||||
$fullyQualifiedObjectType = new FullyQualifiedObjectType(\ltrim($fullyQualifiedObjectType->getClassName(), '@'));
|
$fullyQualifiedObjectType = new FullyQualifiedObjectType(\ltrim($fullyQualifiedObjectType->getClassName(), '@'));
|
||||||
}
|
}
|
||||||
|
@ -121,6 +131,7 @@ final class NameImportingPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
}
|
}
|
||||||
if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
|
if ($this->shouldImport($newNode, $identifierTypeNode, $fullyQualifiedObjectType)) {
|
||||||
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
|
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
|
||||||
|
$this->hasChanged = \true;
|
||||||
return $newNode;
|
return $newNode;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -14,9 +14,11 @@ use PhpParser\Node\Stmt\InlineHTML;
|
||||||
use PhpParser\Node\Stmt\Namespace_;
|
use PhpParser\Node\Stmt\Namespace_;
|
||||||
use PhpParser\Node\Stmt\Use_;
|
use PhpParser\Node\Stmt\Use_;
|
||||||
use PHPStan\Reflection\ReflectionProvider;
|
use PHPStan\Reflection\ReflectionProvider;
|
||||||
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||||
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
|
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
|
||||||
use Rector\CodingStyle\Node\NameImporter;
|
use Rector\CodingStyle\Node\NameImporter;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\Core\Configuration\Option;
|
use Rector\Core\Configuration\Option;
|
||||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||||
|
@ -68,7 +70,12 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
||||||
* @var \Rector\Naming\Naming\AliasNameResolver
|
* @var \Rector\Naming\Naming\AliasNameResolver
|
||||||
*/
|
*/
|
||||||
private $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->nameImporter = $nameImporter;
|
||||||
$this->docBlockNameImporter = $docBlockNameImporter;
|
$this->docBlockNameImporter = $docBlockNameImporter;
|
||||||
|
@ -78,6 +85,7 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
||||||
$this->currentFileProvider = $currentFileProvider;
|
$this->currentFileProvider = $currentFileProvider;
|
||||||
$this->useImportsResolver = $useImportsResolver;
|
$this->useImportsResolver = $useImportsResolver;
|
||||||
$this->aliasNameResolver = $aliasNameResolver;
|
$this->aliasNameResolver = $aliasNameResolver;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
public function enterNode(Node $node) : ?Node
|
public function enterNode(Node $node) : ?Node
|
||||||
{
|
{
|
||||||
|
@ -88,19 +96,30 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
||||||
if (!$file instanceof File) {
|
if (!$file instanceof File) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$currentStmt = \current($file->getNewStmts());
|
$firstStmt = \current($file->getNewStmts());
|
||||||
if ($currentStmt instanceof FileWithoutNamespace && \current($currentStmt->stmts) instanceof InlineHTML) {
|
if ($firstStmt instanceof FileWithoutNamespace && \current($firstStmt->stmts) instanceof InlineHTML) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof Name) {
|
if ($node instanceof Name) {
|
||||||
return $this->processNodeName($node, $file);
|
return $this->processNodeName($node, $file);
|
||||||
}
|
}
|
||||||
if (($node instanceof Stmt || $node instanceof Param) && SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES)) {
|
if (!$node instanceof Stmt && !$node instanceof Param) {
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
return null;
|
||||||
$this->docBlockNameImporter->importNames($phpDocInfo->getPhpDocNode(), $node);
|
|
||||||
return $node;
|
|
||||||
}
|
}
|
||||||
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
|
private function processNodeName(Name $name, File $file) : ?Node
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,12 +131,9 @@ CODE_SAMPLE
|
||||||
if ($this->hasNoComment($comments)) {
|
if ($this->hasNoComment($comments)) {
|
||||||
return $rangeLine;
|
return $rangeLine;
|
||||||
}
|
}
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($nextStmt);
|
|
||||||
if ($phpDocInfo->hasChanged()) {
|
|
||||||
return $rangeLine;
|
|
||||||
}
|
|
||||||
/** @var Comment[] $comments */
|
/** @var Comment[] $comments */
|
||||||
$line = $comments[0]->getStartLine();
|
$firstComment = $comments[0];
|
||||||
|
$line = $firstComment->getStartLine();
|
||||||
return $line - $endLine;
|
return $line - $endLine;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -144,10 +141,7 @@ CODE_SAMPLE
|
||||||
*/
|
*/
|
||||||
private function hasNoComment(?array $comments) : bool
|
private function hasNoComment(?array $comments) : bool
|
||||||
{
|
{
|
||||||
if ($comments === null) {
|
return $comments === null || $comments === [];
|
||||||
return \true;
|
|
||||||
}
|
|
||||||
return !isset($comments[0]);
|
|
||||||
}
|
}
|
||||||
private function shouldSkip(Stmt $stmt) : bool
|
private function shouldSkip(Stmt $stmt) : bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
declare (strict_types=1);
|
declare (strict_types=1);
|
||||||
namespace Rector\Naming\ParamRenamer;
|
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\ValueObject\ParamRename;
|
||||||
use Rector\Naming\VariableRenamer;
|
use Rector\Naming\VariableRenamer;
|
||||||
final class ParamRenamer
|
final class ParamRenamer
|
||||||
|
@ -15,13 +19,19 @@ final class ParamRenamer
|
||||||
private $variableRenamer;
|
private $variableRenamer;
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocManipulator\PropertyDocBlockManipulator
|
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
||||||
*/
|
*/
|
||||||
private $propertyDocBlockManipulator;
|
private $docBlockUpdater;
|
||||||
public function __construct(VariableRenamer $variableRenamer, PropertyDocBlockManipulator $propertyDocBlockManipulator)
|
/**
|
||||||
|
* @readonly
|
||||||
|
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||||
|
*/
|
||||||
|
private $phpDocInfoFactory;
|
||||||
|
public function __construct(VariableRenamer $variableRenamer, DocBlockUpdater $docBlockUpdater, PhpDocInfoFactory $phpDocInfoFactory)
|
||||||
{
|
{
|
||||||
$this->variableRenamer = $variableRenamer;
|
$this->variableRenamer = $variableRenamer;
|
||||||
$this->propertyDocBlockManipulator = $propertyDocBlockManipulator;
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
}
|
}
|
||||||
public function rename(ParamRename $paramRename) : void
|
public function rename(ParamRename $paramRename) : void
|
||||||
{
|
{
|
||||||
|
@ -30,6 +40,21 @@ final class ParamRenamer
|
||||||
// 2. rename param in the rest of the method
|
// 2. rename param in the rest of the method
|
||||||
$this->variableRenamer->renameVariableInFunctionLike($paramRename->getFunctionLike(), $paramRename->getCurrentName(), $paramRename->getExpectedName(), null);
|
$this->variableRenamer->renameVariableInFunctionLike($paramRename->getFunctionLike(), $paramRename->getCurrentName(), $paramRename->getExpectedName(), null);
|
||||||
// 3. rename @param variable in docblock too
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use PhpParser\Node\Stmt\Interface_;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\Core\Php\PhpVersionProvider;
|
use Rector\Core\Php\PhpVersionProvider;
|
||||||
use Rector\Core\ValueObject\MethodName;
|
use Rector\Core\ValueObject\MethodName;
|
||||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||||
|
@ -64,7 +65,12 @@ final class PropertyPromotionRenamer
|
||||||
* @var \Rector\Naming\VariableRenamer
|
* @var \Rector\Naming\VariableRenamer
|
||||||
*/
|
*/
|
||||||
private $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->phpVersionProvider = $phpVersionProvider;
|
||||||
$this->matchParamTypeExpectedNameResolver = $matchParamTypeExpectedNameResolver;
|
$this->matchParamTypeExpectedNameResolver = $matchParamTypeExpectedNameResolver;
|
||||||
|
@ -74,6 +80,7 @@ final class PropertyPromotionRenamer
|
||||||
$this->propertyFetchRenamer = $propertyFetchRenamer;
|
$this->propertyFetchRenamer = $propertyFetchRenamer;
|
||||||
$this->nodeNameResolver = $nodeNameResolver;
|
$this->nodeNameResolver = $nodeNameResolver;
|
||||||
$this->variableRenamer = $variableRenamer;
|
$this->variableRenamer = $variableRenamer;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classLike
|
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classLike
|
||||||
|
@ -125,7 +132,7 @@ final class PropertyPromotionRenamer
|
||||||
$param->var = new Variable($desiredPropertyName);
|
$param->var = new Variable($desiredPropertyName);
|
||||||
$this->variableRenamer->renameVariableInFunctionLike($classMethod, $paramVarName, $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);
|
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramVarName);
|
||||||
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||||
|
@ -136,6 +143,7 @@ final class PropertyPromotionRenamer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->paramRenamer->rename($paramRename);
|
$this->paramRenamer->rename($paramRename);
|
||||||
|
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($classMethod);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sometimes the bare type is not enough.
|
* Sometimes the bare type is not enough.
|
||||||
|
|
|
@ -10,6 +10,8 @@ use PhpParser\Node\Expr\Closure;
|
||||||
use PhpParser\Node\Stmt\ClassMethod;
|
use PhpParser\Node\Stmt\ClassMethod;
|
||||||
use PhpParser\Node\Stmt\Expression;
|
use PhpParser\Node\Stmt\Expression;
|
||||||
use PhpParser\Node\Stmt\Function_;
|
use PhpParser\Node\Stmt\Function_;
|
||||||
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\Core\Rector\AbstractRector;
|
use Rector\Core\Rector\AbstractRector;
|
||||||
use Rector\Naming\Guard\BreakingVariableRenameGuard;
|
use Rector\Naming\Guard\BreakingVariableRenameGuard;
|
||||||
use Rector\Naming\Matcher\VariableAndCallAssignMatcher;
|
use Rector\Naming\Matcher\VariableAndCallAssignMatcher;
|
||||||
|
@ -55,12 +57,17 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRect
|
||||||
* @var \Rector\Naming\VariableRenamer
|
* @var \Rector\Naming\VariableRenamer
|
||||||
*/
|
*/
|
||||||
private $variableRenamer;
|
private $variableRenamer;
|
||||||
|
/**
|
||||||
|
* @readonly
|
||||||
|
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
||||||
|
*/
|
||||||
|
private $docBlockUpdater;
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
* @see https://regex101.com/r/JG5w9j/1
|
* @see https://regex101.com/r/JG5w9j/1
|
||||||
*/
|
*/
|
||||||
private const OR_BETWEEN_WORDS_REGEX = '#[a-z]Or[A-Z]#';
|
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->breakingVariableRenameGuard = $breakingVariableRenameGuard;
|
||||||
$this->expectedNameResolver = $expectedNameResolver;
|
$this->expectedNameResolver = $expectedNameResolver;
|
||||||
|
@ -68,6 +75,7 @@ final class RenameVariableToMatchMethodCallReturnTypeRector extends AbstractRect
|
||||||
$this->varTagValueNodeRenamer = $varTagValueNodeRenamer;
|
$this->varTagValueNodeRenamer = $varTagValueNodeRenamer;
|
||||||
$this->variableAndCallAssignMatcher = $variableAndCallAssignMatcher;
|
$this->variableAndCallAssignMatcher = $variableAndCallAssignMatcher;
|
||||||
$this->variableRenamer = $variableRenamer;
|
$this->variableRenamer = $variableRenamer;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
public function getRuleDefinition() : RuleDefinition
|
public function getRuleDefinition() : RuleDefinition
|
||||||
{
|
{
|
||||||
|
@ -139,7 +147,7 @@ CODE_SAMPLE
|
||||||
if ($this->shouldSkip($variableAndCallAssign, $expectedName)) {
|
if ($this->shouldSkip($variableAndCallAssign, $expectedName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->renameVariable($variableAndCallAssign, $expectedName);
|
$this->renameVariable($variableAndCallAssign, $expectedName, $stmt);
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -155,11 +163,14 @@ CODE_SAMPLE
|
||||||
}
|
}
|
||||||
return $this->breakingVariableRenameGuard->shouldSkipVariable($variableAndCallAssign->getVariableName(), $expectedName, $variableAndCallAssign->getFunctionLike(), $variableAndCallAssign->getVariable());
|
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());
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||||
use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
|
use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||||
|
@ -42,13 +43,19 @@ final class PropertyPromotionDocBlockMerger
|
||||||
* @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter
|
* @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter
|
||||||
*/
|
*/
|
||||||
private $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->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
$this->staticTypeMapper = $staticTypeMapper;
|
$this->staticTypeMapper = $staticTypeMapper;
|
||||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||||
$this->varTagRemover = $varTagRemover;
|
$this->varTagRemover = $varTagRemover;
|
||||||
$this->phpDocInfoPrinter = $phpDocInfoPrinter;
|
$this->phpDocInfoPrinter = $phpDocInfoPrinter;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
public function mergePropertyAndParamDocBlocks(Property $property, Param $param, ?ParamTagValueNode $paramTagValueNode) : void
|
public function mergePropertyAndParamDocBlocks(Property $property, Param $param, ?ParamTagValueNode $paramTagValueNode) : void
|
||||||
{
|
{
|
||||||
|
@ -65,6 +72,7 @@ final class PropertyPromotionDocBlockMerger
|
||||||
$param->setAttribute(AttributeKey::COMMENTS, $mergedComments);
|
$param->setAttribute(AttributeKey::COMMENTS, $mergedComments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($param);
|
||||||
}
|
}
|
||||||
public function decorateParamWithPropertyPhpDocInfo(ClassMethod $classMethod, Property $property, Param $param, string $paramName) : void
|
public function decorateParamWithPropertyPhpDocInfo(ClassMethod $classMethod, Property $property, Param $param, string $paramName) : void
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Rector\Core\Rector\AbstractRector;
|
||||||
use Rector\Core\Reflection\ReflectionResolver;
|
use Rector\Core\Reflection\ReflectionResolver;
|
||||||
use Rector\Core\ValueObject\MethodName;
|
use Rector\Core\ValueObject\MethodName;
|
||||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||||
|
use Rector\Naming\PropertyRenamer\PropertyPromotionRenamer;
|
||||||
use Rector\Naming\VariableRenamer;
|
use Rector\Naming\VariableRenamer;
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||||
|
@ -76,6 +77,11 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect
|
||||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||||
*/
|
*/
|
||||||
private $reflectionResolver;
|
private $reflectionResolver;
|
||||||
|
/**
|
||||||
|
* @readonly
|
||||||
|
* @var \Rector\Naming\PropertyRenamer\PropertyPromotionRenamer
|
||||||
|
*/
|
||||||
|
private $propertyPromotionRenamer;
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -91,7 +97,7 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $inlinePublic = \false;
|
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->promotedPropertyCandidateResolver = $promotedPropertyCandidateResolver;
|
||||||
$this->variableRenamer = $variableRenamer;
|
$this->variableRenamer = $variableRenamer;
|
||||||
|
@ -100,6 +106,7 @@ final class ClassPropertyAssignToConstructorPromotionRector extends AbstractRect
|
||||||
$this->makePropertyPromotionGuard = $makePropertyPromotionGuard;
|
$this->makePropertyPromotionGuard = $makePropertyPromotionGuard;
|
||||||
$this->typeComparator = $typeComparator;
|
$this->typeComparator = $typeComparator;
|
||||||
$this->reflectionResolver = $reflectionResolver;
|
$this->reflectionResolver = $reflectionResolver;
|
||||||
|
$this->propertyPromotionRenamer = $propertyPromotionRenamer;
|
||||||
}
|
}
|
||||||
public function getRuleDefinition() : RuleDefinition
|
public function getRuleDefinition() : RuleDefinition
|
||||||
{
|
{
|
||||||
|
@ -180,8 +187,7 @@ CODE_SAMPLE
|
||||||
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||||
$this->propertyPromotionDocBlockMerger->decorateParamWithPropertyPhpDocInfo($constructClassMethod, $property, $param, $paramName);
|
$this->propertyPromotionDocBlockMerger->decorateParamWithPropertyPhpDocInfo($constructClassMethod, $property, $param, $paramName);
|
||||||
} elseif ($paramTagValueNode->parameterName !== '$' . $propertyName) {
|
} elseif ($paramTagValueNode->parameterName !== '$' . $propertyName) {
|
||||||
$paramTagValueNode->parameterName = '$' . $propertyName;
|
$this->propertyPromotionRenamer->renameParamDoc($constructorPhpDocInfo, $constructClassMethod, $param, $paramTagValueNode->parameterName, $propertyName);
|
||||||
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
|
||||||
}
|
}
|
||||||
// property name has higher priority
|
// property name has higher priority
|
||||||
$paramName = $this->getName($property);
|
$paramName = $this->getName($property);
|
||||||
|
|
|
@ -20,6 +20,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocClassRenamer;
|
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocClassRenamer;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\NodeTypes;
|
use Rector\BetterPhpDocParser\ValueObject\NodeTypes;
|
||||||
use Rector\CodingStyle\Naming\ClassNaming;
|
use Rector\CodingStyle\Naming\ClassNaming;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||||
use Rector\Core\Util\FileHasher;
|
use Rector\Core\Util\FileHasher;
|
||||||
use Rector\NodeNameResolver\NodeNameResolver;
|
use Rector\NodeNameResolver\NodeNameResolver;
|
||||||
|
@ -75,6 +76,11 @@ final class ClassRenamer
|
||||||
* @var \Rector\Core\Util\FileHasher
|
* @var \Rector\Core\Util\FileHasher
|
||||||
*/
|
*/
|
||||||
private $fileHasher;
|
private $fileHasher;
|
||||||
|
/**
|
||||||
|
* @readonly
|
||||||
|
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
||||||
|
*/
|
||||||
|
private $docBlockUpdater;
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
@ -83,7 +89,7 @@ final class ClassRenamer
|
||||||
* @var array<string, OldToNewType[]>
|
* @var array<string, OldToNewType[]>
|
||||||
*/
|
*/
|
||||||
private $oldToNewTypesByCacheKey = [];
|
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->betterNodeFinder = $betterNodeFinder;
|
||||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||||
|
@ -94,6 +100,7 @@ final class ClassRenamer
|
||||||
$this->docBlockClassRenamer = $docBlockClassRenamer;
|
$this->docBlockClassRenamer = $docBlockClassRenamer;
|
||||||
$this->reflectionProvider = $reflectionProvider;
|
$this->reflectionProvider = $reflectionProvider;
|
||||||
$this->fileHasher = $fileHasher;
|
$this->fileHasher = $fileHasher;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $oldToNewClasses
|
||||||
|
@ -104,33 +111,40 @@ final class ClassRenamer
|
||||||
if ($node instanceof Name) {
|
if ($node instanceof Name) {
|
||||||
return $this->refactorName($node, $oldToNewClasses);
|
return $this->refactorName($node, $oldToNewClasses);
|
||||||
}
|
}
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
|
||||||
$this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses, $phpDocInfo);
|
if ($phpDocInfo instanceof PhpDocInfo) {
|
||||||
|
$hasPhpDocChanged = $this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses, $phpDocInfo);
|
||||||
|
if ($hasPhpDocChanged) {
|
||||||
|
return $node;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($node instanceof Namespace_) {
|
if ($node instanceof Namespace_) {
|
||||||
return $this->refactorNamespace($node, $oldToNewClasses);
|
return $this->refactorNamespace($node, $oldToNewClasses);
|
||||||
}
|
}
|
||||||
if ($node instanceof ClassLike) {
|
if ($node instanceof ClassLike) {
|
||||||
return $this->refactorClassLike($node, $oldToNewClasses, $scope);
|
return $this->refactorClassLike($node, $oldToNewClasses, $scope);
|
||||||
}
|
}
|
||||||
if ($phpDocInfo->hasChanged()) {
|
|
||||||
return $node;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param OldToNewType[] $oldToNewTypes
|
* @param OldToNewType[] $oldToNewTypes
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @param array<string, string> $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)) {
|
if (!$phpDocInfo->hasByTypes(NodeTypes::TYPE_AWARE_NODES) && !$phpDocInfo->hasByAnnotationClasses(NodeTypes::TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES)) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
if ($node instanceof AttributeGroup) {
|
if ($node instanceof AttributeGroup) {
|
||||||
return;
|
return \false;
|
||||||
}
|
}
|
||||||
$this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes);
|
$hasChanged = $this->docBlockClassRenamer->renamePhpDocType($phpDocInfo, $oldToNewTypes);
|
||||||
$this->phpDocClassRenamer->changeTypeInAnnotationTypes($node, $phpDocInfo, $oldToNewClasses);
|
$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
|
private function shouldSkip(string $newName, Name $name) : bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@ use PhpParser\Node\Stmt\Class_;
|
||||||
use PhpParser\Node\Stmt\ClassMethod;
|
use PhpParser\Node\Stmt\ClassMethod;
|
||||||
use PhpParser\Node\Stmt\Expression;
|
use PhpParser\Node\Stmt\Expression;
|
||||||
use PhpParser\Node\Stmt\Property;
|
use PhpParser\Node\Stmt\Property;
|
||||||
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||||
|
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||||
use Rector\Core\Rector\AbstractRector;
|
use Rector\Core\Rector\AbstractRector;
|
||||||
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer;
|
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer;
|
||||||
|
@ -26,13 +28,19 @@ final class RenameAnnotationRector extends AbstractRector implements Configurabl
|
||||||
* @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer
|
* @var \Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer
|
||||||
*/
|
*/
|
||||||
private $docBlockTagReplacer;
|
private $docBlockTagReplacer;
|
||||||
|
/**
|
||||||
|
* @readonly
|
||||||
|
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
||||||
|
*/
|
||||||
|
private $docBlockUpdater;
|
||||||
/**
|
/**
|
||||||
* @var RenameAnnotationInterface[]
|
* @var RenameAnnotationInterface[]
|
||||||
*/
|
*/
|
||||||
private $renameAnnotations = [];
|
private $renameAnnotations = [];
|
||||||
public function __construct(DocBlockTagReplacer $docBlockTagReplacer)
|
public function __construct(DocBlockTagReplacer $docBlockTagReplacer, DocBlockUpdater $docBlockUpdater)
|
||||||
{
|
{
|
||||||
$this->docBlockTagReplacer = $docBlockTagReplacer;
|
$this->docBlockTagReplacer = $docBlockTagReplacer;
|
||||||
|
$this->docBlockUpdater = $docBlockUpdater;
|
||||||
}
|
}
|
||||||
public function getRuleDefinition() : RuleDefinition
|
public function getRuleDefinition() : RuleDefinition
|
||||||
{
|
{
|
||||||
|
@ -76,31 +84,25 @@ CODE_SAMPLE
|
||||||
*/
|
*/
|
||||||
public function refactor(Node $node) : ?Node
|
public function refactor(Node $node) : ?Node
|
||||||
{
|
{
|
||||||
$hasChanged = \false;
|
|
||||||
if ($node instanceof Expression) {
|
if ($node instanceof Expression) {
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
return $this->refactorExpression($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;
|
|
||||||
}
|
}
|
||||||
|
$hasChanged = \false;
|
||||||
foreach ($node->stmts as $stmt) {
|
foreach ($node->stmts as $stmt) {
|
||||||
if (!$stmt instanceof ClassMethod && !$stmt instanceof Property) {
|
if (!$stmt instanceof ClassMethod && !$stmt instanceof Property) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($stmt);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($stmt);
|
||||||
|
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ($this->renameAnnotations as $renameAnnotation) {
|
foreach ($this->renameAnnotations as $renameAnnotation) {
|
||||||
if ($renameAnnotation instanceof RenameAnnotationByType && !$this->isObjectType($node, $renameAnnotation->getObjectType())) {
|
if ($renameAnnotation instanceof RenameAnnotationByType && !$this->isObjectType($node, $renameAnnotation->getObjectType())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation());
|
$hasDocBlockChanged = $this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, $renameAnnotation->getOldAnnotation(), $renameAnnotation->getNewAnnotation());
|
||||||
if ($hasDocBlockChanged) {
|
if ($hasDocBlockChanged) {
|
||||||
|
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($stmt);
|
||||||
$hasChanged = \true;
|
$hasChanged = \true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,4 +120,20 @@ CODE_SAMPLE
|
||||||
Assert::allIsAOf($configuration, RenameAnnotationInterface::class);
|
Assert::allIsAOf($configuration, RenameAnnotationInterface::class);
|
||||||
$this->renameAnnotations = $configuration;
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ CODE_SAMPLE
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$functionLikePhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
$functionLikePhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||||
|
$hasChanged = \false;
|
||||||
foreach ($node->getParams() as $param) {
|
foreach ($node->getParams() as $param) {
|
||||||
if ($param->type === null) {
|
if ($param->type === null) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -96,9 +97,12 @@ CODE_SAMPLE
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$paramName = $this->getName($param);
|
$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 $node;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = '596bbc98a25903c525914b4d16ea5f9c76b500fb';
|
public const PACKAGE_VERSION = 'a2f70054a7d976acd2c73b06789095b998829be6';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2023-09-11 20:30:55';
|
public const RELEASE_DATE = '2023-09-12 04:28:02';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,6 @@ use PhpParser\Node\Scalar\DNumber;
|
||||||
use PhpParser\Node\Scalar\EncapsedStringPart;
|
use PhpParser\Node\Scalar\EncapsedStringPart;
|
||||||
use PhpParser\Node\Scalar\LNumber;
|
use PhpParser\Node\Scalar\LNumber;
|
||||||
use PhpParser\Node\Scalar\String_;
|
use PhpParser\Node\Scalar\String_;
|
||||||
use PhpParser\Node\Stmt;
|
|
||||||
use PhpParser\Node\Stmt\Class_;
|
use PhpParser\Node\Stmt\Class_;
|
||||||
use PhpParser\Node\Stmt\ClassMethod;
|
use PhpParser\Node\Stmt\ClassMethod;
|
||||||
use PhpParser\Node\Stmt\Declare_;
|
use PhpParser\Node\Stmt\Declare_;
|
||||||
|
@ -27,7 +26,6 @@ use PhpParser\Node\Stmt\Nop;
|
||||||
use PhpParser\Node\Stmt\Use_;
|
use PhpParser\Node\Stmt\Use_;
|
||||||
use PhpParser\PrettyPrinter\Standard;
|
use PhpParser\PrettyPrinter\Standard;
|
||||||
use PHPStan\Node\Expr\AlwaysRememberedExpr;
|
use PHPStan\Node\Expr\AlwaysRememberedExpr;
|
||||||
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
|
||||||
use Rector\Core\Configuration\Option;
|
use Rector\Core\Configuration\Option;
|
||||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||||
|
@ -39,11 +37,6 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||||
*/
|
*/
|
||||||
final class BetterStandardPrinter extends Standard
|
final class BetterStandardPrinter extends Standard
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @readonly
|
|
||||||
* @var \Rector\Comments\NodeDocBlock\DocBlockUpdater
|
|
||||||
*/
|
|
||||||
private $docBlockUpdater;
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
* @see https://regex101.com/r/DrsMY4/1
|
* @see https://regex101.com/r/DrsMY4/1
|
||||||
|
@ -60,9 +53,8 @@ final class BetterStandardPrinter extends Standard
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private const REPLACE_COLON_WITH_SPACE_REGEX = '#(^.*function .*\\(.*\\)) : #';
|
private const REPLACE_COLON_WITH_SPACE_REGEX = '#(^.*function .*\\(.*\\)) : #';
|
||||||
public function __construct(DocBlockUpdater $docBlockUpdater)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->docBlockUpdater = $docBlockUpdater;
|
|
||||||
parent::__construct(['shortArraySyntax' => \true]);
|
parent::__construct(['shortArraySyntax' => \true]);
|
||||||
// print return type double colon right after the bracket "function(): string"
|
// print return type double colon right after the bracket "function(): string"
|
||||||
$this->initializeInsertionMap();
|
$this->initializeInsertionMap();
|
||||||
|
@ -187,7 +179,6 @@ final class BetterStandardPrinter extends Standard
|
||||||
{
|
{
|
||||||
// reindex positions for printer
|
// reindex positions for printer
|
||||||
$nodes = \array_values($nodes);
|
$nodes = \array_values($nodes);
|
||||||
$this->moveCommentsFromAttributeObjectToCommentsAttribute($nodes);
|
|
||||||
$content = parent::pArray($nodes, $origNodes, $pos, $indentAdjustment, $parentNodeType, $subNodeName, $fixup);
|
$content = parent::pArray($nodes, $origNodes, $pos, $indentAdjustment, $parentNodeType, $subNodeName, $fixup);
|
||||||
if ($content === null) {
|
if ($content === null) {
|
||||||
return $content;
|
return $content;
|
||||||
|
@ -406,19 +397,6 @@ final class BetterStandardPrinter extends Standard
|
||||||
}
|
}
|
||||||
return $stmts;
|
return $stmts;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param array<Node|null> $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
|
* @param Node[] $nodes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433::getLoader();
|
return ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298::getLoader();
|
||||||
|
|
|
@ -951,7 +951,6 @@ return array(
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocClassRenamer' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php',
|
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocClassRenamer' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php',
|
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTypeChanger' => $baseDir . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.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\\PhpDocNodeFinder\\PhpDocNodeByTypeFinder' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php',
|
'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php',
|
'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => $baseDir . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433
|
class ComposerAutoloaderInite0dc58a2abf8b2ef17f09118048a0298
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc2db957c3ce342c948d5b630218dd433
|
||||||
return self::$loader;
|
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__));
|
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';
|
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->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$files;
|
$filesToLoad = \Composer\Autoload\ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$files;
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInitc2db957c3ce342c948d5b630218dd433
|
class ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
'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\\PhpDocClassRenamer' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php',
|
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTagRemover' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTagRemover.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocManipulator\\PhpDocTypeChanger' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.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\\PhpDocNodeFinder\\PhpDocNodeByTypeFinder' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeFinder/PhpDocNodeByTypeFinder.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php',
|
'Rector\\BetterPhpDocParser\\PhpDocNodeMapper' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeMapper.php',
|
||||||
'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php',
|
'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\ArrayTypePhpDocNodeVisitor' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php',
|
||||||
|
@ -2593,9 +2592,9 @@ class ComposerStaticInitc2db957c3ce342c948d5b630218dd433
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInitc2db957c3ce342c948d5b630218dd433::$classMap;
|
$loader->classMap = ComposerStaticInite0dc58a2abf8b2ef17f09118048a0298::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1744,12 +1744,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
|
||||||
"reference": "c8420dcc698c05de5f85fc7d21bd05b66ceb60dc"
|
"reference": "7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c8420dcc698c05de5f85fc7d21bd05b66ceb60dc",
|
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6",
|
||||||
"reference": "c8420dcc698c05de5f85fc7d21bd05b66ceb60dc",
|
"reference": "7f9e1329d06b0b90b36dd310b562a27cfd7b6aa6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1774,7 +1774,7 @@
|
||||||
"tomasvotruba\/type-coverage": "^0.2",
|
"tomasvotruba\/type-coverage": "^0.2",
|
||||||
"tomasvotruba\/unused-public": "^0.3"
|
"tomasvotruba\/unused-public": "^0.3"
|
||||||
},
|
},
|
||||||
"time": "2023-09-11T18:26:33+00:00",
|
"time": "2023-09-11T18:44:21+00:00",
|
||||||
"default-branch": true,
|
"default-branch": true,
|
||||||
"type": "rector-extension",
|
"type": "rector-extension",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||||
*/
|
*/
|
||||||
final class GeneratedConfig
|
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()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue