Doc #62936 [NEW]: Trait-Properties overwrite properties in the importing scope

From: Date: Sun, 26 Aug 2012 16:02:04 +0000
Subject: Doc #62936 [NEW]: Trait-Properties overwrite properties in the importing scope
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8769@lists.php.net to get a copy of this message
From: r dot wilczek at web-appz dot de Operating system: PHP version: 5.4.6 Package: Documentation problem Bug Type: Documentation Problem Bug description:Trait-Properties overwrite properties in the importing scope Description: ------------ In addition to the PHP manual stating ... If a trait defines a property then a class can not define a property with the same name, otherwise an error is issued. It is an E_STRICT if the class definition is compatible (same visibility and initial value) or fatal error otherwise ... note, that if you ignore the E_STRICT-notice, PHP will fetch the docblock of the imported property, discarding the docblock of conflicting property in the importing module. Test script: --------------- error_reporting(E_ALL ^ E_STRICT); trait MyTrait { /** * Comes from trait */ private $foo; } class MyClass { use MyTrait; /** * Comes from class */ private $foo; } $classFoo = new \ReflectionProperty('MyClass', 'foo'); $traitFoo = new \ReflectionProperty('MyTrait', 'foo'); var_export($traitFoo->getDocComment() == $classFoo->getDocComment()); Expected result: ---------------- true // if the composed class contains the docblock of MyTrait::$foo false // if the composed class contains the docblock of MyClass::$foo Actual result: -------------- true -- Edit bug report at https://bugs.php.net/bug.php?id=62936&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62936&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62936&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62936&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62936&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62936&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62936&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62936&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62936&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62936&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62936&r=support Expected behavior: https://bugs.php.net/fix.php?id=62936&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62936&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62936&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62936&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62936&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62936&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62936&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62936&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62936&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62936&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62936&r=mysqlcfg

« previous php.doc.bugs (#8769) next »