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(); print_r($best); print_r($moves); foreach($moves as $m){ print_r($move); $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/qrUcQ
function name:  (null)
number of ops:  18
compiled vars:  !0 = $m1, !1 = $m2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_STATIC_METHOD_CALL                                  'Move', 'initializeEmpty'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   35     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
   36     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                                                 
   37    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/qrUcQ
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/qrUcQ
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/qrUcQ
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 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/qrUcQ
function name:  maxValDirection
number of ops:  23
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        INIT_FCALL                                               'print_r'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
   26     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   27    10      > FE_RESET_R                                       $8      !0, ->20
         11    > > FE_FETCH_R                                               $8, !2, ->20
   28    12    >   INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
   29    15        INIT_METHOD_CALL                                         !3, 'compare'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0  $10     
         18        ASSIGN                                                   !1, $10
   27    19      > JMP                                                      ->11
         20    >   FE_FREE                                                  $8
   31    21      > RETURN                                                   !1
   32    22*     > RETURN                                                   null

End of function maxvaldirection

End of class Move.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.91 ms | 1404 KiB | 15 Q