3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Counter { /** @return self */ public function count(); /** @return int */ public function getCount(); } class EchoingCounter implements Counter { private $counter; public function __construct(Counter $counter) { $this->counter = $counter; } public function count() { echo __METHOD__ . "\n"; return $this->counter->count(); } public function getCount() { echo __METHOD__ . "\n"; return $this->counter->getCount(); } } $counter = new EchoingCounter(new FluentCounter()); $counter = $counter->count()->count()->count()->count(); echo $counter->getCount();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PuA9c
function name:  (null)
number of ops:  20
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'echoingcounter'
   35     1        NEW                                              $1      'EchoingCounter'
          2        NEW                                              $2      'FluentCounter'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   37     7        INIT_METHOD_CALL                                         !0, 'count'
          8        DO_FCALL                                      0  $6      
          9        INIT_METHOD_CALL                                         $6, 'count'
         10        DO_FCALL                                      0  $7      
         11        INIT_METHOD_CALL                                         $7, 'count'
         12        DO_FCALL                                      0  $8      
         13        INIT_METHOD_CALL                                         $8, 'count'
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !0, $9
   39    16        INIT_METHOD_CALL                                         !0, 'getCount'
         17        DO_FCALL                                      0  $11     
         18        ECHO                                                     $11
         19      > RETURN                                                   1

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

End of function count

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

End of function getcount

End of class Counter.

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

End of function __construct

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PuA9c
function name:  count
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                     'EchoingCounter%3A%3Acount%0A'
   24     1        FETCH_OBJ_R                                      ~0      'counter'
          2        INIT_METHOD_CALL                                         ~0, 'count'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   25     5*     > RETURN                                                   null

End of function count

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

End of function getcount

End of class EchoingCounter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.82 ms | 1399 KiB | 13 Q