3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=0); class Item { // more code public function getPrice() { return $this->price; } public function setPrice(float $price) { $this->price = $price; } public function setTitle(string $title) { $this->title = $title; } public function setPublished(bool $published) { $this->published = $published; } public function setId(int $id) { $this->id = $id; } } $item = new Item(); $item->setPrice('1.2'); var_dump($item->getPrice());
based on FPaXh
Output for hhvm-3.11.1 - 3.22.0, 7.0.0 - 7.2.4
float(1.2)
Output for hhvm-3.10.1
Catchable fatal error: Argument 1 passed to Item::setPrice() must be an instance of float, string given in /in/VpAJF on line 13
Process exited with code 255.
Output for 5.4.0 - 5.6.30
Warning: Unsupported declare 'strict_types' in /in/VpAJF on line 2 Catchable fatal error: Argument 1 passed to Item::setPrice() must be an instance of float, string given, called in /in/VpAJF on line 28 and defined in /in/VpAJF on line 10
Process exited with code 255.