3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private $a; public function getA() { return $this->a; } public function setA($a) { $this->a = $a; } } $b = 'b'; $a = new A(); $a->setA("coucou"); echo $a->getA(); modifyA($b); echo $a->getA(); function modifyA(A $a) { $a->setA('B'); }
based on Q0ZdO
Output for 7.0.0 - 7.2.0
coucou Fatal error: Uncaught TypeError: Argument 1 passed to modifyA() must be an instance of A, string given, called in /in/hLkKQ on line 22 and defined in /in/hLkKQ:29 Stack trace: #0 /in/hLkKQ(22): modifyA('b') #1 {main} thrown in /in/hLkKQ on line 29
Process exited with code 255.
Output for 5.3.18 - 5.6.28
coucou Catchable fatal error: Argument 1 passed to modifyA() must be an instance of A, string given, called in /in/hLkKQ on line 22 and defined in /in/hLkKQ on line 29
Process exited with code 255.