Skip to content

Commit

Permalink
more precise BetterNodeFinder types
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab committed Jan 7, 2022
1 parent 111bf5d commit 03e3762
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/PhpParser/Node/BetterNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public function findFirstNonAnonymousClass(array $nodes): ?Node

/**
* @param Node|Node[] $nodes
* @param callable(Node $node): bool $filter
*/
public function findFirst(Node | array $nodes, callable $filter): ?Node
{
Expand Down Expand Up @@ -274,6 +275,9 @@ public function findPreviousAssignToExpr(Expr $expr): ?Node
});
}

/**
* @param callable(Node $node): bool $filter
*/
public function findFirstPreviousOfNode(Node $node, callable $filter): ?Node
{
// move to previous expression
Expand All @@ -300,6 +304,9 @@ public function findFirstPreviousOfNode(Node $node, callable $filter): ?Node
return null;
}

/**
* @param callable(Node $node): bool $filter
*/
public function findFirstPrevious(Node $node, callable $filter): ?Node
{
$node = $node instanceof Expression ? $node : $node->getAttribute(AttributeKey::CURRENT_STATEMENT);
Expand Down Expand Up @@ -339,6 +346,9 @@ public function findFirstPreviousOfTypes(Node $mainNode, array $types): ?Node
);
}

/**
* @param callable(Node $node): bool $filter
*/
public function findFirstNext(Node $node, callable $filter): ?Node
{
$next = $node->getAttribute(AttributeKey::NEXT_NODE);
Expand Down Expand Up @@ -530,6 +540,9 @@ private function findInstanceOfName(Node | array $nodes, string $type, string $n
return null;
}

/**
* @return Closure|Function_|ClassMethod|Class_|Namespace_|null
*/
private function findParentScope(Node $node): Node|null
{
return $this->findParentByTypes($node, [
Expand Down

0 comments on commit 03e3762

Please sign in to comment.