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", -2)); } 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->value : $this->value; } public static function maxValDirection($moves){ $best = Move::initializeEmpty(); foreach($moves as $m){ $best = $move->compare($best); } return $best; } } $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/K7csP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $m1, !1 = $m2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_STATIC_METHOD_CALL                                  'Move', 'initializeEmpty'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   32     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
   33     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                                                 
   34    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/K7csP
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                                              -2
          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/K7csP
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 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/K7csP
function name:  compare
number of ops:  12
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, ->8
          5    >   FETCH_OBJ_R                                      ~4      !0, 'value'
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->10
          8    >   FETCH_OBJ_R                                      ~6      'value'
          9        QM_ASSIGN                                        ~5      ~6
         10    > > RETURN                                                   ~5
   21    11*     > RETURN                                                   null

End of function compare

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

End of function maxvaldirection

End of class Move.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.95 ms | 1400 KiB | 15 Q