3v4l.org

run code in 500+ PHP versions simultaneously
<?php $s = "/**\r\n". "* @changelog https://github.com/rectorphp/rector/blob/master/docs/rector_rules_overview.md\r\n". "*/\r\n"; $annotation = '@changelog'; var_dump(extractAnnotationFromClass($s, $annotation)); function extractAnnotationFromClass(string $docComment, string $annotation): ?string { // @see https://regex101.com/r/oYGaWU/1 $pattern = '#' . preg_quote($annotation, '#') . '\s+(?<content>.*?)$#m'; preg_match($pattern, $docComment, $matches); return $matches['content'] ?? null; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G9NNG
function name:  (null)
number of ops:  10
compiled vars:  !0 = $s, !1 = $annotation
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2F%2A%2A%0D%0A%2A+%40changelog+https%3A%2F%2Fgithub.com%2Frectorphp%2Frector%2Fblob%2Fmaster%2Fdocs%2Frector_rules_overview.md%0D%0A%2A%2F%0D%0A'
    7     1        ASSIGN                                                       !1, '%40changelog'
    9     2        INIT_FCALL                                                   'var_dump'
          3        INIT_FCALL_BY_NAME                                           'extractAnnotationFromClass'
          4        SEND_VAR_EX                                                  !0
          5        SEND_VAR_EX                                                  !1
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
          8        DO_ICALL                                                     
   17     9      > RETURN                                                       1

Function extractannotationfromclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G9NNG
function name:  extractAnnotationFromClass
number of ops:  21
compiled vars:  !0 = $docComment, !1 = $annotation, !2 = $pattern, !3 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   14     2        INIT_FCALL                                                   'preg_quote'
          3        SEND_VAR                                                     !1
          4        SEND_VAL                                                     '%23'
          5        DO_ICALL                                             $4      
          6        CONCAT                                               ~5      '%23', $4
          7        CONCAT                                               ~6      ~5, '%5Cs%2B%28%3F%3Ccontent%3E.%2A%3F%29%24%23m'
          8        ASSIGN                                                       !2, ~6
   15     9        INIT_FCALL                                                   'preg_match'
         10        SEND_VAR                                                     !2
         11        SEND_VAR                                                     !0
         12        SEND_REF                                                     !3
         13        DO_ICALL                                                     
   16    14        FETCH_DIM_IS                                         ~9      !3, 'content'
         15        COALESCE                                             ~10     ~9
         16        QM_ASSIGN                                            ~10     null
         17        VERIFY_RETURN_TYPE                                           ~10
         18      > RETURN                                                       ~10
   17    19*       VERIFY_RETURN_TYPE                                           
         20*     > RETURN                                                       null

End of function extractannotationfromclass

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.89 ms | 2138 KiB | 16 Q