3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface TestInterface { public function test(): TestInterface; } trait TestTrait { public function test(): TestInterface { return $this; } } class TestClass implements TestInterface { use TestTrait; public function test2() : self { return $this; } } class TestClass2 extends TestClass {} $test = new TestClass; $test2 = new TestClass2; var_dump($test->test(), $test2->test(), $test2->test2());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wq6oA
function name:  (null)
number of ops:  20
compiled vars:  !0 = $test, !1 = $test2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_CLASS                                            'testclass'
   20     1        DECLARE_CLASS                                            'testclass2', 'testclass'
   22     2        NEW                                              $2      'TestClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   23     5        NEW                                              $5      'TestClass2'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   24     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'test'
         10        DO_FCALL                                      0  $8      
         11        SEND_VAR                                                 $8
         12        INIT_METHOD_CALL                                         !1, 'test'
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        INIT_METHOD_CALL                                         !1, 'test2'
         16        DO_FCALL                                      0  $10     
         17        SEND_VAR                                                 $10
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

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

End of function test

End of class TestInterface.

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

End of function test

End of class TestTrait.

Class TestClass:
Function test2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wq6oA
function name:  test2
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_THIS                                       ~0      
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   17     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function test2

End of class TestClass.

Class TestClass2: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.35 ms | 1400 KiB | 15 Q