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 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:  12
compiled vars:  !0 = $morseCode
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   21     1        INIT_FCALL                                                   'preg_replace_callback'
          2        SEND_VAL                                                     '%2F%5B.-%5D%2B%2F'
          3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          4        SEND_VAL                                                     ~1
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $2      
   20     7        FRAMELESS_ICALL_2                strtr               ~3      $2, <array>
   22     8        VERIFY_RETURN_TYPE                                           ~3
          9      > RETURN                                                       ~3
   24    10*       VERIFY_RETURN_TYPE                                           
         11*     > 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:MyMorse::decode():21}
number of ops:  6
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
          1        FETCH_DIM_R                                          ~2      !0, 0
          2        FETCH_OBJ_R                                          ~1      'plainTextsByMorseCode'
          3        FETCH_DIM_R                                          ~3      ~1, ~2
          4      > RETURN                                                       ~3
          5*     > 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:
171.83 ms | 1587 KiB | 15 Q