3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Box { private $x; private $y; private $z; public function __construct($x, $y, $z) { $this->x = $x; $this->y = $y; $this->z = $z; } public function getX() { return $this->x; } public function getY() { return $this->y; } public function getZ() { return $this->z; } public function __toString() { return "[{$this->x}, {$this->y}, {$this->z}]"; } public function maxRozmer() { return max([$this->x, $this->y, $this->z]); } } //find max rozmer function cmp(Box $a, Box $b) : int { if($a->maxRozmer() == $b->maxRozmer()) { return 0; } return ($a->maxRozmer() > $b->maxRozmer()) ? -1 : 1; } $boxes = [ new Box(7,7,4), new Box(101,1,2), new Box(5,20,1), ]; $result = usort($boxes, "cmp"); print_r($result); print_r($boxes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  (null)
number of ops:  32
compiled vars:  !0 = $boxes, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'box'
   45     1        NEW                                              $2      'Box'
          2        SEND_VAL_EX                                              7
          3        SEND_VAL_EX                                              7
          4        SEND_VAL_EX                                              4
          5        DO_FCALL                                      0          
          6        INIT_ARRAY                                       ~4      $2
   46     7        NEW                                              $5      'Box'
          8        SEND_VAL_EX                                              101
          9        SEND_VAL_EX                                              1
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~4      $5
   47    13        NEW                                              $7      'Box'
         14        SEND_VAL_EX                                              5
         15        SEND_VAL_EX                                              20
         16        SEND_VAL_EX                                              1
         17        DO_FCALL                                      0          
         18        ADD_ARRAY_ELEMENT                                ~4      $7
   44    19        ASSIGN                                                   !0, ~4
   49    20        INIT_FCALL                                               'usort'
         21        SEND_REF                                                 !0
         22        SEND_VAL                                                 'cmp'
         23        DO_ICALL                                         $10     
         24        ASSIGN                                                   !1, $10
   51    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                                 
   53    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function cmp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  cmp
number of ops:  22
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   38     2        INIT_METHOD_CALL                                         !0, 'maxRozmer'
          3        DO_FCALL                                      0  $2      
          4        INIT_METHOD_CALL                                         !1, 'maxRozmer'
          5        DO_FCALL                                      0  $3      
          6        IS_EQUAL                                                 $2, $3
          7      > JMPZ                                                     ~4, ->9
   39     8    > > RETURN                                                   0
   41     9    >   INIT_METHOD_CALL                                         !0, 'maxRozmer'
         10        DO_FCALL                                      0  $5      
         11        INIT_METHOD_CALL                                         !1, 'maxRozmer'
         12        DO_FCALL                                      0  $6      
         13        IS_SMALLER                                               $6, $5
         14      > JMPZ                                                     ~7, ->17
         15    >   QM_ASSIGN                                        ~8      -1
         16      > JMP                                                      ->18
         17    >   QM_ASSIGN                                        ~8      1
         18    >   VERIFY_RETURN_TYPE                                       ~8
         19      > RETURN                                                   ~8
   42    20*       VERIFY_RETURN_TYPE                                       
         21*     > RETURN                                                   null

End of function cmp

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

End of function __construct

Function getx:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  getX
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'x'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function getx

Function gety:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  getY
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                      ~0      'y'
          1      > RETURN                                                   ~0
   19     2*     > RETURN                                                   null

End of function gety

Function getz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  getZ
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'z'
          1      > RETURN                                                   ~0
   22     2*     > RETURN                                                   null

End of function getz

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  __toString
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ROPE_INIT                                     7  ~4      '%5B'
          1        FETCH_OBJ_R                                      ~0      'x'
          2        ROPE_ADD                                      1  ~4      ~4, ~0
          3        ROPE_ADD                                      2  ~4      ~4, '%2C+'
          4        FETCH_OBJ_R                                      ~1      'y'
          5        ROPE_ADD                                      3  ~4      ~4, ~1
          6        ROPE_ADD                                      4  ~4      ~4, '%2C+'
          7        FETCH_OBJ_R                                      ~2      'z'
          8        ROPE_ADD                                      5  ~4      ~4, ~2
          9        ROPE_END                                      6  ~3      ~4, '%5D'
         10        VERIFY_RETURN_TYPE                                       ~3
         11      > RETURN                                                   ~3
   26    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null

End of function __tostring

Function maxrozmer:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vahpl
function name:  maxRozmer
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'max'
          1        FETCH_OBJ_R                                      ~0      'x'
          2        INIT_ARRAY                                       ~1      ~0
          3        FETCH_OBJ_R                                      ~2      'y'
          4        ADD_ARRAY_ELEMENT                                ~1      ~2
          5        FETCH_OBJ_R                                      ~3      'z'
          6        ADD_ARRAY_ELEMENT                                ~1      ~3
          7        SEND_VAL                                                 ~1
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
   30    10*     > RETURN                                                   null

End of function maxrozmer

End of class Box.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.25 ms | 1404 KiB | 19 Q