Doc #61397 [Opn->Wfx]: referencing class during static access using variable doesn't work properly
| From: | salathe@php.net | Date: | Sun, 22 Dec 2013 11:56:34 +0000 |
| Subject: | Doc #61397 [Opn->Wfx]: referencing class during static access using variable doesn't work properly | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10728@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61397&edit=1
ID: 61397
Updated by: salathe@php.net
Reported by: willewendell at gmail dot com
Summary: referencing class during static access using
variable doesn't work properly
-Status: Open
+Status: Wont fix
Type: Documentation Problem
Package: *General Issues
Operating System: Windows XP
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
$foo->bar is not "a variable".
Previous Comments:
------------------------------------------------------------------------
[2012-03-15 09:42:14] willewendell at gmail dot com
Description:
------------
Documentation says: "As of PHP 5.3.0, it's possible to reference the class using a
variable. The variable's value can not be a keyword (e.g. self, parent and static)."
It does not say that class variables cannot be used, but trying to do so will result in the
completely nonsensical error for non-hebrew speakers.
referencing the variable that references the class name does work, but it is a useless line in my
code, i don't like it.
public function foo() {
$tmp =& $this->bar;
echo $tmp::$my_static;
}
Test script:
---------------
<?php
class Foo {
public static $my_static = 'foo';
}
class Bar {
protected $bar;
public function __construct() {
$this->bar = 'Foo';
}
public function foo() {
echo $this->bar::$my_static;
}
}
$bar = new Bar();
$bar->foo();
Expected result:
----------------
foo
Actual result:
--------------
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or
';' in C:\ ... \test.php on line 12
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61397&edit=1