php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65399 Parse error when trying to access class constant from another class property
Submitted: 2013-08-06 07:52 UTC Modified: 2013-08-10 22:36 UTC
From: filippovdaniil at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.5.1 OS: Debian Wheezy 7.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
7 + 43 = ?
Subscribe to this entry?

 
 [2013-08-06 07:52 UTC] filippovdaniil at gmail dot com
Description:
------------
Workaround:

$obj = $b->obj;
echo $obj::foo;

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

class a{
   const foo = "test";
}
class b{
    public $obj = null;

    public function __construct(){
        $this->obj = new a;
    }
}

$b = new b;

echo $b->obj::foo; // Parse error!


Expected result:
----------------
test

Actual result:
--------------
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-06 15:39 UTC] reeze@php.net
-Type: Bug +Type: Feature/Change Request
 [2013-08-10 22:36 UTC] ab@php.net
-Status: Open +Status: Wont fix
 [2013-08-10 22:36 UTC] ab@php.net
same reason as bug #65218
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC