3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php final class Collection { /** @var string */ private $type; /** * @param string $type */ public static function ofType($type) { $collection = new static(); $collection->type = $type; } } final class Person {} $col = Collection::ofType(Person::class); function parsePersonCollection(PersonCollection $coll) { } parsePersonCollection($col);
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to parsePersonCollection() must be an instance of PersonCollection, null given, called in /in/rLP1E on line 26 and defined in /in/rLP1E:21 Stack trace: #0 /in/rLP1E(26): parsePersonCollection(NULL) #1 {main} thrown in /in/rLP1E on line 21
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Catchable fatal error: Argument 1 passed to parsePersonCollection() must be an instance of PersonCollection, null given, called in /in/rLP1E on line 26 and defined in /in/rLP1E on line 21
Process exited with code 255.
Output for 5.4.9 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/rLP1E on line 19
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /in/rLP1E on line 19
Process exited with code 255.