Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse files that contain namespaces and variables passed by reference #17

Open
zackkatz opened this issue May 26, 2023 · 1 comment

Comments

@zackkatz
Copy link

zackkatz commented May 26, 2023

If I place a single use statement at the top of a file, none of the actions or filters get parsed.

This wouldn't find the example filter:

<?php // Just an example
use GV\Utils;

apply_filters( 'example', 'just an' );

But this would:

<?php // Just an example

apply_filters( 'example', 'just an' );

This also applies to namespaces inside _deprecated_function() calls. This blocks all filters for the file:

_deprecated_function( __METHOD__, '2.0', '\GV\Widget::registered()' );

but removing the namespace fixes it:

_deprecated_function( __METHOD__, '2.0', 'Widget::registered()' );

Same with variables passed by reference. This blocks all parsing for a file:

foreach( $examples as &$example ) {

and this works:

foreach( $examples as $example ) {

When running the command (./vendor/bin/wp-hooks-generator --input ./ --output docs), I get many errors like this:

Warning: Undefined array key 265 in [path]/wp-content/plugins/GravityView/vendor/nikic/php-parser/lib/PhpParser/Lexer.php on line 195

Warning: Undefined array key "" in [path]/wp-content/plugins/GravityView/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 173

Warning: Undefined array key "" in [path]/wp-content/plugins/GravityView/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 335
Parse Error: Syntax error, unexpected , expecting T_STRING or T_NS_SEPARATOR or '{' on line 10

Here's my composer.json and composer.lock file. Hopefully that helps. Please let me know if I'm able to help figure out what's going on here.

@zackkatz
Copy link
Author

zackkatz commented May 26, 2023

I see this is actually an issue with WordPress/phpdoc-parser#231

And the pass-by-reference issue may somehow be related to WordPress/phpdoc-parser#176

And the PHP warnings are all PHP 8 issues (switching to 7.4 removed them all).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant