3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface BarInterface { /** * Bazzes the current environment. */ public function baz(); } class Foo { /** * @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/gJjbL
function name:  (null)
number of ops:  21
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
-------------------------------------------------------------------------------------
   36     0  E >   DECLARE_CLASS                                            'nullbar'
   47     1        DECLARE_CLASS                                            'shoutbar'
   58     2        NEW                                              $4      'NullBar'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   59     5        NEW                                              $7      'ShoutBar'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $7
   61     8        NEW                                              $10     'Foo'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $10
   62    12        INIT_METHOD_CALL                                         !2, 'baz'
         13        DO_FCALL                                      0          
   64    14        NEW                                              $14     'Foo'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $14
   65    18        INIT_METHOD_CALL                                         !3, 'baz'
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Class BarInterface:
Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gJjbL
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/gJjbL
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/gJjbL
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/gJjbL
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/gJjbL
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:
152.91 ms | 1399 KiB | 13 Q