3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface CounterInterface { public function getCount(); public function increment(); } class Counter implements CounterInterface { private $counter = 0; public function getCount() { return $this->counter; } public function increment() { $this->counter = $this->getCount() + 1; } } class CounterOffsetByOne extends Counter { public function getCount() { return parent::getCount() + 1; } } class DecoratedCounterOffsetByOne implements CounterInterface { private $baseCounter; public function __construct() { $this->baseCounter = new Counter; } public function getCount() { return $this->baseCounter->getCount() + 1; } public function increment() { $this->baseCounter->increment(); } } $counter = new CounterOffsetByOne; $counter->increment(); $counter->increment(); var_dump($counter->getCount()); $counter = new DecoratedCounterOffsetByOne; $counter->increment(); $counter->increment(); var_dump($counter->getCount());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  (null)
number of ops:  28
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'counter'
   14     1        DECLARE_CLASS                                            'counteroffsetbyone', 'counter'
   18     2        DECLARE_CLASS                                            'decoratedcounteroffsetbyone'
   25     3        NEW                                              $1      'CounterOffsetByOne'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   26     6        INIT_METHOD_CALL                                         !0, 'increment'
          7        DO_FCALL                                      0          
   27     8        INIT_METHOD_CALL                                         !0, 'increment'
          9        DO_FCALL                                      0          
   28    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !0, 'getCount'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
   30    15        NEW                                              $8      'DecoratedCounterOffsetByOne'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !0, $8
   31    18        INIT_METHOD_CALL                                         !0, 'increment'
         19        DO_FCALL                                      0          
   32    20        INIT_METHOD_CALL                                         !0, 'increment'
         21        DO_FCALL                                      0          
   33    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !0, 'getCount'
         24        DO_FCALL                                      0  $13     
         25        SEND_VAR                                                 $13
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

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

End of function getcount

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

End of function increment

End of class CounterInterface.

Class Counter:
Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  getCount
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~0      'counter'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getcount

Function increment:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  increment
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                         'getCount'
          1        DO_FCALL                                      0  $1      
          2        ADD                                              ~2      $1, 1
          3        ASSIGN_OBJ                                               'counter'
          4        OP_DATA                                                  ~2
          5      > RETURN                                                   null

End of function increment

End of class Counter.

Class CounterOffsetByOne:
Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  getCount
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'getCount'
          1        DO_FCALL                                      0  $0      
          2        ADD                                              ~1      $0, 1
          3      > RETURN                                                   ~1
          4*     > RETURN                                                   null

End of function getcount

End of class CounterOffsetByOne.

Class DecoratedCounterOffsetByOne:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Counter'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'baseCounter'
          3        OP_DATA                                                  $1
          4      > RETURN                                                   null

End of function __construct

Function getcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IV8qQ
function name:  getCount
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'baseCounter'
          1        INIT_METHOD_CALL                                         ~0, 'getCount'
          2        DO_FCALL                                      0  $1      
          3        ADD                                              ~2      $1, 1
          4      > RETURN                                                   ~2
          5*     > RETURN                                                   null

End of function getcount

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

End of function increment

End of class DecoratedCounterOffsetByOne.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.2 ms | 1396 KiB | 15 Q