Bug #51765 [NEW]: class constant has different setter behavior than global constant
From:
Operating system: Any
PHP version: Irrelevant
Package: Class/Object related
Bug Type: Bug
Bug description:class constant has different setter behavior than global constant
Description:
------------
Global constants can be set using string concatenation and other global
constants. This is useful.
Class constants cannot be set using string concatenation or any functions,
although they can be set to a global constant, or another class constant.
The difference in setter behavior is confusing and limits utility of class
constants.
Test script:
---------------
define( 'FOO', 'foo' );
define( 'BAR', FOO . 'bar' );
echo BAR . PHP_EOL;
class Foobar {
const foo = 'foo';
const bar = self::foo . 'bar';
}
echo Foobar::bar;
Expected result:
----------------
foobar
foobar
Actual result:
--------------
Parse error: syntax error, unexpected '.', expecting ',' or ';' on
line 8
--
Edit bug report at http://bugs.php.net/bug.php?id=51765&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51765&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51765&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51765&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51765&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51765&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51765&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51765&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51765&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51765&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51765&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51765&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51765&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51765&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51765&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51765&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51765&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51765&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51765&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51765&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51765&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51765&r=mysqlcfg
Thread (5 messages)
- colin at sheaff dot net