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 strtr( preg_replace_callback('/[.-]+/', fn($m) => $this->plainTextsByMorseCode[$m[0]], $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/6dvFi
function name:  (null)
number of ops:  10
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'MyMorse'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   28     3        INIT_FCALL                                               'var_export'
   29     4        INIT_METHOD_CALL                                         !0, 'decode'
          5        SEND_VAL_EX                                              '-.--+---+..-+++...+....+.-+.-..+.-..+++-.+---+-+++.--.+.-+...+...'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
   28     8        DO_ICALL                                                 
   30     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/6dvFi
function name:  decode
number of ops:  15
compiled vars:  !0 = $morseCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'strtr'
   21     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%5B.-%5D%2B%2F'
          4        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          5        SEND_VAL                                                 ~1
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
   22     9        SEND_VAL                                                 <array>
   20    10        DO_ICALL                                         $3      
   22    11        VERIFY_RETURN_TYPE                                       $3
         12      > RETURN                                                   $3
   24    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6dvFi
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       $1      
          2        FETCH_DIM_R                                      ~3      !0, 0
          3        FETCH_OBJ_R                                      ~2      $1, 'plainTextsByMorseCode'
          4        FETCH_DIM_R                                      ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > 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:
148.87 ms | 1013 KiB | 16 Q