From:             tobias dot john at fondsnet dot de
Operating system: Mac OS X 10.5
PHP version:      5.3CVS-2009-01-09 (CVS)
PHP Bug Type:     Class/Object related
Bug description:  Inconsitent namspace resolving when using dynamic class 
instanciation.

Description:
------------
When using a variable to instantiate a class, the behavior in namespace
resolving is inconsistent to the behavior when using a static class name.

Reproduce code:
---------------
namespace foo\bar;

class Baz {
    public $value;

    public function __construct($v) {
        $this->value = $v;
    }

    public function echoValue() {
        echo 'Value: ' . $this->value, PHP_EOL;
    }
}

$classname1 = '\foo\bar\Baz';
$classname2 = 'foo\bar\Baz';

$a = new $classname1('A');
$a->echoValue();
$b = new $classname2('B');
$b->echoValue();
$c = new \foo\bar\Baz('C');
$c->echoValue();
$d = new foo\bar\Baz('D');
$d->echoValue();

Expected result:
----------------
Value: A

Fatal error: Class 'foo\bar\foo\bar\Baz' not found in
/Users/tj/Documents/workspace/yeti/lib/yeti/NamespaceTest.php on line 20


Actual result:
--------------
Value: A
Value: B
Value: C

Fatal error: Class 'foo\bar\foo\bar\Baz' not found in
/Users/tj/Documents/workspace/yeti/lib/yeti/NamespaceTest.php on line 24


-- 
Edit bug report at http://bugs.php.net/?id=47057&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47057&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47057&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47057&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47057&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47057&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47057&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47057&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47057&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47057&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47057&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47057&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47057&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47057&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47057&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47057&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47057&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47057&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47057&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47057&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47057&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47057&r=mysqlcfg

Reply via email to