mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-15 15:42:22 +00:00
add VIRTUAL_NODE constant, prevent double post traversing nodes
This commit is contained in:
parent
233b1d9680
commit
34c40428f3
|
@ -44,6 +44,7 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
|
@ -73,6 +74,7 @@ expectedArguments(
|
|||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
|
|
|
@ -14,6 +14,11 @@ use Symplify\SmartFileSystem\SmartFileInfo;
|
|||
|
||||
final class AttributeKey
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const VIRTUAL_NODE = 'virtual_node';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
|
@ -99,7 +99,7 @@ final class NameImporter
|
|||
|
||||
private function shouldSkipName(Name $name): bool
|
||||
{
|
||||
if ($name->getAttribute('virtual_node')) {
|
||||
if ($name->getAttribute(AttributeKey::VIRTUAL_NODE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ final class FullyQualifiedObjectType extends ObjectType
|
|||
public function getShortNameNode(): Name
|
||||
{
|
||||
$name = new Name($this->getShortName());
|
||||
$name->setAttribute('virtual_node', true);
|
||||
$name->setAttribute(AttributeKey::VIRTUAL_NODE, true);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ final class ClassRenamer
|
|||
continue;
|
||||
}
|
||||
|
||||
if (! $implementName->getAttribute('virtual_node')) {
|
||||
if (! $implementName->getAttribute(AttributeKey::VIRTUAL_NODE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ final class FileProcessor
|
|||
$this->currentFileInfoProvider->setCurrentStmt($newStmts);
|
||||
|
||||
$newStmts = $this->rectorNodeTraverser->traverse($newStmts);
|
||||
$newStmts = $this->postFileProcessor->traverse($newStmts);
|
||||
|
||||
// this is needed for new tokens added in "afterTraverse()"
|
||||
$this->tokensByFilePathStorage->addForRealPath($smartFileInfo, $newStmts, $oldStmts, $oldTokens);
|
||||
|
|
|
@ -258,6 +258,10 @@ abstract class AbstractRectorTestCase extends AbstractGenericRectorTestCase
|
|||
$this->fileProcessor->parseFileInfoToLocalCache($originalFileInfo);
|
||||
$this->fileProcessor->refactor($originalFileInfo);
|
||||
|
||||
$this->fileProcessor->postFileRefactor($originalFileInfo);
|
||||
|
||||
// mimic post-rectors
|
||||
|
||||
$changedContent = $this->fileProcessor->printToString($originalFileInfo);
|
||||
|
||||
$causedByFixtureMessage = $fixtureFileInfo->getRelativeFilePathFromCwd();
|
||||
|
|
Loading…
Reference in New Issue
Block a user