3v4l.org

run code in 500+ PHP versions simultaneously
<?php function twig_compare($a, $b) { // int <=> string if (\is_int($a) && \is_string($b)) { $b = trim($b); if (!is_numeric($b)) { return (string) $a <=> $b; } if ((int) $b == $b) { return $a <=> (int) $b; } else { return (float) $a <=> (float) $b; } } throw new \LogicException('partial implementation for quick test'); } $failures = []; foreach ([ [1, 42, ' foo'], [0, 42, "42\f"], [1, 42, "\x00\x34\x32"], ] as [$expected, $a, $b]) { $actual = twig_compare($a, $b); if ($expected === $actual) { echo '.'; } else { echo 'F'; $failures[] = [$a, $b, $expected, $actual]; } } echo "\n"; if (!$failures) { echo "OK\n"; } else { echo count($failures)." test(s) failed:\n"; foreach ($failures as [$a, $b, $expected, $actual]) { echo '('.var_export($a, true).', '.var_export($b, true)."): expected $expected, actual $actual\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 27
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 27
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 66
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 66
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
Branch analysis from position: 27
filename:       /in/VkVU2
function name:  (null)
number of ops:  68
compiled vars:  !0 = $failures, !1 = $expected, !2 = $a, !3 = $b, !4 = $actual
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                       !0, <array>
   23     1      > FE_RESET_R                                           $6      <array>, ->27
          2    > > FE_FETCH_R                                                   $6, $7, ->27
          3    >   FETCH_LIST_R                                         $8      $7, 0
   26     4        ASSIGN                                                       !1, $8
          5        FETCH_LIST_R                                         $10     $7, 1
          6        ASSIGN                                                       !2, $10
          7        FETCH_LIST_R                                         $12     $7, 2
          8        ASSIGN                                                       !3, $12
          9        FREE                                                         $7
   27    10        INIT_FCALL                                                   'twig_compare'
         11        SEND_VAR                                                     !2
         12        SEND_VAR                                                     !3
         13        DO_FCALL                                          0  $14     
         14        ASSIGN                                                       !4, $14
   28    15        IS_IDENTICAL                                                 !1, !4
         16      > JMPZ                                                         ~16, ->19
   29    17    >   ECHO                                                         '.'
   28    18      > JMP                                                          ->26
   31    19    >   ECHO                                                         'F'
   32    20        INIT_ARRAY                                           ~18     !2
         21        ADD_ARRAY_ELEMENT                                    ~18     !3
         22        ADD_ARRAY_ELEMENT                                    ~18     !1
         23        ADD_ARRAY_ELEMENT                                    ~18     !4
         24        ASSIGN_DIM                                                   !0
         25        OP_DATA                                                      ~18
   23    26    > > JMP                                                          ->2
         27    >   FE_FREE                                                      $6
   35    28        ECHO                                                         '%0A'
   36    29        BOOL_NOT                                             ~19     !0
         30      > JMPZ                                                         ~19, ->33
   37    31    >   ECHO                                                         'OK%0A'
   36    32      > JMP                                                          ->67
   39    33    >   COUNT                                                ~20     !0
         34        CONCAT                                               ~21     ~20, '+test%28s%29+failed%3A%0A'
         35        ECHO                                                         ~21
   40    36      > FE_RESET_R                                           $22     !0, ->66
         37    > > FE_FETCH_R                                                   $22, $23, ->66
         38    >   FETCH_LIST_R                                         $24     $23, 0
         39        ASSIGN                                                       !2, $24
         40        FETCH_LIST_R                                         $26     $23, 1
         41        ASSIGN                                                       !3, $26
         42        FETCH_LIST_R                                         $28     $23, 2
         43        ASSIGN                                                       !1, $28
         44        FETCH_LIST_R                                         $30     $23, 3
         45        ASSIGN                                                       !4, $30
         46        FREE                                                         $23
   41    47        INIT_FCALL                                                   'var_export'
         48        SEND_VAR                                                     !2
         49        SEND_VAL                                                     <true>
         50        DO_ICALL                                             $32     
         51        CONCAT                                               ~33     '%28', $32
         52        CONCAT                                               ~34     ~33, '%2C+'
         53        INIT_FCALL                                                   'var_export'
         54        SEND_VAR                                                     !3
         55        SEND_VAL                                                     <true>
         56        DO_ICALL                                             $35     
         57        CONCAT                                               ~36     ~34, $35
         58        ROPE_INIT                                         5  ~38     '%29%3A+expected+'
         59        ROPE_ADD                                          1  ~38     ~38, !1
         60        ROPE_ADD                                          2  ~38     ~38, '%2C+actual+'
         61        ROPE_ADD                                          3  ~38     ~38, !4
         62        ROPE_END                                          4  ~37     ~38, '%0A'
         63        CONCAT                                               ~41     ~36, ~37
         64        ECHO                                                         ~41
   40    65      > JMP                                                          ->37
         66    >   FE_FREE                                                      $22
   43    67    > > RETURN                                                       1

Function twig_compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 6
filename:       /in/VkVU2
function name:  twig_compare
number of ops:  31
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    6     2        TYPE_CHECK                                       16  ~2      !0
          3      > JMPZ_EX                                              ~2      ~2, ->6
          4    >   TYPE_CHECK                                       64  ~3      !1
          5        BOOL                                                 ~2      ~3
          6    > > JMPZ                                                         ~2, ->26
    7     7    >   FRAMELESS_ICALL_1                trim                ~4      !1
          8        ASSIGN                                                       !1, ~4
    8     9        FRAMELESS_ICALL_1                is_numeric          ~6      !1
         10        BOOL_NOT                                             ~7      ~6
         11      > JMPZ                                                         ~7, ->15
    9    12    >   CAST                                              6  ~8      !0
         13        SPACESHIP                                            ~9      ~8, !1
         14      > RETURN                                                       ~9
   11    15    >   CAST                                              4  ~10     !1
         16        IS_EQUAL                                                     !1, ~10
         17      > JMPZ                                                         ~11, ->22
   12    18    >   CAST                                              4  ~12     !1
         19        SPACESHIP                                            ~13     !0, ~12
         20      > RETURN                                                       ~13
   11    21*       JMP                                                          ->26
   14    22    >   CAST                                              5  ~14     !0
         23        CAST                                              5  ~15     !1
         24        SPACESHIP                                            ~16     ~14, ~15
         25      > RETURN                                                       ~16
   18    26    >   NEW                                                  $17     'LogicException'
         27        SEND_VAL_EX                                                  'partial+implementation+for+quick+test'
         28        DO_FCALL                                          0          
         29      > THROW                                             0          $17
   19    30*     > RETURN                                                       null

End of function twig_compare

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
178 ms | 2185 KiB | 15 Q