|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-20 02:01 UTC] levim@php.net
[2017-09-10 21:10 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2017-09-10 21:10 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
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 }