|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75850 Incorrect PHAR stub parsing with __halt_compiler() using implied semicolon
Submitted: 2018-01-20 09:21 UTC Modified: 2018-01-20 09:40 UTC
From: anrdaemon at freemail dot ru Assigned:
Status: Open Package: PHAR related
PHP Version: 7.1.13 OS: unrelated
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-01-20 09:21 UTC] anrdaemon at freemail dot ru
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:

(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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-20 09:40 UTC]
-Summary: Incorrect PHAR stub parsing +Summary: Incorrect PHAR stub parsing with __halt_compiler() using implied semicolon
 [2018-01-20 09:40 UTC]
?> does imply ; however the Phar stub docs
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.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 13:01:25 2020 UTC