3v4l.org

run code in 300+ PHP versions simultaneously
<?php $entity_a = new stdClass; $entity_a->weight = 32; $entity_a->label = 'foo'; $entity_b = clone $entity_a; $entity_b->label = 'bar'; $list = array($entity_a, $entity_b); usort($list, 'xsort'); echo var_dump($entity_b); echo var_dump($list[0]); function xsort($a, $b) { $a_weight = isset($a->weight) ? $a->weight : 0; $b_weight = isset($b->weight) ? $b->weight : 0; if ($a_weight == $b_weight) { echo 'yay'; $a_label = $a->label; $b_label = $b->label; return strnatcasecmp($a_label, $b_label); } return ($a_weight < $b_weight) ? -1 : 1; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e5tkR
function name:  (null)
number of ops:  28
compiled vars:  !0 = $entity_a, !1 = $entity_b, !2 = $list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    5     3        ASSIGN_OBJ                                               !0, 'weight'
          4        OP_DATA                                                  32
    6     5        ASSIGN_OBJ                                               !0, 'label'
          6        OP_DATA                                                  'foo'
    7     7        CLONE                                            ~8      !0
          8        ASSIGN                                                   !1, ~8
    8     9        ASSIGN_OBJ                                               !1, 'label'
         10        OP_DATA                                                  'bar'
    9    11        INIT_ARRAY                                       ~11     !0
         12        ADD_ARRAY_ELEMENT                                ~11     !1
         13        ASSIGN                                                   !2, ~11
   10    14        INIT_FCALL                                               'usort'
         15        SEND_REF                                                 !2
         16        SEND_VAL                                                 'xsort'
         17        DO_ICALL                                                 
   11    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $14     
         21        ECHO                                                     $14
   12    22        INIT_FCALL                                               'var_dump'
         23        FETCH_DIM_R                                      ~15     !2, 0
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        ECHO                                                     $16
   24    27      > RETURN                                                   1

Function xsort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
Branch analysis from position: 28
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
Branch analysis from position: 14
filename:       /in/e5tkR
function name:  xsort
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $a_weight, !3 = $b_weight, !4 = $a_label, !5 = $b_label
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        ISSET_ISEMPTY_PROP_OBJ                                   !0, 'weight'
          3      > JMPZ                                                     ~6, ->7
          4    >   FETCH_OBJ_R                                      ~7      !0, 'weight'
          5        QM_ASSIGN                                        ~8      ~7
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~8      0
          8    >   ASSIGN                                                   !2, ~8
   16     9        ISSET_ISEMPTY_PROP_OBJ                                   !1, 'weight'
         10      > JMPZ                                                     ~10, ->14
         11    >   FETCH_OBJ_R                                      ~11     !1, 'weight'
         12        QM_ASSIGN                                        ~12     ~11
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~12     0
         15    >   ASSIGN                                                   !3, ~12
   17    16        IS_EQUAL                                                 !2, !3
         17      > JMPZ                                                     ~14, ->28
   18    18    >   ECHO                                                     'yay'
   19    19        FETCH_OBJ_R                                      ~15     !0, 'label'
         20        ASSIGN                                                   !4, ~15
   20    21        FETCH_OBJ_R                                      ~17     !1, 'label'
         22        ASSIGN                                                   !5, ~17
   21    23        INIT_FCALL                                               'strnatcasecmp'
         24        SEND_VAR                                                 !4
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $19     
         27      > RETURN                                                   $19
   23    28    >   IS_SMALLER                                               !2, !3
         29      > JMPZ                                                     ~20, ->32
         30    >   QM_ASSIGN                                        ~21     -1
         31      > JMP                                                      ->33
         32    >   QM_ASSIGN                                        ~21     1
         33    > > RETURN                                                   ~21
   24    34*     > RETURN                                                   null

End of function xsort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.2 ms | 1405 KiB | 19 Q