3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Generics; class CollectionᐸTᐳ implements \Countable { private $items = []; public function add(T $item) { $this->items[] = $item; } public function count() { return count($this->items); } } $dates = new CollectionᐸDateTimeᐳ(); $dates->add(new DateTime('yesterday')); $dates->add(new DateTime('today')); $dates->add(new DateTime('tomorrow')); echo count($dates); class T extends \DateTime {} class DateTime extends T {}; class CollectionᐸDateTimeᐳ extends CollectionᐸTᐳ {}
based on jRILY
Output for 7.0.0 - 7.2.6
Fatal error: Uncaught Error: Class 'Generics\CollectionᐸDateTimeᐳ' not found in /in/0f4HL:20 Stack trace: #0 {main} thrown in /in/0f4HL on line 20
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Class undefined: Generics\CollectionᐸDateTimeᐳ in /in/0f4HL:20 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Class 'Generics\CollectionᐸDateTimeᐳ' not found in /in/0f4HL on line 20
Process exited with code 255.