Bug #67979 [NEW]: overridding property on an inherited trait

From: Date: Mon, 08 Sep 2014 13:04:08 +0000
Subject: Bug #67979 [NEW]: overridding property on an inherited trait
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187447@lists.php.net to get a copy of this message
From: bradley dot lee80 at googlemai dot com Operating system: MacOSx PHP version: 5.5.16 Package: *General Issues Bug Type: Bug Bug description:overridding property on an inherited trait Description: ------------ Re-declaring properties in inherited traits throws a Fatal error For this scenario I can get around it by having a method return a hard coded value instead of the property, but it will have to be re-declared in each version of the API. --- From manual page: http://www.php.net/language.oop5.traits --- Test script: --------------- <?php trait V1Trait { protected $api_version = '1.0'; public function getApiVersion() { return $this->api_version; } } trait V2Trait { use V1Trait; protected $api_version = '2.0'; } Expected result: ---------------- <void> Actual result: -------------- Fatal error: V2Trait and V1Trait define the same property ($api_version) in the composition of V2Trait. However, the definition differs and is considered incompatible. Class was composed in Traits.php on line 15 -- Edit bug report at https://bugs.php.net/bug.php?id=67979&edit=1 --

« previous php.bugs (#187447) next »