3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class obj implements ArrayAccess { private $container = array(); public function __construct() { $this->container = array( "one" => 1, "two" => 2, "three" => 3, ); } public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetUnset($offset) { unset($this->container[$offset]); } public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } function x (array $y) { print_r ($y); } //$i = new ['1','fsd','sadf']; $i = new obj(); x($i);
based on Pt98P
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to x() must be of the type array, object given, called in /in/trUNm on line 47 and defined in /in/trUNm:37 Stack trace: #0 /in/trUNm(47): x(Object(obj)) #1 {main} thrown in /in/trUNm on line 37
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Catchable fatal error: Argument 1 passed to x() must be of the type array, object given, called in /in/trUNm on line 47 and defined in /in/trUNm on line 37
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Catchable fatal error: Argument 1 passed to x() must be an array, object given, called in /in/trUNm on line 47 and defined in /in/trUNm on line 37
Process exited with code 255.