Broken PHPUnit tests
Before commit e482b28d6cb3761f0a2d69a2ea97fd19a0b22e7a 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
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
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
I'm also getting same error:
Undefined property: PhpParser\Node\Stmt\Function_::$uses in ..
Undefined property: PhpParser\Node\Expr\BinaryOp\Concat::$value ..