3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Foo { case Bar; private function &getState(): array { static $state = []; return $state; } public function increment(): void { $this->getState()[$this->name]['count'] ??= 0; ++$this->getState()[$this->name]['count']; } public function getCount(): int { return $this->getState()[$this->name]['count'] ?? 0; } } Foo::Bar->increment(); var_dump( Foo::Bar->getCount());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nqZfK
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'foo'
   23     1        FETCH_CLASS_CONSTANT                             ~0      'Foo', 'Bar'
          2        INIT_METHOD_CALL                                         ~0, 'increment'
          3        DO_FCALL                                      0          
   24     4        INIT_FCALL                                               'var_dump'
          5        FETCH_CLASS_CONSTANT                             ~2      'Foo', 'Bar'
          6        INIT_METHOD_CALL                                         ~2, 'getCount'
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

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

End of function getstate

Function increment:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nqZfK
function name:  increment
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_METHOD_CALL                                         'getState'
          1        DO_FCALL                                      0  $0      
          2        COPY_TMP                                         $1      $0
          3        FETCH_OBJ_R                                      ~2      'name'
          4        COPY_TMP                                         ~3      ~2
          5        FETCH_DIM_IS                                     ~4      $0, ~2
          6        FETCH_DIM_IS                                     ~5      ~4, 'count'
          7        COALESCE                                         ~6      ~5
          8        SEPARATE                                         $1      $1
          9        FETCH_DIM_W                                      $7      $1, ~3
         10        ASSIGN_DIM                                       ~8      $7, 'count'
         11        OP_DATA                                                  0
         12        QM_ASSIGN                                        ~6      ~8
         13      > JMP                                                      ->16
         14*       FREE                                                     $1
         15*       FREE                                                     ~3
         16    >   FREE                                                     ~6
   14    17        INIT_METHOD_CALL                                         'getState'
         18        DO_FCALL                                      0  $9      
         19        SEPARATE                                         $9      $9
         20        FETCH_OBJ_R                                      ~10     'name'
         21        FETCH_DIM_RW                                     $11     $9, ~10
         22        FETCH_DIM_RW                                     $12     $11, 'count'
         23        PRE_INC                                                  $12
   15    24      > RETURN                                                   null

End of function increment

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

End of function getcount

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
133.57 ms | 1002 KiB | 14 Q