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

PHP Fatal error: Cannot redeclare class PHP_TokenWithScope #239

Closed
gambledor opened this issue Dec 11, 2015 · 3 comments
Closed

PHP Fatal error: Cannot redeclare class PHP_TokenWithScope #239

gambledor opened this issue Dec 11, 2015 · 3 comments

Comments

@gambledor
Copy link

Here there is the stack trace by "debug_print_backtrace"
#0 include() called at ['...'/vendor/goaop/framework/src/Instrument/ClassLoading/AopComposerLoader.php:97]
#1 Go\Instrument\ClassLoading\AopComposerLoader->loadClass(PHP_Token)
#2 spl_autoload_call(PHP_Token)
#3 class_exists(PHP_Token) called at ['...'/vendor/phpunit/phpunit/src/Util/Blacklist.php:91]
#4 PHPUnit_Util_Blacklist->initialize() called at ['...'/vendor/phpunit/phpunit/src/Util/Blacklist.php:58]
#5 PHPUnit_Util_Blacklist->getBlacklistedDirectories() called at ['...'/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:1055]
#6 PHPUnit_TextUI_TestRunner->getCodeCoverageFilter() called at ['...'/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:64]
#7 PHPUnit_TextUI_TestRunner->__construct() called at ['...'/vendor/phpunit/phpunit/src/TextUI/Command.php:178]
#8 PHPUnit_TextUI_Command->createRunner() called at ['...'/vendor/phpunit/phpunit/src/TextUI/Command.php:113]
#9 PHPUnit_TextUI_Command->run(Array ([0] => ./bin/phpunit,[1] => tests/app/Lib/Aspects/BrokerTest.php), 1) called at ['...'/vendor/phpunit/phpunit/src/TextUI/Command.php:100]
#10 PHPUnit_TextUI_Command::main() called at ['...'/vendor/phpunit/phpunit/phpunit:47]

PHPUnit 4.8.20 by Sebastian Bergmann and contributors.

EE

Time: 11.16 seconds, Memory: 29.75Mb

There were 2 errors:

  1. App\Lib\Aspects\BrokerTest::brokerCanBuyShares
    TokenReflection\Exception\ParseException: Unexpected token found.

'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php:1678
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php:1622
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:121
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:104
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionFileNamespace.php:299
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:122
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:104
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionFile.php:120
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/Broker.php:168
'...'/vendor/goaop/framework/src/Instrument/Transformer/WeavingTransformer.php:91
'...'/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:127
'...'/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:106
'...'/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:146
'...'/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:102
'...'/tests/TestCase.php:12
'...'/tests/TestCase.php:12
'...'/vendor/laravel/lumen-framework/src/Testing/ApplicationTrait.php:35
'...'/vendor/laravel/lumen-framework/src/Testing/TestCase.php:43

  1. App\Lib\Aspects\BrokerTest::brokerCanSellShares
    TokenReflection\Exception\ParseException: Unexpected token found.

'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php:1678
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionClass.php:1622
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:121
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:104
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionFileNamespace.php:299
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:122
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionElement.php:104
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionFile.php:120
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/ReflectionBase.php:73
'...'/vendor/andrewsville/php-token-reflection/TokenReflection/Broker.php:168
'...'/vendor/goaop/framework/src/Instrument/Transformer/WeavingTransformer.php:91
'...'/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:127
'...'/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:106
'...'/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:146
'...'/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:102
'...'/tests/TestCase.php:12
'...'/tests/TestCase.php:12
'...'/vendor/laravel/lumen-framework/src/Testing/ApplicationTrait.php:35
'...'/vendor/laravel/lumen-framework/src/Testing/TestCase.php:43

FAILURES!
Tests: 2, Assertions: 0, Errors: 2.

@lisachenko
Copy link
Member

Hello, sorry for the late response, I'm working hard now on my main job.

From the provided trace and exception message I can guess, that you are using PHP5.6 or PHP7 language syntax features and underlying andrewsville/php-token-reflection library which is not maintained now can and not handle this new PHP syntax.

I'm working on goaop/parser-reflection library, which will be compatible with PHP5.6 and PHP7, after that I will migrate my framework on it and release a new version for that.

To avoid such errors, try to exclude all directories where aspect should not be applied (e.g. vendor directory) and whitelist only source directory for your project (e.g. src directory). This will help you to skip source code analysis for external project files.

@gambledor
Copy link
Author

Hello,
I already tried your suggested solution but did not work since Laravel TestCase massively uses Traits.
I'm looking forward to try your next effort.

@lisachenko
Copy link
Member

Version 2.x uses new parser engine and can handle all valid PHP5.6 and PHP7 syntax. So this issue should be solved.

@lisachenko lisachenko added this to the 2.0.0 milestone May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants