note 58431 added to language.oop5.overloading
| From: | TJ | Date: | Fri, 04 Nov 2005 06:11:24 +0000 |
| Subject: | note 58431 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98047@lists.php.net to get a copy of this message | ||
Using the getter/setter methods to provide read-only access to object properties breaks the
conventional understanding of inheritence.
A super class using __set() to make a property read-only cannot be properly inherited because the
visible (read-only) property - with conventional public or protected visibility - cannot be set in
the sub-class.
The sub-class cannot overload the super class's __set() method either, and therefore the
inheritence is severely compromised.
I discovered this issue while extending DOMDocument and particularly DOMElement.
When extDOMDocument->createElement() creates a new extDOMElement, extDOMElement->__construct()
can't set the extDOMElement->ownerDocument property because it's read-only.
DOMElements are totally read-only if they do not have an ownerDocument, and there's no way to
set it in this scenario, which makes inheritence pretty pointless.
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58431
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58431&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58431&report=yes
Search -- http://master.php.net/manage/user-notes.php