3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); trait Foo { public function bar(): int { return 1; } } class Bar { use Foo; } class Baz { use Foo; public function bar(): string { return 'boo'; } } $bar = new Bar(); var_dump($bar->bar()); $baz = new Baz(); var_dump($baz->bar());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kW8DR
function name:  (null)
number of ops:  19
compiled vars:  !0 = $bar, !1 = $baz
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                                'bar'
   15     1        DECLARE_CLASS                                                'baz'
   23     2        NEW                                                  $2      'Bar'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   24     5        INIT_FCALL                                                   'var_dump'
          6        INIT_METHOD_CALL                                             !0, 'bar'
          7        DO_FCALL                                          0  $5      
          8        SEND_VAR                                                     $5
          9        DO_ICALL                                                     
   26    10        NEW                                                  $7      'Baz'
         11        DO_FCALL                                          0          
         12        ASSIGN                                                       !1, $7
   27    13        INIT_FCALL                                                   'var_dump'
         14        INIT_METHOD_CALL                                             !1, 'bar'
         15        DO_FCALL                                          0  $10     
         16        SEND_VAR                                                     $10
         17        DO_ICALL                                                     
         18      > RETURN                                                       1

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

End of function bar

End of class Foo.

Class Bar: [no user functions]
Class Baz:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kW8DR
function name:  bar
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E > > RETURN                                                       'boo'
   20     1*       VERIFY_RETURN_TYPE                                           
          2*     > RETURN                                                       null

End of function bar

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.24 ms | 1473 KiB | 14 Q