3v4l.org

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

Class Counter:
Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AP62m
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/AP62m
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 ImmutableCounter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AP62m
function name:  __construct
number of ops:  5
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                        !0      0
   17     1        CAST                                          4  ~2      !0
          2        ASSIGN_OBJ                                               'count'
          3        OP_DATA                                                  ~2
   18     4      > 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/AP62m
function name:  count
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $0      'ImmutableCounter'
          1        FETCH_OBJ_R                                      ~1      'count'
          2        ADD                                              ~2      ~1, 1
          3        SEND_VAL_EX                                              ~2
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   23     6*     > 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/AP62m
function name:  getCount
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      'count'
          1      > RETURN                                                   ~0
   28     2*     > RETURN                                                   null

End of function getcount

End of class ImmutableCounter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.74 ms | 1453 KiB | 13 Q