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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2021 The PHP Group
All rights reserved.
Last updated: Wed Jul 28 19:01:24 2021 UTC