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(); } } class FluentCounter implements Counter { private $count = 0; public function count() { $this->count += 1; return $this; } public function getCount() { return $this->count; } } $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/i5m5r
function name:  (null)
number of ops:  21
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'echoingcounter'
   35     1        DECLARE_CLASS                                            'fluentcounter'
   52     2        NEW                                              $1      'EchoingCounter'
          3        NEW                                              $2      'FluentCounter'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $1
   54     8        INIT_METHOD_CALL                                         !0, 'count'
          9        DO_FCALL                                      0  $6      
         10        INIT_METHOD_CALL                                         $6, 'count'
         11        DO_FCALL                                      0  $7      
         12        INIT_METHOD_CALL                                         $7, 'count'
         13        DO_FCALL                                      0  $8      
         14        INIT_METHOD_CALL                                         $8, 'count'
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !0, $9
   56    17        INIT_METHOD_CALL                                         !0, 'getCount'
         18        DO_FCALL                                      0  $11     
         19        ECHO                                                     $11
         20      > RETURN                                                   1

Class Counter:
Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i5m5r
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/i5m5r
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/i5m5r
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/i5m5r
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/i5m5r
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.

Class FluentCounter:
Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i5m5r
function name:  count
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ASSIGN_OBJ_OP                                 1          'count'
          1        OP_DATA                                                  1
   43     2        FETCH_THIS                                       ~1      
          3      > RETURN                                                   ~1
   44     4*     > 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/i5m5r
function name:  getCount
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   FETCH_OBJ_R                                      ~0      'count'
          1      > RETURN                                                   ~0
   49     2*     > RETURN                                                   null

End of function getcount

End of class FluentCounter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.09 ms | 1453 KiB | 13 Q