Bug #51651 [Opn->Bgs]: Dynamic class instatiation does not recognize namespaces.
| From: | tony2001@php.net | Date: | Tue, 08 Jun 2010 11:55:26 +0000 |
| Subject: | Bug #51651 [Opn->Bgs]: Dynamic class instatiation does not recognize namespaces. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151187@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51651&edit=1
ID: 51651
Updated by: tony2001@php.net
Reported by: bruno dot p dot reis at gmail dot com
Summary: Dynamic class instatiation does not recognize
namespaces.
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: windows vista
PHP Version: 5.3.2
New Comment:
This is a limitation of namespaces in PHP - they are resolved in
compile-time.
See http://www.php.net/manual/en/language.namespaces.dynamic.php
Previous Comments:
------------------------------------------------------------------------
[2010-04-23 23:12:56] bruno dot p dot reis at gmail dot com
Description:
------------
When I use a variable value as a class name, the file namespace is not
recognized.
Test script:
---------------
<?php
namespace test;
class Test{}
new Test;
$className = '\test\Test';
new $className; // this works
$className = 'Test';
new $className; // this should work either, because this file declares
the test namespace, but it does not recognize class Test.
Expected result:
----------------
I expect to see no error.
Actual result:
--------------
Fatal error: Class 'Test' not found in ...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51651&edit=1