3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyMorse { private array $morseCodeByPlainTexts = [ 'A' => '.-', 'H' => '....', 'L' => '.-..', 'N' => '-.', 'O' => '---', 'P' => '.--.', 'S' => '...', 'T' => '-', 'U' => '..-', 'Y' => '-.--', ]; public function encode(string $plainTexts): string { // prepend all letters except first with a space, add two spaces for every space in the input string return preg_replace_callback( pattern: '/(^)?(\S)| /', callback: fn($m) => ctype_space($m[0]) ? ' ' : ($m[1] ?? ' ') . $this->morseCodeByPlainTexts[$m[2]], subject: $plainTexts, flags: PREG_UNMATCHED_AS_NULL ); } } $obj = new MyMorse(); var_export( $obj->encode('YOU SHALL NOT PASS') );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u69gc
function name:  (null)
number of ops:  10
compiled vars:  !0 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   NEW                                                  $1      'MyMorse'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   33     3        INIT_FCALL                                                   'var_export'
   34     4        INIT_METHOD_CALL                                             !0, 'encode'
          5        SEND_VAL_EX                                                  'YOU+SHALL+NOT+PASS'
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
   33     8        DO_ICALL                                                     
   35     9      > RETURN                                                       1

Class MyMorse:
Function encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u69gc
function name:  encode
number of ops:  13
compiled vars:  !0 = $plainTexts
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   21     1        INIT_FCALL                                                   'preg_replace_callback'
   22     2        SEND_VAL                                                     '%2F%28%5E%29%3F%28%5CS%29%7C+%2F'
   23     3        DECLARE_LAMBDA_FUNCTION                              ~1      [0]
   25     4        SEND_VAL                                                     ~1
   26     5        SEND_VAR                                                     !0
   27     6        SEND_VAL                                                     512
          7        CHECK_UNDEF_ARGS                                             
   21     8        DO_ICALL                                             $2      
   27     9        VERIFY_RETURN_TYPE                                           $2
         10      > RETURN                                                       $2
   29    11*       VERIFY_RETURN_TYPE                                           
         12*     > 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 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u69gc
function name:  {closure:MyMorse::encode():23}
number of ops:  18
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     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
   24     6    >   QM_ASSIGN                                            ~3      '++'
          7      > JMP                                                          ->16
   25     8    >   FETCH_DIM_IS                                         ~4      !0, 1
          9        COALESCE                                             ~5      ~4
         10        QM_ASSIGN                                            ~5      '+'
         11        FETCH_DIM_R                                          ~7      !0, 2
         12        FETCH_OBJ_R                                          ~6      'morseCodeByPlainTexts'
         13        FETCH_DIM_R                                          ~8      ~6, ~7
         14        CONCAT                                               ~9      ~5, ~8
         15        QM_ASSIGN                                            ~3      ~9
         16    > > RETURN                                                       ~3
         17*     > RETURN                                                       null

End of Dynamic Function 0

End of function encode

End of class MyMorse.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.68 ms | 1609 KiB | 15 Q