3v4l.org

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

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

End of function getcount

End of class FluentCounter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.48 ms | 1399 KiB | 13 Q