You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is meant that the expected type is an array of objects that implement both interfaces, because the Visitor interface only has the init() method and can therefore not be used with PhpParser\NodeTraverser:: addVisitor().
A type-safe fix would mean to separate the Visitor interface to a PhpVisitorInterface, that has an init() method and extends PhpParser\NodeVisitor.
The current implementation seems to try to keep the visitor implementations sort of abstract by having a single main interface, but different implementations of the visitor need to implement different additional interfaces -- so that is basically not type safe at all right now.
I see two possible solutions:
introduce new specialized interfaces PhpVisitorInterface extends NodeVisitor, Visitor
do manual instanceof checks in the extractor.
I can prepare a PR, please just tell me which solution you prefer.
Hi,
the
PhpFileExtractor
is callinginit()
on every visitor:extractor/src/FileExtractor/PHPFileExtractor.php
Line 38 in 82fc51a
although one of the allowed types is
PhpParser\NodeVisitor
, which doesn't have aninit()
method: https://github.com/nikic/PHP-Parser/blob/3f718ee2c3a22b656773476f19dd8d72a50e2413/lib/PhpParser/NodeVisitor.phpThe text was updated successfully, but these errors were encountered: