3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseQuoteAware(string $commandLine) : array{ $args = []; preg_match_all('/"((?:\\\\.|[^\\\\"])*)"|(\S+)/u', $commandLine, $matches); foreach($matches[0] as $k => $_){ for($i = 1; $i <= 2; ++$i){ if($matches[$i][$k] !== ""){ $match = $matches[$i][$k]; $args[] = preg_replace('/\\\\([\\\\"])/u', '$1', $match) ?? throw new AssumptionFailedError(preg_last_error_msg()); break; } } } return $args; } $cmdLine = '/tellraw @a[name="Arie1906", c=1] "quoted \"string\"" {"rawtext": [{"text":"§bI am blue"}]}'; var_dump(parseQuoteAware($cmdLine));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q2tdA
function name:  (null)
number of ops:  8
compiled vars:  !0 = $cmdLine
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, '%2Ftellraw+%40a%5Bname%3D%22Arie1906%22%2C+c%3D1%5D+%22quoted+%5C%22string%5C%22%22+%7B%22rawtext%22%3A+%5B%7B%22text%22%3A%22%C2%A7bI+++++am+blue%22%7D%5D%7D'
   20     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'parsequoteaware'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function parsequoteaware:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 40
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 40
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 13
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 36
Branch analysis from position: 17
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 13
Branch analysis from position: 39
Branch analysis from position: 13
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/Q2tdA
function name:  parseQuoteAware
number of ops:  45
compiled vars:  !0 = $commandLine, !1 = $args, !2 = $matches, !3 = $_, !4 = $k, !5 = $i, !6 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAL                                                 '%2F%22%28%28%3F%3A%5C%5C.%7C%5B%5E%5C%5C%22%5D%29%2A%29%22%7C%28%5CS%2B%29%2Fu'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    6     7        FETCH_DIM_R                                      ~9      !2, 0
          8      > FE_RESET_R                                       $10     ~9, ->40
          9    > > FE_FETCH_R                                       ~11     $10, !3, ->40
         10    >   ASSIGN                                                   !4, ~11
    7    11        ASSIGN                                                   !5, 1
         12      > JMP                                                      ->37
    8    13    >   FETCH_DIM_R                                      ~14     !2, !5
         14        FETCH_DIM_R                                      ~15     ~14, !4
         15        IS_NOT_IDENTICAL                                         ~15, ''
         16      > JMPZ                                                     ~16, ->36
    9    17    >   FETCH_DIM_R                                      ~17     !2, !5
         18        FETCH_DIM_R                                      ~18     ~17, !4
         19        ASSIGN                                                   !6, ~18
   10    20        INIT_FCALL                                               'preg_replace'
         21        SEND_VAL                                                 '%2F%5C%5C%28%5B%5C%5C%22%5D%29%2Fu'
         22        SEND_VAL                                                 '%241'
         23        SEND_VAR                                                 !6
         24        DO_ICALL                                         $21     
         25        COALESCE                                         ~22     $21
         26        NEW                                              $23     'AssumptionFailedError'
         27        INIT_FCALL                                               'preg_last_error_msg'
         28        DO_ICALL                                         $24     
         29        SEND_VAR_NO_REF_EX                                       $24
         30        DO_FCALL                                      0          
         31      > THROW                                         1          $23
         32*       QM_ASSIGN                                        ~22     <true>
         33*       ASSIGN_DIM                                               !1
         34*       OP_DATA                                                  ~22
   11    35*       JMP                                                      ->39
    7    36    >   PRE_INC                                                  !5
         37    >   IS_SMALLER_OR_EQUAL                                      !5, 2
         38      > JMPNZ                                                    ~27, ->13
    6    39    > > JMP                                                      ->9
         40    >   FE_FREE                                                  $10
   16    41        VERIFY_RETURN_TYPE                                       !1
         42      > RETURN                                                   !1
   17    43*       VERIFY_RETURN_TYPE                                       
         44*     > RETURN                                                   null

End of function parsequoteaware

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.98 ms | 1021 KiB | 18 Q