3v4l.org

run code in 300+ PHP versions simultaneously
<?php $entity_a = new stdClass; $entity_a->weight = 2; $entity_a->label = 'foo'; $entity_b = clone $entity_a; $entity_b->label = 'bar'; $list = array($entity_a, $entity_b); usort($list, 'xsort'); echo 'entity b =' . var_dump($entity_b); echo 'entity a =' . 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) { $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/oahfD
function name:  (null)
number of ops:  30
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                                                  2
    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        CONCAT                                           ~15     'entity+b+%3D', $14
         22        ECHO                                                     ~15
   12    23        INIT_FCALL                                               'var_dump'
         24        FETCH_DIM_R                                      ~16     !2, 0
         25        SEND_VAL                                                 ~16
         26        DO_ICALL                                         $17     
         27        CONCAT                                           ~18     'entity+a+%3D', $17
         28        ECHO                                                     ~18
   23    29      > 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 = 27
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
Branch analysis from position: 27
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/oahfD
function name:  xsort
number of ops:  34
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, ->27
   18    18    >   FETCH_OBJ_R                                      ~15     !0, 'label'
         19        ASSIGN                                                   !4, ~15
   19    20        FETCH_OBJ_R                                      ~17     !1, 'label'
         21        ASSIGN                                                   !5, ~17
   20    22        INIT_FCALL                                               'strnatcasecmp'
         23        SEND_VAR                                                 !4
         24        SEND_VAR                                                 !5
         25        DO_ICALL                                         $19     
         26      > RETURN                                                   $19
   22    27    >   IS_SMALLER                                               !2, !3
         28      > JMPZ                                                     ~20, ->31
         29    >   QM_ASSIGN                                        ~21     -1
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~21     1
         32    > > RETURN                                                   ~21
   23    33*     > RETURN                                                   null

End of function xsort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.25 ms | 1400 KiB | 19 Q