php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75850 Unclear error message wrt. __halt_compiler() w/o semicolon
Submitted: 2018-01-20 09:21 UTC Modified: 2021-01-25 16:18 UTC
From: anrdaemon at freemail dot ru Assigned: cmb (profile)
Status: Closed Package: PHAR related
PHP Version: 7.1.13 OS: unrelated
Private report: No CVE-ID: None
 [2018-01-20 09:21 UTC] 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


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-20 09:40 UTC] requinix@php.net
-Summary: Incorrect PHAR stub parsing +Summary: Incorrect PHAR stub parsing with __halt_compiler() using implied semicolon
 [2018-01-20 09:40 UTC] 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.
 [2021-01-25 16:18 UTC] cmb@php.net
-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 -Assigned To: +Assigned To: cmb
 [2021-01-25 16:19 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
On GitHub:  https://github.com/php/php-src/pull/6638
Patch:      https://github.com/php/php-src/pull/6638.patch
 [2021-01-25 17:50 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=61ed904cecbfd2eb6e5c39c22de3c215a2aee722
Log: Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
 [2021-01-25 17:50 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2021-01-27 06:53 UTC] anrdaemon at yandex dot ru
Thanks, much appreciated.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC