3v4l.org

run code in 500+ PHP versions simultaneously
<?php function cmp_strict(mixed $a, mixed $b): int { if ($a === $b) return 0; $typeA = gettype($a); $typeB = gettype($b); if ($typeA === $typeB) { return match($typeA){ "string" => strcmp($a, $b), "object" => spl_object_id($a) <=> spl_object_id($b), default => $a <=> $b, }; } else { return $typeA <=> $typeB; } } $data = [ 3, 4, 1, "a", "0", "x", 0, 1, 4, STDIN, STDERR, STDOUT, [3], [[4]], [], (object)['a'=>true], new stdClass ]; usort($data, 'cmp_strict'); var_dump($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2oRQt
function name:  (null)
number of ops:  32
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   INIT_ARRAY                                           ~1      3
          1        ADD_ARRAY_ELEMENT                                    ~1      4
          2        ADD_ARRAY_ELEMENT                                    ~1      1
   22     3        ADD_ARRAY_ELEMENT                                    ~1      'a'
          4        ADD_ARRAY_ELEMENT                                    ~1      '0'
          5        ADD_ARRAY_ELEMENT                                    ~1      'x'
   23     6        ADD_ARRAY_ELEMENT                                    ~1      0
          7        ADD_ARRAY_ELEMENT                                    ~1      1
          8        ADD_ARRAY_ELEMENT                                    ~1      4
   24     9        FETCH_CONSTANT                                       ~2      'STDIN'
         10        ADD_ARRAY_ELEMENT                                    ~1      ~2
         11        FETCH_CONSTANT                                       ~3      'STDERR'
         12        ADD_ARRAY_ELEMENT                                    ~1      ~3
         13        FETCH_CONSTANT                                       ~4      'STDOUT'
         14        ADD_ARRAY_ELEMENT                                    ~1      ~4
   21    15        ADD_ARRAY_ELEMENT                                    ~1      <array>
         16        ADD_ARRAY_ELEMENT                                    ~1      <array>
         17        ADD_ARRAY_ELEMENT                                    ~1      <array>
         18        CAST                                              8  ~5      <array>
         19        ADD_ARRAY_ELEMENT                                    ~1      ~5
   26    20        NEW                                                  $6      'stdClass'
         21        DO_FCALL                                          0          
         22        ADD_ARRAY_ELEMENT                                    ~1      $6
   20    23        ASSIGN                                                       !0, ~1
   29    24        INIT_FCALL                                                   'usort'
         25        SEND_REF                                                     !0
         26        SEND_VAL                                                     'cmp_strict'
         27        DO_ICALL                                                     
   31    28        INIT_FCALL                                                   'var_dump'
         29        SEND_VAR                                                     !0
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Function cmp_strict:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 33
Branch analysis from position: 11
3 jumps found. (Code = 195) Position 1 = 12, Position 2 = 18, Position 3 = 27
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2oRQt
function name:  cmp_strict
number of ops:  38
compiled vars:  !0 = $a, !1 = $b, !2 = $typeA, !3 = $typeB
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        IS_IDENTICAL                                                 !0, !1
          3      > JMPZ                                                         ~4, ->5
          4    > > RETURN                                                       0
    7     5    >   GET_TYPE                                             ~5      !0
          6        ASSIGN                                                       !2, ~5
    8     7        GET_TYPE                                             ~7      !1
          8        ASSIGN                                                       !3, ~7
    9     9        IS_IDENTICAL                                                 !2, !3
         10      > JMPZ                                                         ~9, ->33
   10    11    > > MATCH                                                        !2, [ 'string':->12, 'object':->18, ], ->27
   11    12    >   INIT_FCALL                                                   'strcmp'
         13        SEND_VAR                                                     !0
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                             $11     
         16        QM_ASSIGN                                            ~12     $11
         17      > JMP                                                          ->30
   12    18    >   INIT_FCALL                                                   'spl_object_id'
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                             $13     
         21        INIT_FCALL                                                   'spl_object_id'
         22        SEND_VAR                                                     !1
         23        DO_ICALL                                             $14     
         24        SPACESHIP                                            ~15     $13, $14
         25        QM_ASSIGN                                            ~12     ~15
         26      > JMP                                                          ->30
   13    27    >   SPACESHIP                                            ~16     !0, !1
         28        QM_ASSIGN                                            ~12     ~16
         29      > JMP                                                          ->30
         30    >   VERIFY_RETURN_TYPE                                           ~12
         31      > RETURN                                                       ~12
    9    32*       JMP                                                          ->36
   16    33    >   SPACESHIP                                            ~17     !2, !3
         34        VERIFY_RETURN_TYPE                                           ~17
         35      > RETURN                                                       ~17
   18    36*       VERIFY_RETURN_TYPE                                           
         37*     > RETURN                                                       null

End of function cmp_strict

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
134.47 ms | 487 KiB | 11 Q