1

I am running PHP unit as follows:

phpunit --debug --verbose --coverage-clover=/tmp/test.xml

and get the following error:

Fatal error: Class 'PHP_Token_OPEN_TAG' not found in /opt/pear/share/pear/PHP/Token/Stream.php on line 205

The stack trace leads down to

12. PHP_Token_Stream->scan($sourceCode = '<?php\n/**\n...') /opt/pear/share/pear/PHP/Token/Stream.php:147

The source code is syntactically okay.

This class is defined in /opt/pear/share/pear/PHP/Token.php but it looks like it can not be found.

2 Answers 2

2

I dumped the output of spl_autoload_functions() in Stream.php:147 and found out, that there is some Aitoc autoloader.

The problem is caused by an Aitoc Magento extension.

They have a function that simply unregisters all autoloaders.

$autoloaders = spl_autoload_functions();
if ($autoloaders and is_array($autoloaders) && !empty($autoloaders))
{
    foreach ($autoloaders as $autoloader)
    {
        spl_autoload_unregister($autoloader);
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Seems like a versioning / autoloading Problem as the token package or the code coverage package might not be installed/updated correctly.

Give

(sudo) pear install --force --alldeps phpunit/phpunit 

a try. That usually fixes those "strange errors".

1 Comment

Unfortunately that does not help. Also other projects on the same server do not cause that problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.