note 80669 added to language.oop5.abstract

From: Date: Mon, 28 Jan 2008 14:57:34 +0000
Subject: note 80669 added to language.oop5.abstract
Groups: php.notes 
Request: Send a blank email to php-notes+get-135481@lists.php.net to get a copy of this message
As obvious as this may or may not seem; function properties declared as references in abstract functions must also be declared as references in child classes. <?php abstract class A { abstract function hello(&$ref); } class B extends A { function hello(&$ref) { $ref = 'sausage'; } } $b = new B(); $b->hello($ref); var_dump($ref); ?> Otherwise it returns the error: Declaration of B::hello() must be compatible with that of A::hello() References are a bit of an odd one in PHP so I thought it worth mentioning here seeing as no-one else has already. ---- Server IP: 147.32.160.17 Probable Submitter: 86.49.10.239 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php Edit -- https://master.php.net/note/edit/80669 Del: integrated -- https://master.php.net/note/delete/80669/integrated Del: useless -- https://master.php.net/note/delete/80669/useless Del: bad code -- https://master.php.net/note/delete/80669/bad+code Del: spam -- https://master.php.net/note/delete/80669/spam Del: non-english -- https://master.php.net/note/delete/80669/non-english Del: in docs -- https://master.php.net/note/delete/80669/in+docs Del: other reasons-- https://master.php.net/note/delete/80669 Reject -- https://master.php.net/note/reject/80669 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135481) next »