3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Foo { public function doSomething(string $param1); } class Bar implements Foo { public function doSomething(string $param1) { echo "Bar: " . $param1; } } class Baz implements Foo { // Using a named parameter different from Foo's signature public function doSomething(string $paramName) { echo "Baz: " . $paramName; } } function processFoo(Foo $foo) { $foo->doSomething(param1: "Test"); } $bar = new Bar(); $baz = new Baz(); processFoo($bar); // Works fine processFoo($baz); // Fatal error:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L1Ki3
function name:  (null)
number of ops:  15
compiled vars:  !0 = $bar, !1 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'bar'
   13     1        DECLARE_CLASS                                            'baz'
   24     2        NEW                                              $2      'Bar'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   25     5        NEW                                              $5      'Baz'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   27     8        INIT_FCALL                                               'processfoo'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0          
   28    11        INIT_FCALL                                               'processfoo'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function processfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L1Ki3
function name:  processFoo
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_METHOD_CALL                                         !0, 'doSomething'
          2        SEND_VAL_EX                                              'Test', 'param1'
          3        CHECK_UNDEF_ARGS                                         
          4        DO_FCALL                                      1          
   22     5      > RETURN                                                   null

End of function processfoo

Class Foo:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L1Ki3
function name:  doSomething
number of ops:  2
compiled vars:  !0 = $param1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function dosomething

End of class Foo.

Class Bar:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L1Ki3
function name:  doSomething
number of ops:  4
compiled vars:  !0 = $param1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        CONCAT                                           ~1      'Bar%3A+', !0
          2        ECHO                                                     ~1
   10     3      > RETURN                                                   null

End of function dosomething

End of class Bar.

Class Baz:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L1Ki3
function name:  doSomething
number of ops:  4
compiled vars:  !0 = $paramName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        CONCAT                                           ~1      'Baz%3A+', !0
          2        ECHO                                                     ~1
   17     3      > RETURN                                                   null

End of function dosomething

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152 ms | 1442 KiB | 15 Q