Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Type/FileTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class FileTypeMapper

private const SKIP_NODE = 1;
private const POP_TYPE_MAP_STACK = 2;
private const DONT_TRAVERSE_CHILDREN = 3;

/** @var NameScope[][] */
private array $memoryCache = [];
Expand Down Expand Up @@ -319,6 +320,10 @@ function (Node $node) use ($fileName, $lookForTrait, &$traitFound, $traitMethodA
$phpDocNodeMap[$nameScopeKey] = $this->phpDocStringResolver->resolve($docComment);
}

if ($node instanceof Node\Stmt\ClassMethod || $node instanceof Node\Stmt\Function_) {
return self::DONT_TRAVERSE_CHILDREN;
}

return null;
} elseif ($node instanceof Node\PropertyHook) {
$propertyName = $node->getAttribute('propertyName');
Expand All @@ -330,7 +335,7 @@ function (Node $node) use ($fileName, $lookForTrait, &$traitFound, $traitMethodA
}
}

return null;
return self::DONT_TRAVERSE_CHILDREN;
}

if ($node instanceof Node\Stmt\Namespace_) {
Expand Down Expand Up @@ -821,9 +826,11 @@ private function processNodes($node, Closure $nodeCallback, Closure $endNodeCall
if ($callbackResult === self::SKIP_NODE) {
return;
}
foreach ($node->getSubNodeNames() as $subNodeName) {
$subNode = $node->{$subNodeName};
$this->processNodes($subNode, $nodeCallback, $endNodeCallback);
if ($callbackResult !== self::DONT_TRAVERSE_CHILDREN) {
foreach ($node->getSubNodeNames() as $subNodeName) {
$subNode = $node->{$subNodeName};
$this->processNodes($subNode, $nodeCallback, $endNodeCallback);
}
}
$endNodeCallback($node, $callbackResult);
} elseif (is_array($node)) {
Expand Down
Loading