1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-10 23:18:40 +01:00
psalm/src/Psalm/Internal/PhpVisitor/ShortClosureVisitor.php
orklah ffe7874906
Misc improvements (#4314)
* extract the operation out of the loop when possible

* remove unnecessary interfaces when already inherited in parent

* simplify expressions

* avoid using alias functions

* redundant phpdoc

* unused imports
2020-10-15 13:23:35 -04:00

33 lines
633 B
PHP

<?php
namespace Psalm\Internal\PhpVisitor;
use PhpParser;
/**
* @internal
*/
class ShortClosureVisitor extends PhpParser\NodeVisitorAbstract
{
/**
* @var array<string, bool>
*/
protected $used_variables = [];
public function enterNode(PhpParser\Node $node): ?int
{
if ($node instanceof PhpParser\Node\Expr\Variable && \is_string($node->name)) {
$this->used_variables['$' . $node->name] = true;
}
return null;
}
/**
* @return array<string, bool>
*/
public function getUsedVariables(): array
{
return $this->used_variables;
}
}