3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface BarInterface { /** * Bazzes the current environment. */ public function baz(); } class Foo implements FooInterface { /** * @var \BarInterface */ protected $bar; /** * Constructs a new instance. * * @param \BarInterface $bar */ public function __construct(BarInterface $bar) { $this->bar = $bar; } /** * Bazzes the bar. */ public function baz() { $this->bar->baz(); } } class NullBar implements BarInterface { /** * {@inheritdoc} */ public function baz() { // Silently fail. } } class ShoutBar implements BarInterface { /** * {@inheritdoc} */ public function baz() { print "HELLO BAZ!"; } } $null_bar = new NullBar(); $shout_bar = new ShoutBar(); $null_bar_foo = new Foo($null_bar); $null_bar_foo->baz(); $shout_bar_foo = new Foo($shout_bar); $shout_bar_foo->baz();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1ohuo
function name:  (null)
number of ops:  22
compiled vars:  !0 = $null_bar, !1 = $shout_bar, !2 = $null_bar_foo, !3 = $shout_bar_foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'foo'
   36     1        DECLARE_CLASS                                            'nullbar'
   47     2        DECLARE_CLASS                                            'shoutbar'
   58     3        NEW                                              $4      'NullBar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
   59     6        NEW                                              $7      'ShoutBar'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   61     9        NEW                                              $10     'Foo'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $10
   62    13        INIT_METHOD_CALL                                         !2, 'baz'
         14        DO_FCALL                                      0          
   64    15        NEW                                              $14     'Foo'
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $14
   65    19        INIT_METHOD_CALL                                         !3, 'baz'
         20        DO_FCALL                                      0          
         21      > RETURN                                                   1

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

End of function baz

End of class BarInterface.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1ohuo
function name:  __construct
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   25     3      > RETURN                                                   null

End of function __construct

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1ohuo
function name:  baz
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1        INIT_METHOD_CALL                                         ~0, 'baz'
          2        DO_FCALL                                      0          
   32     3      > RETURN                                                   null

End of function baz

End of class Foo.

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

End of function baz

End of class NullBar.

Class ShoutBar:
Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1ohuo
function name:  baz
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   ECHO                                                     'HELLO+BAZ%21'
   54     1      > RETURN                                                   null

End of function baz

End of class ShoutBar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.57 ms | 1399 KiB | 13 Q