3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Service; set_error_handler(function ($errno) { if ($errno === E_RECOVERABLE_ERROR) { return true; } return false; }); class TestService { protected $service; public function __construct(array $service) { $this->service = $service; } } $product = new TestService("THIS IS NOT AN ARRAY"); var_dump($product);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: Service\TestService::__construct(): Argument #1 ($service) must be of type array, string given, called in /in/JoJqh on line 19 and defined in /in/JoJqh:14 Stack trace: #0 /in/JoJqh(19): Service\TestService->__construct('THIS IS NOT AN ...') #1 {main} thrown in /in/JoJqh on line 14
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to Service\TestService::__construct() must be of the type array, string given, called in /in/JoJqh on line 19 and defined in /in/JoJqh:14 Stack trace: #0 /in/JoJqh(19): Service\TestService->__construct('THIS IS NOT AN ...') #1 {main} thrown in /in/JoJqh on line 14
Process exited with code 255.

preferences:
176.54 ms | 402 KiB | 167 Q