php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55007 compiler fail after previous fail
Submitted: 2011-06-07 14:11 UTC Modified: 2011-06-08 00:58 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 3 (66.7%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: sebcsaba at freemail dot hu Assigned: felipe (profile)
Status: Closed Package: Compile Failure
PHP Version: 5.3.6 OS: winxp, ubuntu... (apache)
Private report: No CVE-ID: None
 [2011-06-07 14:11 UTC] sebcsaba at freemail dot hu
Description:
------------
If a class loading (eval or require_once) fails by an E_COMPILE_ERROR (e.g. "Cannot use [] for reading") inside a class declaration, the next class load parse will fail, (perhaps) because the compiler starts it's syntax tree stack from the error of previous class, and gives 'Class declarations may not be nested' fatal error.

Test script:
---------------
function __autoload($classname) {
  if ('CompileErrorClass'==$classname) eval('class CompileErrorClass { function foo() { $a[] } }');
  if ('MyErrorHandler'==$classname) eval('class MyErrorHandler { function __construct() { print "My error handler runs."; } }');
}

function shutdown() {
  new MyErrorHandler();
}


register_shutdown_function('shutdown');
	
new CompileErrorClass();


Expected result:
----------------
Fatal error: Cannot use [] for reading in D:\docroot\tests\bugreport.php(5) : eval()'d code on line 1

Fatal error: Class 'CompileErrorClass' not found in D:\docroot\tests\bugreport.php on line 16
My error handler runs.

Actual result:
--------------
Fatal error: Cannot use [] for reading in D:\docroot\tests\bugreport.php(5) : eval()'d code on line 1

Fatal error: Class declarations may not be nested in D:\docroot\tests\bugreport.php(6) : eval()'d code on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-08 00:58 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-06-08 00:58 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2011-06-08 00:58 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=311903
Log: - Fixed bug #55007 (compiler fail after previous fail)
 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bf07dcd506f4a8b7e1bf4601e1c75a20dca106f4
Log: - Fixed bug #55007 (compiler fail after previous fail)
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bf07dcd506f4a8b7e1bf4601e1c75a20dca106f4
Log: - Fixed bug #55007 (compiler fail after previous fail)
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of felipe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=bf07dcd506f4a8b7e1bf4601e1c75a20dca106f4
Log: - Fixed bug #55007 (compiler fail after previous fail)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC