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

Warning: declare(encoding=...) ignored because Zend multibyte feature is turned off by settings in string code #1076

Closed
Synchro opened this issue Aug 29, 2017 · 7 comments
Labels
bug A crash in Phan, a recent change causing incorrect analysis results, etc.

Comments

@Synchro
Copy link

Synchro commented Aug 29, 2017

This may be true, but it should be trapped and reported better, along with advice on how to fix.

@TysonAndre
Copy link
Member

What PHP version, phan version?

What file is that warning emitted from?

What are the steps to reproduce? The PHP in settings used?

@Synchro
Copy link
Author

Synchro commented Aug 29, 2017

Sorry. PHP 7.1.8, phan 0.9.4. Call stack:

Warning: declare(encoding=...) ignored because Zend multibyte feature is turned off by settings in string code on line 17

Call Stack:
    0.0003     356696   1. {main}() /Users/marcus/.composer/vendor/etsy/phan/phan:0
    0.0006     365056   2. require_once('/Users/marcus/.composer/vendor/etsy/phan/src/phan.php') /Users/marcus/.composer/vendor/etsy/phan/phan:2
    4.5717   34069320   3. Phan\Phan::analyzeFileList() /Users/marcus/.composer/vendor/etsy/phan/src/phan.php:54
   40.3803  416905312   4. Phan\Analysis::parseFile() /Users/marcus/.composer/vendor/etsy/phan/src/Phan/Phan.php:129
   40.3806  416905584   5. ast\parse_code() /Users/marcus/.composer/vendor/etsy/phan/src/Phan/Analysis.php:76

The only use of declare() I've found is for strict_types=1.

@TysonAndre
Copy link
Member

declare(encoding=...) was probably part of the project being parsed, e.g. vendor.

The lack of multibyte support probably affects the strings (e.g. string literals, unicode class names) that ast\parse_code('', version) returns.

Maybe printing a suppressable message to stderr if a lack of multibyte support is detected would help

@Synchro
Copy link
Author

Synchro commented Aug 30, 2017

Indeed, I found occurrences in my vendor folder:

vendor/wimg/php-compatibility/Tests/sniff-examples/new_execution_directives.php:declare(encoding='ISO-8859-1');
vendor/wimg/php-compatibility/Tests/sniff-examples/new_execution_directives.php:declare(encoding='invalid'); // Invalid - not a valid encoding.

@TysonAndre
Copy link
Member

This still should be fixed, but:

You may want to look at https://github.com/phan/phan/wiki/Speeding-up-Phan-Analysis#3-reduce-the-number-of-files-phan-parses.

E.g. add the following section to your .phan/config.php for the project to exclude tests

 'exclude_file_regex' => '@^vendor/.*/(tests|Tests)/@',   

@TysonAndre TysonAndre added the bug A crash in Phan, a recent change causing incorrect analysis results, etc. label Sep 2, 2017
@AjkP
Copy link

AjkP commented Sep 5, 2017

Confirming seeing this warning. +1 for clearer error messages in general.

Fixing the exculde_file_regex worked fine for me.

@Synchro
Copy link
Author

Synchro commented Feb 28, 2019

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash in Phan, a recent change causing incorrect analysis results, etc.
Projects
None yet
Development

No branches or pull requests

3 participants