-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionScanner.php
More file actions
41 lines (34 loc) · 881 Bytes
/
Copy pathFunctionScanner.php
File metadata and controls
41 lines (34 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace Paths;
use \ast\Node;
use Paths\AST\Visitor\KindVisitorImplementation;
class FunctionScanner extends KindVisitorImplementation
{
/**
* The fallback implementation for node kinds where the subclass visitor
* didn't override the more specific `visit*()` method.
*
* @param Node $node
* @return \Generator
*/
public function visit(Node $node): \Generator
{
// Recurse into children
foreach ($node->children as $child) {
if ($child instanceof Node) {
foreach ($this($child) as $found) {
yield $found;
}
}
}
}
public function visitFuncDecl(Node $node): \Generator
{
yield $node;
}
public function visitMethod(Node $node): \Generator
{
yield $node;
}
}