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

RuntimeException : AspectMock couldn't parse some of files. #101

Closed
tereschenkov opened this issue Oct 17, 2013 · 2 comments
Closed

RuntimeException : AspectMock couldn't parse some of files. #101

tereschenkov opened this issue Oct 17, 2013 · 2 comments

Comments

@tereschenkov
Copy link

I've got this error with such code (originally from Twig library):

if (function_exists('mb_convert_encoding')) {
    function twig_convert_encoding($string, $to, $from)
    {
        return mb_convert_encoding($string, $to, $from);
    }
} elseif (function_exists('iconv')) {
    function twig_convert_encoding($string, $to, $from)
    {
        return iconv($from, $to, $string);
    }
} else {
    function twig_convert_encoding($string, $to, $from)
    {
        throw new Exception('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
    }
}

With such code I get this error (I'm using AspectMock library, but as I understand, this exception is thrown from Go! library):

RuntimeException : AspectMock couldn't parse some of files.
 Try to exclude them from parsing list.
There were following reasons for this exception:
Thrown when working with file "{root}\src\ProxyBundle\ProxyBundle.php" token stream.
The cause of the exception was the } token (line 29) in following part of \ProxyBundle source code:

 24: 
 25: } elseif (function_exists('iconv')) {
 26:     function twig_convert_encoding($string, $to, $from)
 27:     {
 28:         return iconv($from, $to, $string);
*29:     }
 30: } else {
 31:     function twig_convert_encoding($string, $to, $from)
 32:     {
 33:         throw new Exception('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
 34:     }
#0 \vendor\lisachenko\go-aop-php\src\Go\Instrument\Transformer\CachingTransformer.php(115): AspectMock\Intercept\BeforeMockTransformer->transform(Object(Go\Instrument\Transformer\StreamMetaData))
#1 \vendor\lisachenko\go-aop-php\src\Go\Instrument\Transformer\CachingTransformer.php(83): Go\Instrument\Transformer\CachingTransformer->processTransformers(Object(Go\Instrument\Transformer\StreamMetaData))
#2 \vendor\lisachenko\go-aop-php\src\Go\Instrument\ClassLoading\SourceTransformingLoader.php(156): Go\Instrument\Transformer\CachingTransformer->transform(Object(Go\Instrument\Transformer\StreamMetaData))
#3 \vendor\lisachenko\go-aop-php\src\Go\Instrument\ClassLoading\SourceTransformingLoader.php(111): Go\Instrument\ClassLoading\SourceTransformingLoader->transformCode(Object(Go\Instrument\Transformer\StreamMetaData))
#4 \vendor\lisachenko\go-aop-php\src\Go\Instrument\ClassLoading\AopComposerLoader.php(97): Go\Instrument\ClassLoading\SourceTransformingLoader->filter(Resource id #807, Resource id #808, 1004, true)
#5 \vendor\lisachenko\go-aop-php\src\Go\Instrument\ClassLoading\AopComposerLoader.php(97): Go\Instrument\ClassLoading\AopComposerLoader::loadClass()
#6 [internal function]: Go\Instrument\ClassLoading\AopComposerLoader->loadClass('ProxyBundle')
...
@lisachenko
Copy link
Member

Hello, thank you for the issue report, however this is not a bug for go-aop-php :) I'm using php-token-reflection to perform static analysis of source code and it can not handle dynamic definition of functions like this one. This is a known issue, my suggestion is to add this file to the blacklist in the kernel.

@tereschenkov
Copy link
Author

Ok then. I already added while twig library to a blacklist. Thanks

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

No branches or pull requests

2 participants