Bug #60724 [Opn->Csd]: Includes fails at compile time when using bracketed namespaces

From: Date: Wed, 05 Feb 2014 14:29:02 +0000
Subject: Bug #60724 [Opn->Csd]: Includes fails at compile time when using bracketed namespaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184166@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60724&edit=1 ID: 60724 Updated by: jpauli@php.net Reported by: nicolas dot grekas+php at gmail dot com Summary: Includes fails at compile time when using bracketed namespaces -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem PHP Version: 5.4.4 -Assigned To: +Assigned To: jpauli Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is exepected behavior. E_STRICT often happens when the engine is in compilation phase. The compiler is not re-entrant, then when the error is triggered, the second eval() is run, which itself triggers compilation while the preceding compilation phase is not cleared yet. The second eval() then suffers from the compilation context of the first one. We can't change that. We, however, could add an error in the eval() OPCode to check for unclean previous compiler state. Previous Comments: ------------------------------------------------------------------------ [2012-08-07 11:37:44] nicolas dot grekas+php at gmail dot com The bug is still there is the latest version of PHP ------------------------------------------------------------------------ [2012-01-12 10:25:09] nicolas dot grekas+php at gmail dot com Description: ------------ Tested in 5.3.8, 5.2.9 and 5.4RC5, APC not enabled. At compile time, two nested includes fail when both use bracketed namespaces or mix bracketed and unbracketed ones. The compile time behavior of PHP is described in: https://bugs.php.net/bug.php?id=42098 I found a workaround that makes me think that some internal state is not initialized correctly when using namespaces. See test script for more details. Test script: --------------- <?php // This test script uses eval, but the same arise when including files. error_reporting(E_ALL | E_STRICT); set_error_handler('eh'); // The code in the eval triggers an E_DEPRECATED because of "=& new" // so eh() is called to handle the error, _at_compile_time_. // Note the unbracketed namespace declaration. eval('namespace b; $a =& new \stdClass; '); function eh() { // dynamically load class a\abc, // using bracketed namespace declaration // but this fails with fatal error. // uncomment the following line, and things work again perfectly. //eval(';'); eval('namespace a{ class abc{} }'); print_r(new a\abc); } Expected result: ---------------- No error Actual result: -------------- Fatal error: Cannot mix bracketed namespace declarations with unbracketed namespace declarations ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60724&edit=1

« previous php.bugs (#184166) next »