3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyMorse { private array $plainTextsByMorseCode = [ '.-' => 'A', '....' => 'H', '.-..' => 'L', '-.' => 'N', '---' => 'O', '.--.' => 'P', '...' => 'S', '-' => 'T', '..-' => 'U', '-.--' => 'Y', ]; public function decode(string $morseCode): string { return preg_replace_callback( '/ ?(\S+)| {3}/', fn($m) => ctype_space($m[0]) ? ' ' : $this->plainTextsByMorseCode[$m[1]], $morseCode ); } } $obj = new MyMorse(); var_export( $obj->decode('-.-- --- ..- ... .... .- .-.. .-.. -. --- - .--. .- ... ...') );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3QS3k
function name:  (null)
number of ops:  10
compiled vars:  !0 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   NEW                                                  $1      'MyMorse'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   29     3        INIT_FCALL                                                   'var_export'
   30     4        INIT_METHOD_CALL                                             !0, 'decode'
          5        SEND_VAL_EX                                                  '-.--+---+..-+++...+....+.-+.-..+.-..+++-.+---+-+++.--.+.-+...+...'
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
   29     8        DO_ICALL                                                     
   31     9      > RETURN                                                       1

Class MyMorse:
Function decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3QS3k
function name:  decode
number of ops:  11
compiled vars:  !0 = $morseCode
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1        INIT_FCALL                                                   'preg_replace_callback'
   21     2        SEND_VAL                                                     '%2F+%3F%28%5CS%2B%29%7C+%7B3%7D%2F'
   22     3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          4        SEND_VAL                                                     ~1
   23     5        SEND_VAR                                                     !0
   20     6        DO_ICALL                                             $2      
   23     7        VERIFY_RETURN_TYPE                                           $2
          8      > RETURN                                                       $2
   25     9*       VERIFY_RETURN_TYPE                                           
         10*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3QS3k
function name:  {closure:MyMorse::decode():22}
number of ops:  14
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
          1        INIT_FCALL                                                   'ctype_space'
          2        FETCH_DIM_R                                          ~1      !0, 0
          3        SEND_VAL                                                     ~1
          4        DO_ICALL                                             $2      
          5      > JMPZ                                                         $2, ->8
          6    >   QM_ASSIGN                                            ~3      '+'
          7      > JMP                                                          ->12
          8    >   FETCH_DIM_R                                          ~5      !0, 1
          9        FETCH_OBJ_R                                          ~4      'plainTextsByMorseCode'
         10        FETCH_DIM_R                                          ~6      ~4, ~5
         11        QM_ASSIGN                                            ~3      ~6
         12    > > RETURN                                                       ~3
         13*     > RETURN                                                       null

End of Dynamic Function 0

End of function decode

End of class MyMorse.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.14 ms | 1592 KiB | 16 Q