3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public array $elements = []; public function __construct(int $howMany) { for ($i = 0; $i < $howMany; $i++) { $this->elements[] = random_int(1, 100); } } } class Demo { public Foo $foo; public function __construct(int $howMany) { $this->foo = new Foo($howMany); } public function demo(): void { echo "\nWe start with ", count($this->foo->elements), " soldiers in \$foo->elements\n"; $this->removeElement(); echo "\nWe now have ", count($this->foo->elements), " soldiers in \$foo->elements\n"; } private function removeElement(): void { array_splice($this->foo->elements, 2, 1); } } $init = random_int(4,10); $demo = new Demo($init); $demo->demo(); $remaining = count($demo->foo->elements); if ($init-1 !== $remaining) { throw new UnexpectedValueException('Wrong number of elements, application is broken'); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MjmHv
function name:  (null)
number of ops:  23
compiled vars:  !0 = $init, !1 = $demo, !2 = $remaining
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                                   'random_int'
          1        SEND_VAL                                                     4
          2        SEND_VAL                                                     10
          3        DO_ICALL                                             $3      
          4        ASSIGN                                                       !0, $3
   40     5        NEW                                                  $5      'Demo'
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $5
   41     9        INIT_METHOD_CALL                                             !1, 'demo'
         10        DO_FCALL                                          0          
   43    11        FETCH_OBJ_R                                          ~9      !1, 'foo'
         12        FETCH_OBJ_R                                          ~10     ~9, 'elements'
         13        COUNT                                                ~11     ~10
         14        ASSIGN                                                       !2, ~11
   45    15        SUB                                                  ~13     !0, 1
         16        IS_NOT_IDENTICAL                                             !2, ~13
         17      > JMPZ                                                         ~14, ->22
   46    18    >   NEW                                                  $15     'UnexpectedValueException'
         19        SEND_VAL_EX                                                  'Wrong+number+of+elements%2C+application+is+broken'
         20        DO_FCALL                                          0          
         21      > THROW                                             0          $15
   47    22    > > RETURN                                                       1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
Branch analysis from position: 3
filename:       /in/MjmHv
function name:  __construct
number of ops:  14
compiled vars:  !0 = $howMany, !1 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->11
   10     3    >   INIT_FCALL                                                   'random_int'
          4        SEND_VAL                                                     1
          5        SEND_VAL                                                     100
          6        DO_ICALL                                             $5      
          7        FETCH_OBJ_W                                          $3      'elements'
          8        ASSIGN_DIM                                                   $3
          9        OP_DATA                                                      $5
    9    10        PRE_INC                                                      !1
         11    >   IS_SMALLER                                                   !1, !0
         12      > JMPNZ                                                        ~7, ->3
   12    13    > > RETURN                                                       null

End of function __construct

End of class Foo.

Class Demo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MjmHv
function name:  __construct
number of ops:  7
compiled vars:  !0 = $howMany
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
   22     1        NEW                                                  $2      'Foo'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN_OBJ                                                   'foo'
          5        OP_DATA                                                      $2
   23     6      > RETURN                                                       null

End of function __construct

Function demo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MjmHv
function name:  demo
number of ops:  15
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                         '%0AWe+start+with+'
          1        FETCH_OBJ_R                                          ~0      'foo'
          2        FETCH_OBJ_R                                          ~1      ~0, 'elements'
          3        COUNT                                                ~2      ~1
          4        ECHO                                                         ~2
          5        ECHO                                                         '+soldiers+in+%24foo-%3Eelements%0A'
   28     6        INIT_METHOD_CALL                                             'removeElement'
          7        DO_FCALL                                          0          
   30     8        ECHO                                                         '%0AWe+now+have+'
          9        FETCH_OBJ_R                                          ~4      'foo'
         10        FETCH_OBJ_R                                          ~5      ~4, 'elements'
         11        COUNT                                                ~6      ~5
         12        ECHO                                                         ~6
         13        ECHO                                                         '+soldiers+in+%24foo-%3Eelements%0A'
   31    14      > RETURN                                                       null

End of function demo

Function removeelement:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MjmHv
function name:  removeElement
number of ops:  8
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                                   'array_splice'
          1        FETCH_OBJ_W                                          $0      'foo'
          2        FETCH_OBJ_W                                          $1      $0, 'elements'
          3        SEND_REF                                                     $1
          4        SEND_VAL                                                     2
          5        SEND_VAL                                                     1
          6        DO_ICALL                                                     
   36     7      > RETURN                                                       null

End of function removeelement

End of class Demo.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.39 ms | 1393 KiB | 15 Q