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

36 lines
664 B
PHP
Raw Normal View History

<?php
2020-03-15 04:54:42 +01:00
namespace Psalm\Internal\PhpVisitor;
use PhpParser;
2021-12-03 21:07:25 +01:00
use function is_string;
/**
* @internal
*/
class ShortClosureVisitor extends PhpParser\NodeVisitorAbstract
{
/**
* @var array<string, bool>
*/
2022-12-14 01:52:54 +01:00
protected array $used_variables = [];
public function enterNode(PhpParser\Node $node): ?int
{
2021-12-03 21:07:25 +01:00
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;
}
}