2018-07-03 18:27:14 +02:00
|
|
|
<?php
|
2020-03-15 04:54:42 +01:00
|
|
|
namespace Psalm\Internal\PhpVisitor;
|
2018-07-03 18:27:14 +02:00
|
|
|
|
|
|
|
use PhpParser;
|
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2018-07-03 18:27:14 +02:00
|
|
|
class NodeCleanerVisitor extends PhpParser\NodeVisitorAbstract implements PhpParser\NodeVisitor
|
|
|
|
{
|
2019-11-25 17:44:54 +01:00
|
|
|
private $type_provider;
|
|
|
|
|
|
|
|
public function __construct(\Psalm\Internal\Provider\NodeDataProvider $type_provider)
|
|
|
|
{
|
|
|
|
$this->type_provider = $type_provider;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function enterNode(PhpParser\Node $node): ?int
|
2018-07-03 18:27:14 +02:00
|
|
|
{
|
2019-11-25 17:44:54 +01:00
|
|
|
if ($node instanceof PhpParser\Node\Expr) {
|
|
|
|
$this->type_provider->clearNodeOfTypeAndAssertions($node);
|
|
|
|
}
|
2018-07-03 18:27:14 +02:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|