Doc #54038 [Opn->Csd]: "static" scope resolution operator
| From: | salathe@php.net | Date: | Fri, 14 Oct 2011 11:40:37 +0000 |
| Subject: | Doc #54038 [Opn->Csd]: "static" scope resolution operator | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7326@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54038&edit=1
ID: 54038
Updated by: salathe@php.net
Reported by: delphists at apollo dot lv
Summary: "static" scope resolution operator
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: salathe
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2011-10-14 11:37:18] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=318102
Log: static is special keyword too (patch by anon 11351, doc #54038)
------------------------------------------------------------------------
[2011-02-18 00:43:42] delphists at apollo dot lv
Description:
------------
It's stated in http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php
that "Two special keywords _self_ and _parent_ are used to access properties or methods from
inside the class definition", but there's also 3rd keyword which is not mentioned -
"static".
Test script:
---------------
<?php
header('content-type: text/plain');
class ParentClass {
const property = 'parent';
public function getPropertySelf() {
// use 'property' const of ParentClass
return self::property;
}
public function getPropertyStatic() {
// use 'property' const of called class
return static::property;
}
}
class ChildClass extends ParentClass {
const property = 'child';
}
$obj = new ChildClass();
var_dump($obj->getPropertySelf()); // string(6) "parent"
var_dump($obj->getPropertyStatic()); // string(5) "child"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54038&edit=1