3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php Interface ShapeInterface { public function getArea(); } Class ShapeManager { public function __construct(ShapeInterface $shape) { $this->shape = $shape; } public function getArea() { $this->shape->getArea(); } } Class Circle { public function getArea() { return 'circle area'; } } Class Sqaure { public function getArea() { return 'square area'; } } $shape = new ShapeManager(new Circle); $shape->getArea();
Output for 7.0.0 - 7.2.11
Fatal error: Uncaught TypeError: Argument 1 passed to ShapeManager::__construct() must implement interface ShapeInterface, instance of Circle given, called in /in/QYZPm on line 29 and defined in /in/QYZPm:9 Stack trace: #0 /in/QYZPm(29): ShapeManager->__construct(Object(Circle)) #1 {main} thrown in /in/QYZPm on line 9
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught TypeError: Argument 1 passed to ShapeManager::__construct() must implement interface ShapeInterface, Circle given in /in/QYZPm:11 Stack trace: #0 /in/QYZPm(29): ShapeManager->__construct() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Catchable fatal error: Argument 1 passed to ShapeManager::__construct() must implement interface ShapeInterface, instance of Circle given, called in /in/QYZPm on line 29 and defined in /in/QYZPm on line 9
Process exited with code 255.