Req #54095 [Opn->Csd]: Impossible to access static p/m/const from static context directly
| From: | requinix@php.net | Date: | Thu, 08 Jan 2015 06:46:22 +0000 |
| Subject: | Req #54095 [Opn->Csd]: Impossible to access static p/m/const from static context directly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189728@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54095&edit=1
ID: 54095
Updated by: requinix@php.net
Reported by: 11honza11 at seznam dot cz
Summary: Impossible to access static p/m/const from static
context directly
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Win7
PHP Version: Irrelevant
-Assigned To:
+Assigned To: requinix
Block user comment: N
Private report: N
New Comment:
Supported in PHP 7. http://3v4l.org/KDevT
Previous Comments:
------------------------------------------------------------------------
[2015-01-08 06:02:43] 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.
------------------------------------------------------------------------
[2011-02-24 18:21:57] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54095&edit=1