#46310 [NEW]: Namespace resolution is not done when creating objects of a variable class name
| From: | benno at transmog dot com dot au | Date: | Thu, 16 Oct 2008 01:28:42 +0000 |
| Subject: | #46310 [NEW]: Namespace resolution is not done when creating objects of a variable class name | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-129740@lists.php.net to get a copy of this message | ||
From: benno at transmog dot com dot au
Operating system: Linux, but probably irrelevant
PHP version: 5.3.0alpha2
PHP Bug Type: Scripting Engine problem
Bug description: Namespace resolution is not done when creating objects of a variable class name
Description:
------------
Suppose you have a namespace that contains:
- a function that has "new $blah ();"
- the class $blah
The instantiation will generate a fatal error if the namespace is not
explicitly specified. I assume then that namespace resolution is not done
when instantiating an object of a variable class name.
This is similar to Bug #45197, but I don't think it's quite the same
thing. Classes must know, at runtime, which namespace they belong to for
the runtime namespace resolution described in the manual to work -
http://php.net/manual/en/language.namespaces.definition.php
Please advise either way.
Reproduce code:
---------------
Classes (defined in namespace ns):
http://transmog.com.au/php/ns.phps
Test suite:
http://transmog.com.au/php/test.phps
Expected result:
----------------
a: ok
b: ok
c: ok
Actual result:
--------------
a: ok
b: ok
c: <br />
<b>Fatal error</b>: Class 'testclass' not found in
<b>/var/www/ns.php</b>
on line <b>7</b><br />
--
Edit bug report at http://bugs.php.net/?id=46310&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46310&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46310&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46310&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46310&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=46310&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46310&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46310&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46310&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46310&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46310&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46310&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46310&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46310&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46310&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46310&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46310&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46310&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46310&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46310&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46310&r=mysqlcfg