3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface FooInterface { public function foo(FooInterface $foo); } class Bar implements FooInterface { public function foo(FooInterface $foo): FooInterface { return new self(); } } $bar = new Bar(); $result = $bar->foo(new Bar()); var_dump($result);
based on OpP23
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/6HPJ5
function name:  (null)
number of ops:  17
compiled vars:  !0 = $bar, !1 = $result
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   7     1        DECLARE_CLASS                                    $3      '%00bar%2Fin%2F6HPJ50x7f972b9d40cf', 'bar'
         2        ADD_INTERFACE                                            $3, 'FooInterface'
         3        VERIFY_ABSTRACT_CLASS                                    $3
  14     4        NEW                                              $4      :-2
         5        DO_FCALL                                      0          
         6        ASSIGN                                                   !0, $4
  16     7        INIT_METHOD_CALL                                         !0, 'foo'
         8        NEW                                              $7      :2
         9        DO_FCALL                                      0          
        10        SEND_VAR_NO_REF                               0          $7
        11        DO_FCALL                                      0  $9      
        12        ASSIGN                                                   !1, $9
  18    13        INIT_FCALL                                               'var_dump'
        14        SEND_VAR                                                 !1
        15        DO_ICALL                                                 
        16      > RETURN                                                   1

Class FooInterface:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/6HPJ5
function name:  foo
number of ops:  2
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   RECV                                             !0      
         1      > RETURN                                                   null

End of function foo

End of class FooInterface.

Class Bar:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/6HPJ5
function name:  foo
number of ops:  8
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   RECV                                             !0      
  10     1        FETCH_CLASS                                 513  :1      
         2        NEW                                              $2      :1
         3        DO_FCALL                                      0          
         4        VERIFY_RETURN_TYPE                                       $2
         5      > RETURN                                                   $2
  11     6*       VERIFY_RETURN_TYPE                                       
         7*     > RETURN                                                   null

End of function foo

End of class Bar.

Generated using Vulcan Logic Dumper, using php 7.3.0