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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: filippovdaniil at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 19:01:30 2025 UTC