note 114383 added to language.oop5.traits

From: Date: Fri, 14 Feb 2014 08:31:22 +0000
Subject: note 114383 added to language.oop5.traits
Groups: php.notes 
Request: Send a blank email to php-notes+get-198506@lists.php.net to get a copy of this message
Note that you can omit a method's inclusion by excluding it from one trait in favor of the other and doing the exact same thing in the reverse way. <?php trait A { public function sayHello() { echo 'Hello from A'; } public function sayWorld() { echo 'World from A'; } } trait B { public function sayHello() { echo 'Hello from B'; } public function sayWorld() { echo 'World from B'; } } class Talker { use A, B { A::sayHello insteadof B; A::sayWorld insteadof B; B::sayWorld insteadof A; } } $talker = new Talker(); $talker->sayHello(); $talker->sayWorld(); ?> The method sayHello is imported, but the method sayWorld is simply excluded. ---- Server IP: 92.48.119.85 Probable Submitter: 194.209.82.254 ---- Manual Page -- http://php.net/manual/en/language.oop5.traits.php Edit -- https://master.php.net/note/edit/114383 Del: integrated -- https://master.php.net/note/delete/114383/integrated Del: useless -- https://master.php.net/note/delete/114383/useless Del: bad code -- https://master.php.net/note/delete/114383/bad+code Del: spam -- https://master.php.net/note/delete/114383/spam Del: non-english -- https://master.php.net/note/delete/114383/non-english Del: in docs -- https://master.php.net/note/delete/114383/in+docs Del: other reasons-- https://master.php.net/note/delete/114383 Reject -- https://master.php.net/note/reject/114383 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198506) next »