3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Command { private $photoIds; private $categoryIds; private function setPhotoIds(int ...$photoIds):self { $this->photoIds = $photoIds; return $this; } private function setCategoryIds(int ...$categoryIds):self { $this->categoryIds = $categoryIds; return $this; } public function __construct(array $photoIds, array $categoryIds) { $this ->setPhotoIds(...$photoIds) ->setCategoryIds(...$categoryIds); } public function getPhotoIds():array { return $this->photoIds; } public function getCategoryIds():array { return $this->categoryIds; } } class Handler { public function __invoke(Command $command) { return array_sum($command->getPhotoIds(), $command->getCategoryIds()); } } $handler = new Handler(); $command = new Command([1, 2], [3, 4]); echo $handler($command);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: array_sum() expects exactly 1 argument, 2 given in /in/7tVQB:44 Stack trace: #0 /in/7tVQB(44): array_sum(Array, Array) #1 /in/7tVQB(51): Handler->__invoke(Object(Command)) #2 {main} thrown in /in/7tVQB on line 44
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_sum() expects exactly 1 parameter, 2 given in /in/7tVQB on line 44
Output for 5.6.8 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/7tVQB on line 8
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/7tVQB on line 8
Process exited with code 255.

preferences:
207.08 ms | 401 KiB | 183 Q