Bug #77561 [NEW]: PHAR bootstrap script with shebang and strict types does not work

From: Date: Sun, 03 Feb 2019 17:46:54 +0000
Subject: Bug #77561 [NEW]: PHAR bootstrap script with shebang and strict types does not work
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219345@lists.php.net to get a copy of this message
From: sebastian Operating system: Irrelevant PHP version: 7.3.1 Package: PHAR related Bug Type: Bug Bug description:PHAR bootstrap script with shebang and strict types does not work Description: ------------ It seems that there is a bug in PHP that when a PHAR is include()d or require()d and the PHAR's bootstrap script has a shebang such as "#!/usr/bin/env php" on its first line followed by "<?php declare(strict_types=1);" on its second line then PHP wrongly triggers a "strict_types declaration must be the very first statement in the script" compiler error. See https://github.com/sebastianbergmann/phpunit/issues/3509 for an issue that showcases this problem in the context of PHPUnit's phpunit.phar. I discussed this with Nikita who said "The strict_types error is correct, because the shebang line is interpreted as literal output (and will be printed to stdout unless you intercept that somehow). Shebangs are only stripped from the primary script if run via CLI. It would probably make sense to always strip them instead. This can probably only be fixed in 7.4 at the earliest, as it's a BC breaking change. Unless there is some phar-specific interaction here where it already strips the shebang but not for the purpose of strict_types handling)." -- Edit bug report at https://bugs.php.net/bug.php?id=77561&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77561&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77561&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77561&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77561&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77561&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77561&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77561&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77561&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77561&r=support Expected behavior: https://bugs.php.net/fix.php?id=77561&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77561&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77561&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77561&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77561&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77561&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77561&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77561&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77561&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77561&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77561&r=mysqlcfg

« previous php.bugs (#219345) next »