mirror of
https://github.com/danog/psalm.git
synced 2025-01-05 20:48:45 +01:00
37 lines
771 B
PHP
37 lines
771 B
PHP
|
<?php
|
||
|
namespace Psalm\Internal\Visitor;
|
||
|
|
||
|
use PhpParser;
|
||
|
use Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer;
|
||
|
|
||
|
/**
|
||
|
* @internal
|
||
|
*/
|
||
|
class ShortClosureVisitor extends PhpParser\NodeVisitorAbstract implements PhpParser\NodeVisitor
|
||
|
{
|
||
|
/**
|
||
|
* @var array<string, bool>
|
||
|
*/
|
||
|
protected $used_variables = [];
|
||
|
|
||
|
/**
|
||
|
* @param PhpParser\Node $node
|
||
|
*
|
||
|
* @return null|int
|
||
|
*/
|
||
|
public function enterNode(PhpParser\Node $node)
|
||
|
{
|
||
|
if ($node instanceof PhpParser\Node\Expr\Variable && \is_string($node->name)) {
|
||
|
$this->used_variables['$' . $node->name] = true;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array<string, bool>
|
||
|
*/
|
||
|
public function getUsedVariables()
|
||
|
{
|
||
|
return $this->used_variables;
|
||
|
}
|
||
|
}
|