Req #67097 [Opn->Sus]: Allow traits to require class/interface
| From: | cmb@php.net | Date: | Sun, 10 Sep 2017 21:10:55 +0000 |
| Subject: | Req #67097 [Opn->Sus]: Allow traits to require class/interface | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211041@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67097&edit=1
ID: 67097
Updated by: cmb@php.net
Reported by: thierry at byscripts dot info
Summary: Allow traits to require class/interface
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Class/Object related
PHP Version: 5.5.11
Block user comment: N
Private report: N
New Comment:
Apparently, this proposal is controversial and as such would
require an RFC, see <https://wiki.php.net/rfc>.
Everybody is
welcome to create a respective RFC; if you do so please refer to
this feature request. In the meantime, I'm suspending this ticket.
Previous Comments:
------------------------------------------------------------------------
[2014-04-20 02:01:17] levim@php.net
My $0.02: allow traits to specify that they implement Interfaces. This is their #1 use already.
------------------------------------------------------------------------
[2014-04-18 21:17:31] thierry at byscripts dot info
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 this bug report at https://bugs.php.net/bug.php?id=67097&edit=1