note 112960 added to language.oop5.final

From: Date: Mon, 12 Aug 2013 18:34:45 +0000
Subject: note 112960 added to language.oop5.final
Groups: php.notes 
Request: Send a blank email to php-notes+get-195941@lists.php.net to get a copy of this message
As several other notes point out "you cannot override final methods even if they are defined as private in parent class". However, this is not unexpected behaviour as implied. The whole point of parent / child classes is that the child will act as if the parent is part of it, which is very convenient if you have several classes that all need some shared functionality - you only need to write those functions once. The final keyword allows us to prevent a child class from overriding the function. The private keyword allows us to prevent "outsiders" from seeing the function. Hence the two keywords aren't connected (interacting, affecting each other), and the behaviour is exactly what you should expect. Private functions are private from the outside world, but they are certainly accessible from the child. Therefore it makes a lot of sense to be able to make a private function final - to prevent / protect you or a teammate from accidentally creating the same function with a totally different meaning or functionality in your child-classes. ---- Server IP: 69.147.83.199 Probable Submitter: 85.202.26.31 ---- Manual Page -- http://php.net/manual/en/language.oop5.final.php Edit -- https://master.php.net/note/edit/112960 Del: integrated -- https://master.php.net/note/delete/112960/integrated Del: useless -- https://master.php.net/note/delete/112960/useless Del: bad code -- https://master.php.net/note/delete/112960/bad+code Del: spam -- https://master.php.net/note/delete/112960/spam Del: non-english -- https://master.php.net/note/delete/112960/non-english Del: in docs -- https://master.php.net/note/delete/112960/in+docs Del: other reasons-- https://master.php.net/note/delete/112960 Reject -- https://master.php.net/note/reject/112960 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195941) next »