note 115456 added to language.oop5.traits
| From: | kuzawinski dot marcin at NOSPAM dot gmail dot com | Date: | Sat, 26 Jul 2014 14:58:32 +0000 |
| Subject: | note 115456 added to language.oop5.traits | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200056@lists.php.net to get a copy of this message | ||
Be warned, that you may accidentally define class old-style constructor when you use traits:
<?php
trait testTrait {
public function testClass() {
echo 'Yep... I am THE CONSTRUCTOR now!!!';
}
}
class testClass {
use testTrait;
}
$o = new testClass();
?>
To avoid this just define __construct() method in every class or use namespace (works with PHP
5.3.3+)
----
Server IP: 72.52.91.14
Probable Submitter: 89.78.6.71
----
Manual Page -- http://php.net/manual/en/language.oop5.traits.php
Edit -- https://master.php.net/note/edit/115456
Del: integrated -- https://master.php.net/note/delete/115456/integrated
Del: useless -- https://master.php.net/note/delete/115456/useless
Del: bad code -- https://master.php.net/note/delete/115456/bad+code
Del: spam -- https://master.php.net/note/delete/115456/spam
Del: non-english -- https://master.php.net/note/delete/115456/non-english
Del: in docs -- https://master.php.net/note/delete/115456/in+docs
Del: other reasons-- https://master.php.net/note/delete/115456
Reject -- https://master.php.net/note/reject/115456
Search -- https://master.php.net/manage/user-notes.php