3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); class Test { private function parseDocComment(string $comment): array { $result = []; foreach (\preg_split('#[\r\n]+#', $comment, -1, \PREG_SPLIT_NO_EMPTY) as $line) { if (\preg_match('#\s\*\s*@([a-z0-9\-_])\s*(.*)#i', $line, $match)) { $result[$match[1]] = $match[2] ?? ''; } } return $result; } public function __call(string $name, array $arguments) { $objectReflection = new \ReflectionObject($this); if (!$objectReflection->hasMethod($name)) { throw new Exception('Invalid route target: ' . self::class . '::' . $name); } $methodReflection = $objectReflection->getMethod($name); if (false === $comment = $methodReflection->getDocComment()) { throw new Exception('Invalid route target: ' . self::class . '::' . $name); } $comment = $this->parseDocComment($comment); if (!isset($comment['json'])) { throw new Exception('Invalid route target: ' . self::class . '::' . $name); } return $this->{$name}(...$arguments); } /** * @json */ private function method() { echo ":-("; } } (new Test)->method();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T8e3g
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   NEW                                              $0      'Test'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $0, 'method'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class Test:
Function parsedoccomment:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/T8e3g
function name:  parseDocComment
number of ops:  28
compiled vars:  !0 = $comment, !1 = $result, !2 = $line, !3 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    9     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%23%5B%5Cr%5Cn%5D%2B%23'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 -1
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $5      
          8      > FE_RESET_R                                       $6      $5, ->23
          9    > > FE_FETCH_R                                               $6, !2, ->23
   10    10    >   INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%23%5Cs%5C%2A%5Cs%2A%40%28%5Ba-z0-9%5C-_%5D%29%5Cs%2A%28.%2A%29%23i'
         12        SEND_VAR                                                 !2
         13        SEND_REF                                                 !3
         14        DO_ICALL                                         $7      
         15      > JMPZ                                                     $7, ->22
   11    16    >   FETCH_DIM_R                                      ~8      !3, 1
         17        FETCH_DIM_IS                                     ~10     !3, 2
         18        COALESCE                                         ~11     ~10
         19        QM_ASSIGN                                        ~11     ''
         20        ASSIGN_DIM                                               !1, ~8
         21        OP_DATA                                                  ~11
    9    22    > > JMP                                                      ->9
         23    >   FE_FREE                                                  $6
   15    24        VERIFY_RETURN_TYPE                                       !1
         25      > RETURN                                                   !1
   16    26*       VERIFY_RETURN_TYPE                                       
         27*     > RETURN                                                   null

End of function parsedoccomment

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 43
Branch analysis from position: 38
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T8e3g
function name:  __call
number of ops:  49
compiled vars:  !0 = $name, !1 = $arguments, !2 = $objectReflection, !3 = $methodReflection, !4 = $comment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        NEW                                              $5      'ReflectionObject'
          3        FETCH_THIS                                       $6      
          4        SEND_VAR_EX                                              $6
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $5
   22     7        INIT_METHOD_CALL                                         !2, 'hasMethod'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $9      
         10        BOOL_NOT                                         ~10     $9
         11      > JMPZ                                                     ~10, ->17
   23    12    >   NEW                                              $11     'Exception'
         13        CONCAT                                           ~12     'Invalid+route+target%3A+Test%3A%3A', !0
         14        SEND_VAL_EX                                              ~12
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $11
   26    17    >   INIT_METHOD_CALL                                         !2, 'getMethod'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0  $14     
         20        ASSIGN                                                   !3, $14
   28    21        INIT_METHOD_CALL                                         !3, 'getDocComment'
         22        DO_FCALL                                      0  $16     
         23        ASSIGN                                           ~17     !4, $16
         24        TYPE_CHECK                                    4          ~17
         25      > JMPZ                                                     ~18, ->31
   29    26    >   NEW                                              $19     'Exception'
         27        CONCAT                                           ~20     'Invalid+route+target%3A+Test%3A%3A', !0
         28        SEND_VAL_EX                                              ~20
         29        DO_FCALL                                      0          
         30      > THROW                                         0          $19
   32    31    >   INIT_METHOD_CALL                                         'parseDocComment'
         32        SEND_VAR                                                 !4
         33        DO_FCALL                                      0  $22     
         34        ASSIGN                                                   !4, $22
   34    35        ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !4, 'json'
         36        BOOL_NOT                                         ~25     ~24
         37      > JMPZ                                                     ~25, ->43
   35    38    >   NEW                                              $26     'Exception'
         39        CONCAT                                           ~27     'Invalid+route+target%3A+Test%3A%3A', !0
         40        SEND_VAL_EX                                              ~27
         41        DO_FCALL                                      0          
         42      > THROW                                         0          $26
   38    43    >   INIT_METHOD_CALL                                         !0
         44        SEND_UNPACK                                              !1
         45        CHECK_UNDEF_ARGS                                         
         46        DO_FCALL                                      1  $29     
         47      > RETURN                                                   $29
   39    48*     > RETURN                                                   null

End of function __call

Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T8e3g
function name:  method
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   ECHO                                                     '%3A-%28'
   47     1      > RETURN                                                   null

End of function method

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.36 ms | 1404 KiB | 17 Q