Skip to content

Commit

Permalink
TASK: Fix non idempotent rector (#3441)
Browse files Browse the repository at this point in the history
* TASK: Fix idempotent rector

Resolves: #3234

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
sabbelasichon and actions-user authored Jul 31, 2023
1 parent f1118d9 commit 2cade62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Rector/v12/v0/typo3/AbstractMessageGetSeverityRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Identifier;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand Down Expand Up @@ -38,6 +39,12 @@ public function refactor(Node $node)
return null;
}

$nextNode = $this->betterNodeFinder->resolveNextNode($node);

if ($nextNode instanceof Identifier && $this->isName($nextNode, 'value')) {
return null;
}

return $this->nodeFactory->createPropertyFetch($node, 'value');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use \TYPO3\CMS\Core\Messaging\FlashMessage;

$flashMessage = new FlashMessage('This is a message');
$severityAsInt = $flashMessage->getSeverity();
$severityValue = $flashMessage->getSeverity()->value;
?>
-----
<?php
Expand All @@ -16,4 +17,5 @@ use \TYPO3\CMS\Core\Messaging\FlashMessage;

$flashMessage = new FlashMessage('This is a message');
$severityAsInt = $flashMessage->getSeverity()->value;
$severityValue = $flashMessage->getSeverity()->value;
?>

0 comments on commit 2cade62

Please sign in to comment.