3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); trait T { abstract function foo(): string; function bar(): string { return $this->foo(); } } abstract class A { use T; } /* class B extends A { // This fatals as expected function foo() { return 'some string'; } } */ class C { use T; // This does not function foo() { return 'some string'; } } class D { use T; // This ALSO does not function foo(): int { return 3; } } abstract class E { use T; // Nor this function foo() { return 'some thing'; } } (new D())->bar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/02d4a
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'a'
   24     1        DECLARE_CLASS                                            'c'
   33     2        DECLARE_CLASS                                            'd'
   42     3        DECLARE_CLASS                                            'e'
   51     4        NEW                                              $0      'D'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $0, 'bar'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

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

End of function foo

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

End of function bar

End of class T.

Class A: [no user functions]
Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/02d4a
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E > > RETURN                                                   'some+string'
   30     1*     > RETURN                                                   null

End of function foo

End of class C.

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

End of function foo

End of class D.

Class E:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/02d4a
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E > > RETURN                                                   'some+thing'
   48     1*     > RETURN                                                   null

End of function foo

End of class E.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166 ms | 1399 KiB | 13 Q