Skip to content

Commit

Permalink
[Core] Refactor RectifiedAnalyzer: no longer need check PhpDocInfo->h…
Browse files Browse the repository at this point in the history
…asChanged() (#1545)

* [Core] Refactor RectifiedAnalyzer: no longer need check PhpDocInfo->hasChanged()

* comment update
  • Loading branch information
samsonasik committed Dec 22, 2021
1 parent 6861ae9 commit 3f80cd0
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/ProcessAnalyzer/RectifiedAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Stmt\Class_;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\RectifiedNode;
Expand All @@ -17,10 +16,9 @@
*
* Same Rector Rule <-> Same Node <-> Same File
*
* Some limitations:
* Limitation:
*
* - only check against Node which not Assign or Class_
* - The checked node doesn't has PhpDocInfo changed.
* It only check against Node which not Assign or Class_
*
* which possibly changed by other process.
*/
Expand All @@ -36,22 +34,12 @@ final class RectifiedAnalyzer
*/
private array $previousFileWithNodes = [];

public function __construct(
private readonly PhpDocInfoFactory $phpDocInfoFactory
) {
}

public function verify(RectorInterface $rector, Node $node, File $currentFile): ?RectifiedNode
{
if (in_array($node::class, self::EXCLUDE_NODES, true)) {
return null;
}

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
if ($phpDocInfo->hasChanged()) {
return null;
}

$smartFileInfo = $currentFile->getSmartFileInfo();
$realPath = $smartFileInfo->getRealPath();

Expand Down

0 comments on commit 3f80cd0

Please sign in to comment.