From: macmade at eosgarden dot com Operating system: MacOS X 10.5.6 (Client) PHP version: 5.3.0RC2 PHP Bug Type: Scripting Engine problem Bug description: Namespaces and get_class()
Description: ------------ When using the get_class() function on an object whose class is defined in a different namespace as the actual, the return value does not contain a leading backslah (which is normal). But then why are we able to dynamically create an instance, based on the result of get_class(), without adding a leading backslash? I don't know if this is a bug, a feature, a wanted or un-wanted behavior, but I think this is weird. Reproduce code: --------------- <?php namespace Foo; class Test {} namespace Bar; # Calling 'new Foo\Test()' will obvisously fail, as it won't be found in the current NS $TEST = new \Foo\Test(); $CLASSNAME = get_class( $TEST ); # Will display 'Foo\Test' - No leading backslash print $CLASSNAME . '<br />'; # This will work... Why??? print_r( new $CLASSNAME() ); Expected result: ---------------- Foo\Test Fatal error: Class 'Bar\Foo\Test' not found ... on line 19 Actual result: -------------- Foo\Test Foo\Test Object ( ) -- Edit bug report at http://bugs.php.net/?id=48209&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48209&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48209&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48209&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48209&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48209&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48209&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48209&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48209&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48209&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48209&r=support Expected behavior: http://bugs.php.net/fix.php?id=48209&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48209&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48209&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48209&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48209&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48209&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48209&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48209&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48209&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48209&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48209&r=mysqlcfg