3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace SomethingElse; class Test{} class Test2{} namespace MyApp\Example; use ReflectionClass; use ReflectionProperty; use SomethingElse\Test; use SomethingElse\Test2 as Alias; class ClassWithTypeHintedProperties { /** @var Test */ public $test; /** @var Alias */ public $alias; } $c = new ClassWithTypeHintedProperties(); $reflection = new ReflectionClass($c); $declared = get_declared_classes(); $usedWithNamespace = []; foreach ($declared as $class) { if (strstr($class, '\\')) { $usedWithNamespace[] = $class; } } var_dump($usedWithNamespace); foreach($reflection->getProperties(ReflectionProperty::IS_PUBLIC) as $p) { $comment = $p->getDocComment(); $comment = str_replace('/** @var', '', $comment); $comment = str_replace(' */', '', $comment); $comment = trim($comment); foreach ($usedWithNamespace as $class) { if (strstr($comment, $class)) { $comment = $class; echo $class."\n"; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 20
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 62
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 62
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 60
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 60
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 59
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 59
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 60
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
Branch analysis from position: 21
filename:       /in/e8s9o
function name:  (null)
number of ops:  64
compiled vars:  !0 = $c, !1 = $reflection, !2 = $declared, !3 = $usedWithNamespace, !4 = $class, !5 = $p, !6 = $comment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $7      'MyApp%5CExample%5CClassWithTypeHintedProperties'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $7
   26     3        NEW                                              $10     'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $10
   28     7        INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cget_declared_classes'
          8        DO_FCALL                                      0  $13     
          9        ASSIGN                                                   !2, $13
   29    10        ASSIGN                                                   !3, <array>
   30    11      > FE_RESET_R                                       $16     !2, ->21
         12    > > FE_FETCH_R                                               $16, !4, ->21
   31    13    >   INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cstrstr'
         14        SEND_VAR_EX                                              !4
         15        SEND_VAL_EX                                              '%5C'
         16        DO_FCALL                                      0  $17     
         17      > JMPZ                                                     $17, ->20
   32    18    >   ASSIGN_DIM                                               !3
         19        OP_DATA                                                  !4
   30    20    > > JMP                                                      ->12
         21    >   FE_FREE                                                  $16
   36    22        INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cvar_dump'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
   38    25        INIT_METHOD_CALL                                         !1, 'getProperties'
         26        SEND_VAL_EX                                              1
         27        DO_FCALL                                      0  $20     
         28      > FE_RESET_R                                       $21     $20, ->62
         29    > > FE_FETCH_R                                               $21, !5, ->62
   39    30    >   INIT_METHOD_CALL                                         !5, 'getDocComment'
         31        DO_FCALL                                      0  $22     
         32        ASSIGN                                                   !6, $22
   40    33        INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cstr_replace'
         34        SEND_VAL_EX                                              '%2F%2A%2A+%40var'
         35        SEND_VAL_EX                                              ''
         36        SEND_VAR_EX                                              !6
         37        DO_FCALL                                      0  $24     
         38        ASSIGN                                                   !6, $24
   41    39        INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cstr_replace'
         40        SEND_VAL_EX                                              '+%2A%2F'
         41        SEND_VAL_EX                                              ''
         42        SEND_VAR_EX                                              !6
         43        DO_FCALL                                      0  $26     
         44        ASSIGN                                                   !6, $26
   42    45        INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Ctrim'
         46        SEND_VAR_EX                                              !6
         47        DO_FCALL                                      0  $28     
         48        ASSIGN                                                   !6, $28
   43    49      > FE_RESET_R                                       $30     !3, ->60
         50    > > FE_FETCH_R                                               $30, !4, ->60
   44    51    >   INIT_NS_FCALL_BY_NAME                                    'MyApp%5CExample%5Cstrstr'
         52        SEND_VAR_EX                                              !6
         53        SEND_VAR_EX                                              !4
         54        DO_FCALL                                      0  $31     
         55      > JMPZ                                                     $31, ->59
   45    56    >   ASSIGN                                                   !6, !4
   46    57        CONCAT                                           ~33     !4, '%0A'
         58        ECHO                                                     ~33
   43    59    > > JMP                                                      ->50
         60    >   FE_FREE                                                  $30
   38    61      > JMP                                                      ->29
         62    >   FE_FREE                                                  $21
   49    63      > RETURN                                                   1

Class SomethingElse\Test: [no user functions]
Class SomethingElse\Test2: [no user functions]
Class MyApp\Example\ClassWithTypeHintedProperties: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.52 ms | 1405 KiB | 23 Q