3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Move { var $direction; var $value; var $x; var $y; public static function initializeEmpty(){ return (new Move(array(0, 0), "NONE", -1)); } public function __construct($pos, $direction, $value){ $this->y = $pos[0]; $this->x = $pos[1]; $this->value = $value; $this->direction = $direction; } public function compare($move){ return $move->value > $this->value ? $move : $this; } public static function maxValDirection($moves, $board, $player, $pos){ $best = Move::initializeEmpty(); foreach($moves as $m){ $m->setValue($board, $player, $pos); $best = $m->compare($best); } return $best; } public function setValue($board, $player, $pos){ $this->value = 1; } } $m1 = Move::initializeEmpty(); $m2 = new Move(array(0, 1), "RIGHT", 10); print_r(Move::maxValDirection(array($m1, $m2))); ?>
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Move::maxValDirection(), 1 passed in /in/O497v on line 38 and exactly 4 expected in /in/O497v:23 Stack trace: #0 /in/O497v(38): Move::maxValDirection(Array) #1 {main} thrown in /in/O497v on line 23
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
Warning: Missing argument 2 for Move::maxValDirection(), called in /in/O497v on line 38 and defined in /in/O497v on line 23 Warning: Missing argument 3 for Move::maxValDirection(), called in /in/O497v on line 38 and defined in /in/O497v on line 23 Warning: Missing argument 4 for Move::maxValDirection(), called in /in/O497v on line 38 and defined in /in/O497v on line 23 Notice: Undefined variable: board in /in/O497v on line 26 Notice: Undefined variable: player in /in/O497v on line 26 Notice: Undefined variable: pos in /in/O497v on line 26 Notice: Undefined variable: board in /in/O497v on line 26 Notice: Undefined variable: player in /in/O497v on line 26 Notice: Undefined variable: pos in /in/O497v on line 26 Move Object ( [direction] => RIGHT [value] => 1 [x] => 1 [y] => 0 )

preferences:
161.16 ms | 403 KiB | 215 Q