3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types = 1); class HelloWorld { /** @var array<string, string> */ private $items; public function doFoo(string $input) { $this->items[$input] = $input; /*foreach ($this->items as $key => $value) { $this->requireString($key); }*/ } public function requireString(string $s) { } } $h = new HelloWorld(); $h->doFoo('1'); // bang
based on OfRBH
Output for hhvm-3.18.5 - 3.22.0, 7.0.28 - 7.3.0rc3
Output for 5.6.30
Warning: Unsupported declare 'strict_types' in /in/m3t15 on line 1 Catchable fatal error: Argument 1 passed to HelloWorld::doFoo() must be an instance of string, string given, called in /in/m3t15 on line 24 and defined in /in/m3t15 on line 9
Process exited with code 255.