Req #70986 [NEW]: Constants in traits
| From: | owlet at avtovokzaly dot ru | Date: | Fri, 27 Nov 2015 14:37:37 +0000 |
| Subject: | Req #70986 [NEW]: Constants in traits | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-197462@lists.php.net to get a copy of this message | ||
From: owlet at avtovokzaly dot ru
Operating system:
PHP version: Irrelevant
Package: Class/Object related
Bug Type: Feature/Change Request
Bug description:Constants in traits
Description:
------------
Sometimes we need to define constants directly in trait. Now it is
impossible and can be done throw namespace constants, for example, But
this replacement very uncomfortable.
Test script:
---------------
trait A {
const CONST_A = 'value of A::A';
}
class B {
use A;
public static function getA()
{
return self::CONST_A;
}
}
echo B::getA();
Expected result:
----------------
value of A::A
Actual result:
--------------
PHP Fatal error: Traits cannot have constants in php shell code on line
2
--
Edit bug report at https://bugs.php.net/bug.php?id=70986&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70986&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70986&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70986&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70986&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70986&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70986&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70986&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70986&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70986&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70986&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70986&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70986&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70986&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70986&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70986&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70986&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70986&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70986&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70986&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70986&r=mysqlcfg