Php_codesniffer: Generic.PHP.LowerCaseKeyword complains __HALT_COMPILER is uppercase

Created on 2 Feb 2020  路  3Comments  路  Source: squizlabs/PHP_CodeSniffer

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

Bug

Most helpful comment

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

All 3 comments

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings