3v4l.org

run code in 300+ PHP versions simultaneously
<?php class comparer { public static array $counter = []; public static function compare($a, $b) { static::$counter[$a] = (static::$counter[$a] ?? 0) + 1; static::$counter[$b] = (static::$counter[$b] ?? 0) + 1; return $a <=> $b; } } $a=[5,6,7,8,9,10,1,2,3,4]; uasort($a, 'comparer::compare'); var_dump(comparer::$counter);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lYob3
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'uasort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'comparer%3A%3Acompare'
          4        DO_ICALL                                                 
   13     5        INIT_FCALL                                               'var_dump'
          6        FETCH_STATIC_PROP_R          unknown             ~3      'counter'
          7        SEND_VAL                                                 ~3
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class comparer:
Function compare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lYob3
function name:  compare
number of ops:  21
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_STATIC_PROP_IS                             ~4      'counter'
          3        FETCH_DIM_IS                                     ~5      ~4, !0
          4        COALESCE                                         ~6      ~5
          5        QM_ASSIGN                                        ~6      0
          6        ADD                                              ~7      ~6, 1
          7        FETCH_STATIC_PROP_W          global              $2      'counter'
          8        ASSIGN_DIM                                               $2, !0
          9        OP_DATA                                                  ~7
    7    10        FETCH_STATIC_PROP_IS                             ~10     'counter'
         11        FETCH_DIM_IS                                     ~11     ~10, !1
         12        COALESCE                                         ~12     ~11
         13        QM_ASSIGN                                        ~12     0
         14        ADD                                              ~13     ~12, 1
         15        FETCH_STATIC_PROP_W          unknown             $8      'counter'
         16        ASSIGN_DIM                                               $8, !1
         17        OP_DATA                                                  ~13
    8    18        SPACESHIP                                        ~14     !0, !1
         19      > RETURN                                                   ~14
    9    20*     > RETURN                                                   null

End of function compare

End of class comparer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.57 ms | 1002 KiB | 15 Q