3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CtorTrait { protected $a; public function __construct($a) { $this->a = $a; } } class Test { use CtorTrait; public function testTrait() { echo $this->a; } } $test = new Test('Trait works'); $test->testTrait(); $method = new ReflectionMethod(Test::class, '__construct'); var_dump($method->getParameters());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbVTU
function name:  (null)
number of ops:  18
compiled vars:  !0 = $test, !1 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'test'
   19     1        NEW                                              $2      'Test'
          2        SEND_VAL_EX                                              'Trait+works'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   20     5        INIT_METHOD_CALL                                         !0, 'testTrait'
          6        DO_FCALL                                      0          
   22     7        NEW                                              $6      'ReflectionMethod'
          8        SEND_VAL_EX                                              'Test'
          9        SEND_VAL_EX                                              '__construct'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $6
   23    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'getParameters'
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class CtorTrait:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbVTU
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

End of class CtorTrait.

Class Test:
Function testtrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbVTU
function name:  testTrait
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        ECHO                                                     ~0
   16     2      > RETURN                                                   null

End of function testtrait

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.3 ms | 1401 KiB | 15 Q