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){ echo "HERE"; print_r($move); print_r($this); echo "DONE"; return $move->value > $this->value ? $move->value : $this->value; } public static function maxValDirection($moves){ $best = Move::initializeEmpty(); foreach($moves as $m){ print_r($m); $best = $m->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/dG7Vk
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/dG7Vk
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/dG7Vk
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 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dG7Vk
function name:  compare
number of ops:  21
compiled vars:  !0 = $move
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ECHO                                                     'HERE'
   21     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   22     5        INIT_FCALL                                               'print_r'
          6        FETCH_THIS                                       ~2      
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                                 
   23     9        ECHO                                                     'DONE'
   24    10        FETCH_OBJ_R                                      ~4      !0, 'value'
         11        FETCH_OBJ_R                                      ~5      'value'
         12        IS_SMALLER                                               ~5, ~4
         13      > JMPZ                                                     ~6, ->17
         14    >   FETCH_OBJ_R                                      ~7      !0, 'value'
         15        QM_ASSIGN                                        ~8      ~7
         16      > JMP                                                      ->19
         17    >   FETCH_OBJ_R                                      ~9      'value'
         18        QM_ASSIGN                                        ~8      ~9
         19    > > RETURN                                                   ~8
   25    20*     > 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 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/dG7Vk
function name:  maxValDirection
number of ops:  17
compiled vars:  !0 = $moves, !1 = $best, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        INIT_STATIC_METHOD_CALL                                  'Move', 'initializeEmpty'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   29     4      > FE_RESET_R                                       $5      !0, ->14
          5    > > FE_FETCH_R                                               $5, !2, ->14
   30     6    >   INIT_FCALL                                               'print_r'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   31     9        INIT_METHOD_CALL                                         !2, 'compare'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !1, $7
   29    13      > JMP                                                      ->5
         14    >   FE_FREE                                                  $5
   33    15      > RETURN                                                   !1
   34    16*     > RETURN                                                   null

End of function maxvaldirection

End of class Move.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.65 ms | 1404 KiB | 15 Q