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

Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase #2850

Closed
kwhat opened this issue Feb 2, 2020 · 3 comments
Closed

Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase #2850

kwhat opened this issue Feb 2, 2020 · 3 comments

Comments

@kwhat
Copy link

kwhat commented Feb 2, 2020

phpcs --standard=PSR1,PSR2,PSR12 pharstub.php

----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] PHP keywords must be lowercase; expected
   |       |     "__halt_compiler" but found "__HALT_COMPILER"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

The problem is that despite what the documentation would suggest, this function must be upper case for include phar:///path/archive.phar/public/index.php to work from the phar stub. Seriously, I cannot make this stuff up:

PHP message: PHP Warning: include(): Failed opening 'public/index.php' for inclusion (include_path='phar:///tmp/archive.phar:.:/usr/share/php7:/usr/share/php') in /tmp/archive.phar on line 6"

Switching __halt_compiler() to __HALT_COMPILER() resolves this issue.

See halt-compiler vs phar.stub

@gsherwood
Copy link
Member

Yep, I used in uppercase in the PHPCS phar stubs as well. I'll remove it from the sniff.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Feb 2, 2020
@gsherwood gsherwood added this to the 3.5.5 milestone Feb 2, 2020
@kwhat
Copy link
Author

kwhat commented Feb 3, 2020

Thanks for taking care of these bugs so quickly. I have investigated this issue and found the source of the problem at https://github.com/php/php-src/blob/6e630fe79b734c0923d8dc0a7b622983e68dad58/ext/phar/phar.c#L1582 I will see if I can fix this and some of the many bugs I have come accross in phar upstream at some point in the near future.

@gsherwood gsherwood changed the title PSR1,PSR2,PSR12 complains __HALT_COMPILER is uppercase Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase Feb 18, 2020
gsherwood added a commit that referenced this issue Feb 18, 2020
gsherwood added a commit that referenced this issue Feb 18, 2020
@gsherwood
Copy link
Member

__HALT_COMPILER is now ignored by this sniff. The change will be in 3.5.5. Thanks for reporting this.

PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

No branches or pull requests

2 participants