3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function &getState(): array { static $state = ['counter' => 0]; return $state; } public function count(): int { return $this->getState()['counter']++; } } $x = new Foo(); $y = new Foo(); var_dump($x->count(), $y->count());;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYNQD
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   15     3        NEW                                              $5      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   16     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'count'
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        INIT_METHOD_CALL                                         !1, 'count'
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class Foo:
Function getstate:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/uYNQD
function name:  getState
number of ops:  5
compiled vars:  !0 = $state
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        VERIFY_RETURN_TYPE                                       !0
          2      > RETURN_BY_REF                                            !0
    7     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN_BY_REF                                            null

End of function getstate

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uYNQD
function name:  count
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_METHOD_CALL                                         'getState'
          1        DO_FCALL                                      0  $0      
          2        SEPARATE                                         $0      $0
          3        FETCH_DIM_RW                                     $1      $0, 'counter'
          4        POST_INC                                         ~2      $1
          5        VERIFY_RETURN_TYPE                                       ~2
          6      > RETURN                                                   ~2
   11     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function count

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.57 ms | 1001 KiB | 14 Q