Bug #75850 [Opn->Ver]: Unclear error message wrt. __halt_compiler() w/o semicolon
| From: | cmb@php.net | Date: | Mon, 25 Jan 2021 16:19:00 +0000 |
| Subject: | Bug #75850 [Opn->Ver]: Unclear error message wrt. __halt_compiler() w/o semicolon | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231763@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75850&edit=1
ID: 75850
Updated by: cmb@php.net
Reported by: anrdaemon at freemail dot ru
-Summary: Incorrect PHAR stub parsing with __halt_compiler()
using implied semicolon
+Summary: Unclear error message wrt. __halt_compiler() w/o
semicolon
-Status: Open
+Status: Verified
Type: Bug
Package: PHAR related
Operating System: unrelated
PHP Version: 7.1.13
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2018-01-20 09:40:59] requinix@php.net
?> does imply ; however the Phar stub docs
http://php.net/manual/en/phar.fileformat.stub.php
require "that it conclude with __HALT_COMPILER();". Indeed, Phar internally looks for that
exact (case-insensitive) string.
This could be a request to support dropping the semicolon, but changing the message is certainly
easy enough.
------------------------------------------------------------------------
[2018-01-20 09:21:45] anrdaemon at freemail dot ru
Description:
------------
Unable to use stub with "?>" token present but ";" omitted after
__halt_compiler().
According to PHP parsing rules, "?>" implies ";". (In other words, the stub
itself executes cleanly, which makes it extra hard to realize the source of confusion.)
At the very least, the error message could be clearer.
Test script:
---------------
<?php
(new Phar("test.phar"))->setStub("<?php __halt_compiler()?>");
Expected result:
----------------
A
test.phar example created.
Actual result:
--------------
PHP Fatal error: Uncaught PharException: illegal stub for phar ".../test.phar" in
.../case2.php:3
Stack trace:
#0 .../case2.php(3): Phar->setStub('<?php __halt_co...')
#1 {main}
thrown in .../case2.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75850&edit=1