From:
Operating system: N/A
PHP version: Irrelevant
Package: Class/Object related
Bug Type: Feature/Change Request
Bug description:Add string casting support for class/interface names
Description:
------------
Please add a way to get the fully qualified class or interface name without
the need to create an object. While it is possible to declare a static
variable in classes as a workaround, this will not work with interfaces, as
you can't declare members inside them. A common trick I've seen is to use a
constant:
namespace Foo\Bar;
interface A {
const __NAME = __CLASS__;
}
factory(Bar\A::__NAME); // calls factory with '\Foo\Bar\A'
Though this won't work with inheritance. The magic __NAMESPACE__ constant
is also no help when importing namespaces. I propose to use the __CLASS__
keyword to implement such a feature, as it is not allowed to have a class
constant of this name:
namespace Foo\Bar {
interface A {}
}
namespace Orange\Banana {
use Foo\Bar;
echo Bar\A::__CLASS__; // should print "Foo\Bar\A"
}
--
Edit bug report at http://bugs.php.net/bug.php?id=54417&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54417&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54417&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54417&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54417&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54417&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54417&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54417&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54417&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54417&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54417&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54417&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54417&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54417&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54417&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54417&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54417&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54417&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54417&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54417&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54417&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54417&r=mysqlcfg