3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace MyNamespace; use Zend\I18n\Translator\Translator; class MyAbstractClass { public $statusAction; public function setStatusAction($statusAction, Translator $translator = null) { $this->statusAction = ($translator !== null) ? $translator->translate(nl2br(ucfirst($statusAction))) : nl2br(ucfirst($statusAction)); } } $mine = new MyAbstractClass; $mine->setStatusAction('foo'); var_dump($mine->statusAction); $mine->setStatusAction('bar', null); var_dump($mine->statusAction); $mine->setStatusAction('baz', true); var_dump($mine->statusAction);
based on p0X4N
Output for 7.1.0 - 7.2.4
string(3) "Foo" string(3) "Bar" Fatal error: Uncaught TypeError: Argument 2 passed to MyNamespace\MyAbstractClass::setStatusAction() must be an instance of Zend\I18n\Translator\Translator or null, boolean given, called in /in/BTjUc on line 28 and defined in /in/BTjUc:11 Stack trace: #0 /in/BTjUc(28): MyNamespace\MyAbstractClass->setStatusAction('baz', true) #1 {main} thrown in /in/BTjUc on line 11
Process exited with code 255.
Output for hhvm-3.22.0
string(3) "Foo" string(3) "Bar" Fatal error: Uncaught TypeError: Argument 2 passed to MyNamespace\MyAbstractClass::setStatusAction() must be an instance of Zend\I18n\Translator\Translator, bool given in /in/BTjUc:-1 Stack trace: #0 /in/BTjUc(-1): MyNamespace\MyAbstractClass->setStatusAction() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
string(3) "Foo" string(3) "Bar" Fatal error: Uncaught TypeError: Argument 2 passed to MyNamespace\MyAbstractClass::setStatusAction() must be an instance of Zend\I18n\Translator\Translator, bool given in /in/BTjUc:14 Stack trace: #0 /in/BTjUc(28): MyNamespace\MyAbstractClass->setStatusAction() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
string(3) "Foo" string(3) "Bar" Catchable fatal error: Argument 2 passed to MyNamespace\MyAbstractClass::setStatusAction() must be an instance of Zend\I18n\Translator\Translator, boolean given, called in /in/BTjUc on line 28 and defined in /in/BTjUc on line 11
Process exited with code 255.