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

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

* comment update
This commit is contained in:
Abdul Malik Ikhsan 2021-12-22 17:50:34 +07:00 committed by GitHub
parent 6861ae9a4f
commit 3f80cd0543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,6 @@ namespace Rector\Core\ProcessAnalyzer;
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;
@ -17,10 +16,9 @@ use Rector\Core\ValueObject\RectifiedNode;
*
* 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.
*/
@ -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();