Req #67097 [NEW]: Allow traits to require class/interface
| From: | thierry at byscripts dot info | Date: | Fri, 18 Apr 2014 21:17:32 +0000 |
| Subject: | Req #67097 [NEW]: Allow traits to require class/interface | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185344@lists.php.net to get a copy of this message | ||
From: thierry at byscripts dot info
Operating system:
PHP version: 5.5.11
Package: Class/Object related
Bug Type: Feature/Change Request
Bug description:Allow traits to require class/interface
Description:
------------
I think we need to be able to allow traits to require that the class in
which it can be used must be an instance of an arbitrary
class/interface.
Expected result:
----------------
trait AirConditioning requires Vehicle
{
public function increaseTemperature() { $this->ambientTemperature++;
}
public function decreaseTemperature() { $this->ambientTemperature--;
}
}
abstract class Vehicle
{
protected $ambientTemperature;
}
class Car extends Vehicle {}
class Truck extends Vehicle {}
class Dog extends Animal {}
class MyOldCar extends Car {}
class MyNewCar extends Car
{
use AirConditioning; // Should be OK
}
class MyLabrador extends Dog
{
use AirConditioning; // Should throw an exception
}
--
Edit bug report at https://bugs.php.net/bug.php?id=67097&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67097&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67097&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67097&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67097&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67097&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67097&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67097&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67097&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67097&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67097&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67097&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67097&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67097&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67097&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67097&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67097&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67097&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67097&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67097&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67097&r=mysqlcfg