Edit report at http://bugs.php.net/bug.php?id=52029&edit=1
ID: 52029 Updated by: fel...@php.net Reported by: rustyj4ck at gmail dot com Summary: create_alias namespaces -Status: Open +Status: Assigned Type: Bug -Package: Class/Object related +Package: Scripting Engine problem Operating System: all PHP Version: 5.3.2 -Assigned To: +Assigned To: dmitry New Comment: Hmm, in fact the alias is created by reusing the original class entry. I.e. no copy is done, it just add a new entry to the class table using the alias name pointing to the original one. class a { } class_alias('a', 'b'); ReflectionClass::export('b'); /* Class [ <user> class a ] { ... } */ Dmitry, are actually the aliases supposed to behave in this way? (needing to be explained in the documentation wether it is right as is) Previous Comments: ------------------------------------------------------------------------ [2010-06-09 13:08:28] rustyj4ck at gmail dot com Description: ------------ Cant create alias to class in different namespace. Created object (alias instance) return type of base class, not alias. Test script: --------------- <?php namespace tf\users {} namespace tf\core { class collection { private $_cl; function __construct() { $this->_cl = get_class($this); } function get_cl() { return $this->_cl; } } class core { private $_cl; function register($name) { $from = 'tf\\core\\collection'; $to = 'tf\\users\\' . $name; printf ("aliasing %s --> %s : %s <br/> \n", $from, $to, class_alias($from, $to)?'OK':'FAIl'); $a = new $to (); $this->_cl = get_class($a); return $a; } function get_cl() { return $this->_cl; } } } namespace { use tf\core\core; $core = new core(); $test = $core->register('test'); printf("core: %s, result: %s, get_class: %s <br/>\n", $core->get_cl(), $test->get_cl(), get_class($test)); } Expected result: ---------------- tf\users\test Actual result: -------------- aliasing tf\core\collection --> tf\users\test : OK core: tf\core\collection, result: tf\core\collection, get_class: tf\core\collection ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52029&edit=1