3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL ^ E_STRICT); trait MyTrait { /** * Comes from trait */ private $foo; } class MyClass { use MyTrait; /** * Comes from class */ private $foo; } $classFoo = new \ReflectionProperty('MyClass', 'foo'); $traitFoo = new \ReflectionProperty('MyTrait', 'foo'); var_export($traitFoo->getDocComment() == $classFoo->getDocComment()); $classFoo = new \ReflectionProperty('MyClass','foo'); $traitFoo = new \ReflectionProperty('MyTrait','foo'); echo $traitFoo->getDeclaringClass()->getName().PHP_EOL; echo $traitFoo->getDocComment().PHP_EOL; echo $classFoo->getDeclaringClass()->getName().PHP_EOL; echo $classFoo->getDocComment().PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r7CQa
function name:  (null)
number of ops:  53
compiled vars:  !0 = $classFoo, !1 = $traitFoo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 30719
          2        DO_ICALL                                                 
   12     3        DECLARE_CLASS                                            'myclass'
   24     4        NEW                                              $3      'ReflectionProperty'
          5        SEND_VAL_EX                                              'MyClass'
          6        SEND_VAL_EX                                              'foo'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $3
   25     9        NEW                                              $6      'ReflectionProperty'
         10        SEND_VAL_EX                                              'MyTrait'
         11        SEND_VAL_EX                                              'foo'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $6
   27    14        INIT_FCALL                                               'var_export'
         15        INIT_METHOD_CALL                                         !1, 'getDocComment'
         16        DO_FCALL                                      0  $9      
         17        INIT_METHOD_CALL                                         !0, 'getDocComment'
         18        DO_FCALL                                      0  $10     
         19        IS_EQUAL                                         ~11     $9, $10
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                                 
   30    22        NEW                                              $13     'ReflectionProperty'
         23        SEND_VAL_EX                                              'MyClass'
         24        SEND_VAL_EX                                              'foo'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !0, $13
   31    27        NEW                                              $16     'ReflectionProperty'
         28        SEND_VAL_EX                                              'MyTrait'
         29        SEND_VAL_EX                                              'foo'
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !1, $16
   32    32        INIT_METHOD_CALL                                         !1, 'getDeclaringClass'
         33        DO_FCALL                                      0  $19     
         34        INIT_METHOD_CALL                                         $19, 'getName'
         35        DO_FCALL                                      0  $20     
         36        CONCAT                                           ~21     $20, '%0A'
         37        ECHO                                                     ~21
   33    38        INIT_METHOD_CALL                                         !1, 'getDocComment'
         39        DO_FCALL                                      0  $22     
         40        CONCAT                                           ~23     $22, '%0A'
         41        ECHO                                                     ~23
   34    42        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
         43        DO_FCALL                                      0  $24     
         44        INIT_METHOD_CALL                                         $24, 'getName'
         45        DO_FCALL                                      0  $25     
         46        CONCAT                                           ~26     $25, '%0A'
         47        ECHO                                                     ~26
   35    48        INIT_METHOD_CALL                                         !0, 'getDocComment'
         49        DO_FCALL                                      0  $27     
         50        CONCAT                                           ~28     $27, '%0A'
         51        ECHO                                                     ~28
         52      > RETURN                                                   1

Class MyTrait: [no user functions]
Class MyClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.36 ms | 1400 KiB | 17 Q