PHP/criticism/woozle

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< PHP‎ | criticism
Jump to navigation Jump to search

Some actual problems I've found with PHP 7, after using PHP for the better part of two decades:

Interfaces and Traits

  • Parameters can be declared to be of a given class or a given interface, but not a given trait.
  • Traits cannot be declared to implement interfaces.
    • Interfaces and traits really kind of go together -- neither one is tied to a specific class; a trait can be thought of as a way of implementing a given interface -- but there is no way to attach one to the other. So even if you're systematically defining traits as implementations of specific interfaces, every class that uses the trait needs to also declare that it implements the interface.
  • There is no way to dynamically test an object or class-name to see if it uses a trait or implements an interface.