Edit report at https://bugs.php.net/bug.php?id=61928&edit=1

 ID:                 61928
 Comment by:         olav at fwt dot no
 Reported by:        olav at fwt dot no
 Summary:            Instanciate object for aliased class
 Status:             Open
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Linux 3.3.4
 PHP Version:        5.3.12
 Block user comment: N
 Private report:     N

 New Comment:

It seems this problem is not related to the use keyword but imported 
items in general:

file: test2.php
------------------------------------
<?php
namespace Foo;

class Bar { }


file: test.php
------------------------------------
<?php
namespace NS2;

include 'test1.php';

use Foo\Bar;

$class = "Bar";
new $class;


Results is the same:
---------------------------
Fatal error: Class 'Bar' not found in /tmp/test.php on line 9

Call Stack:
    0.0003     632520   1. {main}() /tmp/test.php:0


Previous Comments:
------------------------------------------------------------------------
[2012-05-03 18:53:28] olav at fwt dot no

Description:
------------
Creating a class from variable when it has been imported with use keyword fails 
with class not found error.

This problems persists in 5.3.11, 5.3.12 and 5.4.1


Test script:
---------------
use stdClass as Foo;

$class = "Foo";
new $class;


Expected result:
----------------
No output

Actual result:
--------------
PHP Fatal error:  Class 'Foo' not found in /tmp/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /tmp/test.php:0

Fatal error: Class 'Foo' not found in /tmp/test.php on line 6

Call Stack:
    0.0003     631856   1. {main}() /tmp/test.php:0



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61928&edit=1

Reply via email to