From:             mail at thomasbachem dot com
Operating system: Mac OS X 10.8
PHP version:      5.4.17
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Reference class constant from object property

Description:
------------
When referencing a class constant, as of PHP 5.3.0, it's possible to
reference the 
class using a variable, e.g. "$myObj::MY_CONST".

It's not possible however to use that syntax with object properties, e.g. 
"$anotherObj->myObj::MY_CONST". I think that's inconsistent.

Test script:
---------------
<?php

class MyClass {

   const MY_CONST = 'foo';

}

$myObj = new MyClass();

// Works, prints "foo"
// echo $myObj::MY_CONST;

$anotherObj = new stdObject();
$anotherObj->myObj = $myObj;

// Raises a parse error
echo $anotherObj->myObj::MY_CONST;

Expected result:
----------------
Prints "foo"

Actual result:
--------------
Raises "Parse error: syntax error, unexpected '::'
(T_PAAMAYIM_NEKUDOTAYIM), 
expecting ',' or ';'"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65218&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65218&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65218&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65218&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65218&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65218&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65218&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65218&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65218&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65218&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65218&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65218&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65218&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65218&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65218&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65218&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65218&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65218&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65218&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65218&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65218&r=mysqlcfg

Reply via email to