3v4l.org

run code in 500+ PHP versions simultaneously
<?php readonly class ImmutableBadNumberGenerator { public function __construct(private readonly int $i) {} public function generate(): int { static $j = 1; ++$j; return $this->i + $j; } } $o = new ImmutableBadNumberGenerator(10); var_dump($o->generate()); var_dump($o->generate()); var_dump($o->generate());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A2Lbs
function name:  (null)
number of ops:  20
compiled vars:  !0 = $o
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   NEW                                                  $1      'ImmutableBadNumberGenerator'
          1        SEND_VAL_EX                                                  10
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
   14     4        INIT_FCALL                                                   'var_dump'
          5        INIT_METHOD_CALL                                             !0, 'generate'
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
          8        DO_ICALL                                                     
   15     9        INIT_FCALL                                                   'var_dump'
         10        INIT_METHOD_CALL                                             !0, 'generate'
         11        DO_FCALL                                          0  $6      
         12        SEND_VAR                                                     $6
         13        DO_ICALL                                                     
   16    14        INIT_FCALL                                                   'var_dump'
         15        INIT_METHOD_CALL                                             !0, 'generate'
         16        DO_FCALL                                          0  $8      
         17        SEND_VAR                                                     $8
         18        DO_ICALL                                                     
         19      > RETURN                                                       1

Class ImmutableBadNumberGenerator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A2Lbs
function name:  __construct
number of ops:  4
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        ASSIGN_OBJ                                                   'i'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       null

End of function __construct

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A2Lbs
function name:  generate
number of ops:  8
compiled vars:  !0 = $j
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   BIND_STATIC                                                  !0
    8     1        PRE_INC                                                      !0
    9     2        FETCH_OBJ_R                                          ~2      'i'
          3        ADD                                                  ~3      ~2, !0
          4        VERIFY_RETURN_TYPE                                           ~3
          5      > RETURN                                                       ~3
   10     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function generate

End of class ImmutableBadNumberGenerator.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.66 ms | 1503 KiB | 14 Q