php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54095 Impossible to access static p/m/const from static context directly
Submitted: 2011-02-24 18:21 UTC Modified: 2015-01-08 06:46 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: 11honza11 at seznam dot cz Assigned: requinix (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: Irrelevant OS: Win7
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: 11honza11 at seznam dot cz
New email:
PHP Version: OS:

 

 [2011-02-24 18:21 UTC] 11honza11 at seznam dot cz
Description:
------------
There is no support for DIRECT access constants, static properties or static methods from static context. It means, that there is only "one-level" ability to access theese things.
We have to use workaround to eliminate this problem. But this workaround rises up a code and seems strange.

Test script:
---------------
echo config::$languageFile::error404;

Expected result:
----------------
The page was not found

Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';'
-----------------------

The workaround is:

$languageFile = config::$languageFile;
echo $languageFile::error404;

The code above works. The direct access would be purer and easier.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-02 04:21 UTC] yohgaki@php.net
-Package: Class/Object related +Package: Scripting Engine problem
 [2015-01-08 06:02 UTC] tjbk123 at gmail dot com
The test script given could be a bit more complete. A complete version would be:

<?php
class Foo {
    static public $bar = "Bar";
}

class Bar {
    static public $baz = "Baz";
}

echo Foo::$bar::$baz;
?>

where I would expect an output of "Baz" instead of the given syntax error.
 [2015-01-08 06:46 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 [2015-01-08 06:46 UTC] requinix@php.net
Supported in PHP 7. http://3v4l.org/KDevT
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 13:01:26 2025 UTC