Skip to content
Merged
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: 0 additions & 15 deletions src/PhpParser/Node/BetterNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,6 @@ public function findFirstPrevious(Node $node, callable $filter): ?Node
return null;
}

/**
* @api
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this method was api before, should we at least mark it as deprecated in a few releases before dropping it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findFirstPrevious() still available -- for now --, it basically just shortcut with only pass type instead of callable filter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO for good DX we would change api only when really required.

Even if this method is no longer used in rector-src it might have been used by people in custom rules. Therefore I think we should keep it but mark it as deprecated for at least a few releases, before dropping it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let @TomasVotruba decide on that if it going to be reverted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method was rarely used, so its ok. Also refactoring to parent nodes should start as soon as possible, to get other packages who use it into new shape.

* @template T of Node
*
* @param array<class-string<T>> $types
* @return T|null
*/
public function findFirstPreviousOfTypes(Node $mainNode, array $types): ?Node
{
return $this->findFirstPrevious(
$mainNode,
fn (Node $node): bool => $this->multiInstanceofChecker->isInstanceOf($node, $types)
);
}

/**
* @param callable(Node $node): bool $filter
*/
Expand Down