3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Newable { public static function new() { return new static(); } } class Foo { use Newable; public function meth() : self { return $this; } } var_dump(Foo::new()->meth());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZQLSk
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'foo'
   17     1        INIT_FCALL                                               'var_dump'
          2        INIT_STATIC_METHOD_CALL                                  'Foo', 'new'
          3        DO_FCALL                                      0  $0      
          4        INIT_METHOD_CALL                                         $0, 'meth'
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class Newable:
Function new:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZQLSk
function name:  new
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    6     3*     > RETURN                                                   null

End of function new

End of class Newable.

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

End of function meth

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.66 ms | 998 KiB | 14 Q