From: robert at interjinn dot com Operating system: Linux PHP version: 5.1.1 PHP Bug Type: Scripting Engine problem Bug description: Erroneous "Class declarations may not be nested" error raised.
Description: ------------ PHP bails out with class declaration nesting error when an error handler dynamically loads an error handling class during a class related E_STRICT warning. Reproduce code: --------------- test.php <?php set_error_handler( 'errorHandler' ); function errorHandler ( $errorNumber, $errorMessage, $fileName, $lineNumber ) { require_once( 'errorClass.php' ); $error = new ErrorClass(); $error->handleException( $errorNumber, $errorMessage, $fileName, $lineNumber ); } require_once( 'testClass.php' ); $test = new TestClass(); ?> ------------------------------------------------- testClass.php <?php class TestClass { function __construct() { } function TestClass() { $this->__construct(); } } ?> ------------------------------------------------- errorClass.php <?php class ErrorClass { function handleException ( $errorNumber, $errorMessage, $fileName, $lineNumber ) { echo "Error: [$errorNumber] $errorMessage ($fileName:$lineNumber)\n"; } } ?> Expected result: ---------------- I expect to properly be able to handle the following E_STRICT in my custom error class: <br /> <b>Strict Standards</b>: Redefining already defined constructor for class TestClass in <b>/home/suds/testClass.php</b> on line <b>9</b><br /> Actual result: -------------- Fatal error: Class declarations may not be nested in /home/suds/errorClass.php on line 4 -- Edit bug report at http://bugs.php.net/?id=35634&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35634&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35634&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35634&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=35634&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35634&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35634&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35634&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35634&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35634&r=support Expected behavior: http://bugs.php.net/fix.php?id=35634&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35634&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35634&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35634&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35634&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35634&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35634&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35634&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35634&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35634&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35634&r=mysqlcfg