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))); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O497v
function name:  (null)
number of ops:  18
compiled vars:  !0 = $m1, !1 = $m2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_STATIC_METHOD_CALL                                  'Move', 'initializeEmpty'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   37     3        NEW                                              $4      'Move'
          4        SEND_VAL_EX                                              <array>
          5        SEND_VAL_EX                                              'RIGHT'
          6        SEND_VAL_EX                                              10
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $4
   38     9        INIT_FCALL                                               'print_r'
         10        INIT_STATIC_METHOD_CALL                                  'Move', 'maxValDirection'
         11        INIT_ARRAY                                       ~7      !0
         12        ADD_ARRAY_ELEMENT                                ~7      !1
         13        SEND_VAL                                                 ~7
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_ICALL                                                 
   39    17      > RETURN                                                   1

Class Move:
Function initializeempty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O497v
function name:  initializeEmpty
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $0      'Move'
          1        SEND_VAL_EX                                              <array>
          2        SEND_VAL_EX                                              'NONE'
          3        SEND_VAL_EX                                              -1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   10     6*     > RETURN                                                   null

End of function initializeempty

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O497v
function name:  __construct
number of ops:  14
compiled vars:  !0 = $pos, !1 = $direction, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   13     3        FETCH_DIM_R                                      ~4      !0, 0
          4        ASSIGN_OBJ                                               'y'
          5        OP_DATA                                                  ~4
   14     6        FETCH_DIM_R                                      ~6      !0, 1
          7        ASSIGN_OBJ                                               'x'
          8        OP_DATA                                                  ~6
   15     9        ASSIGN_OBJ                                               'value'
         10        OP_DATA                                                  !2
   16    11        ASSIGN_OBJ                                               'direction'
         12        OP_DATA                                                  !1
   17    13      > RETURN                                                   null

End of function __construct

Function compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O497v
function name:  compare
number of ops:  11
compiled vars:  !0 = $move
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        FETCH_OBJ_R                                      ~1      !0, 'value'
          2        FETCH_OBJ_R                                      ~2      'value'
          3        IS_SMALLER                                               ~2, ~1
          4      > JMPZ                                                     ~3, ->7
          5    >   QM_ASSIGN                                        ~4      !0
          6      > JMP                                                      ->9
          7    >   FETCH_THIS                                       ~5      
          8        QM_ASSIGN                                        ~4      ~5
          9    > > RETURN                                                   ~4
   21    10*     > RETURN                                                   null

End of function compare

Function maxvaldirection:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/O497v
function name:  maxValDirection
number of ops:  22
compiled vars:  !0 = $moves, !1 = $board, !2 = $player, !3 = $pos, !4 = $best, !5 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   24     4        INIT_STATIC_METHOD_CALL                                  'Move', 'initializeEmpty'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !4, $6
   25     7      > FE_RESET_R                                       $8      !0, ->19
          8    > > FE_FETCH_R                                               $8, !5, ->19
   26     9    >   INIT_METHOD_CALL                                         !5, 'setValue'
         10        SEND_VAR_EX                                              !1
         11        SEND_VAR_EX                                              !2
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0          
   27    14        INIT_METHOD_CALL                                         !5, 'compare'
         15        SEND_VAR_EX                                              !4
         16        DO_FCALL                                      0  $10     
         17        ASSIGN                                                   !4, $10
   25    18      > JMP                                                      ->8
         19    >   FE_FREE                                                  $8
   29    20      > RETURN                                                   !4
   30    21*     > RETURN                                                   null

End of function maxvaldirection

Function setvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O497v
function name:  setValue
number of ops:  6
compiled vars:  !0 = $board, !1 = $player, !2 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   33     3        ASSIGN_OBJ                                               'value'
          4        OP_DATA                                                  1
   34     5      > RETURN                                                   null

End of function setvalue

End of class Move.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.68 ms | 1404 KiB | 15 Q