3v4l.org

run code in 300+ 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 = 13
Branch analysis from position: 13
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}
number of ops:  15
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                                                      ->13
          8    >   FETCH_THIS                                       $4      
          9        FETCH_DIM_R                                      ~6      !0, 1
         10        FETCH_OBJ_R                                      ~5      $4, 'plainTextsByMorseCode'
         11        FETCH_DIM_R                                      ~7      ~5, ~6
         12        QM_ASSIGN                                        ~3      ~7
         13    > > RETURN                                                   ~3
         14*     > RETURN                                                   null

End of Dynamic Function 0

End of function decode

End of class MyMorse.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.34 ms | 1020 KiB | 16 Q