3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooArrayToString { public array $foo; public function doFoo(int $arr): void { $this->foo = $arr; var_dump($this->foo); } } var_dump((array)1); $f = new FooArrayToString(); $f->doFoo(1);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
array(1) { [0]=> int(1) } Fatal error: Uncaught TypeError: Cannot assign int to property FooArrayToString::$foo of type array in /in/H5XnR:9 Stack trace: #0 /in/H5XnR(17): FooArrayToString->doFoo(1) #1 {main} thrown in /in/H5XnR on line 9
Process exited with code 255.
Output for 7.4.33
array(1) { [0]=> int(1) } Fatal error: Uncaught TypeError: Typed property FooArrayToString::$foo must be array, int used in /in/H5XnR:9 Stack trace: #0 /in/H5XnR(17): FooArrayToString->doFoo(1) #1 {main} thrown in /in/H5XnR on line 9
Process exited with code 255.

preferences:
46.81 ms | 407 KiB | 5 Q