note 78542 added to language.oop5.paamayim-nekudotayim

From: Date: Tue, 16 Oct 2007 22:41:50 +0000
Subject: note 78542 added to language.oop5.paamayim-nekudotayim
Groups: php.notes 
Request: Send a blank email to php-notes+get-131436@lists.php.net to get a copy of this message
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.paamayim-nekudotayim.php Edit -- https://master.php.net/note/edit/78542 Del: integrated -- https://master.php.net/note/delete/78542/integrated Del: useless -- https://master.php.net/note/delete/78542/useless Del: bad code -- https://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 -- https://master.php.net/note/delete/78542/in+docs Del: other reasons-- https://master.php.net/note/delete/78542 Reject -- https://master.php.net/note/reject/78542 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131436) next »