3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface FruitInterface { } interface AppleInterface extends FruitInterface { } class RedApple implements AppleInterface { } interface JuicerInterface { public function addComponent(FruitInterface $fruit); } class CommonJuicer implements JuicerInterface { public function addComponent(FruitInterface $fruit){ } } class SpecialAppleJuicer implements JuicerInterface { public function addComponent(AppleInterface $apple){ } } $redApple = new RedApple(); $juicer = new SpecialAppleJuicer(); $juicer->addComponent($redApple); // Expected that this would not produce Fatal Error, because RedApple implements FruitInterface. // "As of PHP 7.4.0, full covariance and contravariance support was added" // https://www.php.net/manual/en/language.oop5.variance.php
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vC0WM
function name:  (null)
number of ops:  14
compiled vars:  !0 = $redApple, !1 = $juicer
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                                'appleinterface'
   11     1        DECLARE_CLASS                                                'redapple'
   21     2        DECLARE_CLASS                                                'commonjuicer'
   29     3        DECLARE_CLASS                                                'specialapplejuicer'
   37     4        NEW                                                  $2      'RedApple'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !0, $2
   39     7        NEW                                                  $5      'SpecialAppleJuicer'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !1, $5
   40    10        INIT_METHOD_CALL                                             !1, 'addComponent'
         11        SEND_VAR_EX                                                  !0
         12        DO_FCALL                                          0          
   44    13      > RETURN                                                       1

Class FruitInterface: [no user functions]
Class AppleInterface: [no user functions]
Class RedApple: [no user functions]
Class JuicerInterface:
Function addcomponent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vC0WM
function name:  addComponent
number of ops:  2
compiled vars:  !0 = $fruit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function addcomponent

End of class JuicerInterface.

Class CommonJuicer:
Function addcomponent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vC0WM
function name:  addComponent
number of ops:  2
compiled vars:  !0 = $fruit
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
   25     1      > RETURN                                                       null

End of function addcomponent

End of class CommonJuicer.

Class SpecialAppleJuicer:
Function addcomponent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vC0WM
function name:  addComponent
number of ops:  2
compiled vars:  !0 = $apple
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   31     0  E >   RECV                                                 !0      
   33     1      > RETURN                                                       null

End of function addcomponent

End of class SpecialAppleJuicer.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
123.81 ms | 476 KiB | 7 Q