3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { function b() { static $count; if (null === $count) { $count = 1; return ['a', 'b']; } return $count++; } } $a = new A; var_dump($a->b(), $a->b()); $a = new A; var_dump($a->b()[$a->b()]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vkCd1
function name:  (null)
number of ops:  23
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   17     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'b'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        INIT_METHOD_CALL                                         !0, 'b'
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
   19    11        NEW                                              $7      'A'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $7
   21    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'b'
         16        DO_FCALL                                      0  $10     
         17        INIT_METHOD_CALL                                         !0, 'b'
         18        DO_FCALL                                      0  $11     
         19        FETCH_DIM_R                                      ~12     $10, $11
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class A:
Function b:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vkCd1
function name:  b
number of ops:  8
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    7     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->5
    8     3    >   ASSIGN                                                   !0, 1
    9     4      > RETURN                                                   <array>
   12     5    >   POST_INC                                         ~3      !0
          6      > RETURN                                                   ~3
   13     7*     > RETURN                                                   null

End of function b

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.28 ms | 1388 KiB | 15 Q