There's no surprize here. These resolution rules are
identical in C++ and Java, where static fields (and methods)
are not separately instanciated within the inheritance tree
for the new derived classes.
This is per design. If you want per-class static fields,you
have to overload each static field (or method) to assign
them a new value that will hide the inherited static field
(or method). The "$self::" scope in a static
method does not refer to the object or class from which the
method is called, as it is statically compiled and resolved
within the class declaring the method.
In other words "$self::" is just needed to specify
the field declared in the defining class, instead of a
homonym variable (or function) in the local scope which may
hide it. This is exactly similar to the "this."
scope specifier (used with the "." operator here)
used in C++ (or Java).
The same can be said about the semantic of
"$super::" used within a static method (similar to
"super." scope specifier used in C++ or Java).
Neither PHP, nor C++, have a way to work on instanciated
class objects as if they were objects of the first grade
(that's why C++ and Java are making distinctions between
classes and interfaces).
On the opposite Javascript/ECMAScript defines classes like
standard objects with a "prototype" field for the
fields (or methods) to inherit instead of duplicating them
with the new operator. When working in PHP, forget
Javascript, think like in C++ and Java.
----
Server IP: 217.174.196.197
Probable Submitter: 90.50.243.245
----
Manual Page -- http://www.php.net/manual/en/language.oop5.pa
amayim-nekudotayim.php
Edit -- https://master
.php.net/note/edit/78542
Del: integrated -- h
ttps://master.php.net/note/delete/78542/integrated
Del: useless -- http
s://master.php.net/note/delete/78542/useless
Del: bad code -- htt
ps://master.php.net/note/delete/78542/bad+code
Del: spam -- https:/
/master.php.net/note/delete/78542/spam
Del: non-english --
https://master.php.net/note/delete/78542/non-english
Del: in docs -- http
s://master.php.net/note/delete/78542/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78542
Reject -- https://mast
er.php.net/note/reject/78542
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|