Bug #60724 [Opn]: Includes fails at compile time when using bracketed namespaces
| From: | nicolas dot grekas+php at gmail dot com | Date: | Tue, 07 Aug 2012 11:37:44 +0000 |
| Subject: | Bug #60724 [Opn]: Includes fails at compile time when using bracketed namespaces | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172485@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
User updated by: nicolas dot grekas+php at gmail dot com
Reported by: nicolas dot grekas+php at gmail dot com
Summary: Includes fails at compile time when using bracketed
namespaces
Status: Open
Type: Bug
Package: Scripting Engine problem
-PHP Version: 5.4.0RC5
+PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
The bug is still there is the latest version of PHP
Previous Comments:
------------------------------------------------------------------------
[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