Skip to content

Commit

Permalink
[Core] Use parent attribute check instead of origNode for check updat…
Browse files Browse the repository at this point in the history
…e and connect parent node after refactor (#3054)

* [Core] Use parent attribute check instead of origNode for check update and connect parent node after refactor

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
samsonasik and actions-user committed Nov 12, 2022
1 parent a8fd5aa commit 64f4a55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rules/Php80/Rector/FunctionLike/MixedTypeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down Expand Up @@ -142,7 +143,7 @@ private function refactorParamTypes(
$this->hasChanged = true;
$param->type = new Identifier('mixed');
if ($param->flags !== 0) {
$param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE, null);
$param->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ final public function enterNode(Node $node)
* - Expression on Assign with ArrowFunction changed to Closure
* - Return_ on ArrowFunction usage, Return_ is created dynamically on getStmts()
*
* 2. When returned refactored Node doesn't has origNode yet,
* 2. When returned refactored Node doesn't has parent yet,
* it means returned with New Node instead of re-use existing Node
*/
if (
$refactoredNode instanceof Expression
|| $refactoredNode instanceof Return_
|| ! $refactoredNode->hasAttribute(AttributeKey::ORIGINAL_NODE)
|| ! $refactoredNode->hasAttribute(AttributeKey::PARENT_NODE)
) {
$this->updateAndconnectParentNodes($refactoredNode, $parentNode);
}
Expand Down

0 comments on commit 64f4a55

Please sign in to comment.