2021-04-06 17:33:09 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2021-04-06 17:33:09 +00:00
|
|
|
namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
|
|
|
|
|
|
|
|
use PHPStan\PhpDocParser\Ast\Node;
|
|
|
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
2021-08-08 00:26:40 +00:00
|
|
|
use RectorPrefix20210808\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
|
|
|
final class ChangedPhpDocNodeVisitor extends \RectorPrefix20210808\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
private $hasChanged = \false;
|
2021-07-05 23:06:30 +00:00
|
|
|
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
2021-05-09 20:15:43 +00:00
|
|
|
$this->hasChanged = \false;
|
2021-04-06 17:33:09 +00:00
|
|
|
}
|
2021-07-05 23:06:30 +00:00
|
|
|
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
2021-05-10 22:23:08 +00:00
|
|
|
$origNode = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE);
|
2021-04-06 17:33:09 +00:00
|
|
|
if ($origNode === null) {
|
2021-05-09 20:15:43 +00:00
|
|
|
$this->hasChanged = \true;
|
2021-04-06 17:33:09 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2021-05-09 20:15:43 +00:00
|
|
|
public function hasChanged() : bool
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
|
|
|
return $this->hasChanged;
|
|
|
|
}
|
|
|
|
}
|