3v4l.org

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

Class MyTrait:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dQ6hM
function name:  test
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                          ~0      'attr'
          1      > RETURN                                                       ~0
    8     2*     > RETURN                                                       null

End of function test

End of class MyTrait.

Class A: [no user functions]
Class B: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
234.3 ms | 3266 KiB | 14 Q