3v4l.org

run code in 300+ PHP versions simultaneously
<?php // \Drupal\Core\Entity\EntityInterface interface EntityInterface { // ... } // \Drupal\Core\Entity\OwnerInterface interface OwnerInterface extends EntityInterface { // Just a marker interface (for now?). } // \Drupal\user\UserInterface interface UserInterface extends OwnerInterface { // ... } // \Drupal\user\User class User implements UserInterface { } // \Drupal\Core\Entity\OwnedEntityInterface interface OwnedEntityInterface { // For callers this work fine when you pass an object whose class implements // UserInterface. Implementors may need to adapt but this is fine according to // our current policies (https://www.drupal.org/core/d8-bc-policy): // "Interfaces follow a similar pattern as above with respect to @api, // @internal, or neither. However, in case of neither tag, the interface is // treated as an API for callers but not for implementers." public function setOwner(OwnerInterface $owner); // ... } // Example class. class OwnedEntity implements OwnedEntityInterface { public function setOwner(OwnerInterface $owner) {} } /** * @deprecated */ // \Drupal\user\EntityOwnerInterface interface EntityOwnerInterface extends OwnedEntityInterface { // This now empty, all methods are in "OwnedEntityInterface". } $user = new User(); $entity = new OwnedEntity(); $entity->setOwner($user);
Output for 7.0.0 - 7.0.25, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14

preferences:
106.4 ms | 407 KiB | 5 Q