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

Broken PHPUnit tests #206

Open
keesiemeijer opened this issue Nov 1, 2018 · 3 comments
Open

Broken PHPUnit tests #206

keesiemeijer opened this issue Nov 1, 2018 · 3 comments

Comments

@keesiemeijer
Copy link
Contributor

Before commit e482b28 the PHPUnit tests used to work with PHPUnit 4. Now I get this error for half of the unit tests.

1) WP_Parser\Tests\Export_Docblocks::test_linebreaks_removed
Undefined property: PhpParser\Node\Stmt\Function_::$uses

/app/public/wp-content/plugins/phpdoc-parser/lib/class-file-reflector.php:174
/app/public/wp-content/plugins/phpdoc-parser/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:133
/app/public/wp-content/plugins/phpdoc-parser/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64
/app/public/wp-content/plugins/phpdoc-parser/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Traverser.php:52
/app/public/wp-content/plugins/phpdoc-parser/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FileReflector.php:163
/app/public/wp-content/plugins/phpdoc-parser/lib/runner.php:56
/app/public/wp-content/plugins/phpdoc-parser/tests/phpunit/includes/export-testcase.php:31
/app/public/wp-content/plugins/phpdoc-parser/tests/phpunit/includes/export-testcase.php:44
@keesiemeijer
Copy link
Contributor Author

It seems that parsed empty functions (that have no uses) are the cause of this change.

Example
https://github.com/WordPress/phpdoc-parser/blob/master/tests/phpunit/tests/export/namespace.inc#L5

@keesiemeijer
Copy link
Contributor Author

keesiemeijer commented Nov 2, 2018

We should check if a function has uses here
https://github.com/WordPress/phpdoc-parser/blob/master/lib/class-file-reflector.php#L174

something like this

$function = array_pop( $this->location );
if( isset( $function->uses ) && ! empty( $function->uses ) ) {
	end( $this->functions )->uses = $function->uses;
}

Because phpdocumentor/reflection 3 now uses nikic/php-parser 1 as a dependency we should also use the namespaced names as mentioned here
https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-1.0.md

keesiemeijer added a commit to keesiemeijer/phpdoc-parser that referenced this issue Jan 30, 2019
Fixes errors for nikic/php-parser v1.2.0+ by checking the  property.
See issue WordPress#206
@maheshwaghmare
Copy link

I'm also getting same error:

Undefined property: PhpParser\Node\Stmt\Function_::$uses in ..
Undefined property: PhpParser\Node\Expr\BinaryOp\Concat::$value ..

coffee2code added a commit that referenced this issue Nov 19, 2020
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

2 participants