3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = -2
filename:       /in/r7CQa
function name:  (null)
number of ops:  56
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                                                 
   4     3        NOP                                                      
  12     4        DECLARE_CLASS                                    $4      '%00myclass%2Fin%2Fr7CQa0x7fe5dfebb0d7', 'myclass'
  14     5        ADD_TRAIT                                                $4, 'MyTrait'
  12     6        BIND_TRAITS                                              $4
  24     7        NEW                                              $5      :0
         8        SEND_VAL_EX                                              'MyClass'
         9        SEND_VAL_EX                                              'foo'
        10        DO_FCALL                                      0          
        11        ASSIGN                                                   !0, $5
  25    12        NEW                                              $8      :4
        13        SEND_VAL_EX                                              'MyTrait'
        14        SEND_VAL_EX                                              'foo'
        15        DO_FCALL                                      0          
        16        ASSIGN                                                   !1, $8
  27    17        INIT_FCALL                                               'var_export'
        18        INIT_METHOD_CALL                                         !1, 'getDocComment'
        19        DO_FCALL                                      0  $11     
        20        INIT_METHOD_CALL                                         !0, 'getDocComment'
        21        DO_FCALL                                      0  $12     
        22        IS_EQUAL                                         ~13     $11, $12
        23        SEND_VAL                                                 ~13
        24        DO_ICALL                                                 
  30    25        NEW                                              $15     :13
        26        SEND_VAL_EX                                              'MyClass'
        27        SEND_VAL_EX                                              'foo'
        28        DO_FCALL                                      0          
        29        ASSIGN                                                   !0, $15
  31    30        NEW                                              $18     :17
        31        SEND_VAL_EX                                              'MyTrait'
        32        SEND_VAL_EX                                              'foo'
        33        DO_FCALL                                      0          
        34        ASSIGN                                                   !1, $18
  32    35        INIT_METHOD_CALL                                         !1, 'getDeclaringClass'
        36        DO_FCALL                                      0  $21     
        37        INIT_METHOD_CALL                                         $21, 'getName'
        38        DO_FCALL                                      0  $22     
        39        CONCAT                                           ~23     $22, '%0A'
        40        ECHO                                                     ~23
  33    41        INIT_METHOD_CALL                                         !1, 'getDocComment'
        42        DO_FCALL                                      0  $24     
        43        CONCAT                                           ~25     $24, '%0A'
        44        ECHO                                                     ~25
  34    45        INIT_METHOD_CALL                                         !0, 'getDeclaringClass'
        46        DO_FCALL                                      0  $26     
        47        INIT_METHOD_CALL                                         $26, 'getName'
        48        DO_FCALL                                      0  $27     
        49        CONCAT                                           ~28     $27, '%0A'
        50        ECHO                                                     ~28
  35    51        INIT_METHOD_CALL                                         !0, 'getDocComment'
        52        DO_FCALL                                      0  $29     
        53        CONCAT                                           ~30     $29, '%0A'
        54        ECHO                                                     ~30
        55      > RETURN                                                   1

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

Generated using Vulcan Logic Dumper, using php 7.1.0