3v4l.org

run code in 300+ PHP versions simultaneously
<?php $i = 0; function is_cyclic(array &$array) { global $i; // Exit when too deep. if (++$i > 10) exit; echo "Call $i:\n"; var_dump($GLOBALS['bomb']); echo "\n"; $lastKey = array_key_last($array); if ($lastKey === null) { // Array is empty return false; } static $marker; if ($marker === null) $marker = new stdClass(); if ($array[$lastKey] === $marker) { return true; } $array[] = $marker; foreach ($array as &$item) { if (is_array($item) && is_cyclic($item)) { //array_pop($array); return true; } } //array_pop($array); return false; } function craft_bomb() { $array = [1, [2, 3]]; $array[1][1] = &$array; return $array; } $bomb = craft_bomb(); is_cyclic($bomb);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1d90
function name:  (null)
number of ops:  8
compiled vars:  !0 = $i, !1 = $bomb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 0
   44     1        INIT_FCALL                                               'craft_bomb'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   45     4        INIT_FCALL                                               'is_cyclic'
          5        SEND_REF                                                 !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function is_cyclic:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 125) Position 1 = 35, Position 2 = 46
Branch analysis from position: 35
2 jumps found. (Code = 126) Position 1 = 36, Position 2 = 46
Branch analysis from position: 36
2 jumps found. (Code = 46) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 42
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 28
filename:       /in/C1d90
function name:  is_cyclic
number of ops:  49
compiled vars:  !0 = $array, !1 = $i, !2 = $lastKey, !3 = $marker, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        BIND_GLOBAL                                              !1, 'i'
   10     2        PRE_INC                                          ~5      !1
          3        IS_SMALLER                                               10, ~5
          4      > JMPZ                                                     ~6, ->6
          5    > > EXIT                                                     
   12     6    >   ROPE_INIT                                     3  ~8      'Call+'
          7        ROPE_ADD                                      1  ~8      ~8, !1
          8        ROPE_END                                      2  ~7      ~8, '%3A%0A'
          9        ECHO                                                     ~7
   13    10        INIT_FCALL                                               'var_dump'
         11        FETCH_R                      global              ~10     'bomb'
         12        SEND_VAL                                                 ~10
         13        DO_ICALL                                                 
   14    14        ECHO                                                     '%0A'
   16    15        INIT_FCALL                                               'array_key_last'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !2, $12
   17    19        TYPE_CHECK                                    2          !2
         20      > JMPZ                                                     ~14, ->22
   19    21    > > RETURN                                                   <false>
   21    22    >   BIND_STATIC                                              !3
   22    23        TYPE_CHECK                                    2          !3
         24      > JMPZ                                                     ~15, ->28
   23    25    >   NEW                                              $16     'stdClass'
         26        DO_FCALL                                      0          
         27        ASSIGN                                                   !3, $16
   24    28    >   FETCH_DIM_R                                      ~19     !0, !2
         29        IS_IDENTICAL                                             !3, ~19
         30      > JMPZ                                                     ~20, ->32
   25    31    > > RETURN                                                   <true>
   27    32    >   ASSIGN_DIM                                               !0
         33        OP_DATA                                                  !3
   28    34      > FE_RESET_RW                                      $22     !0, ->46
         35    > > FE_FETCH_RW                                              $22, !4, ->46
   29    36    >   TYPE_CHECK                                  128  ~23     !4
         37      > JMPZ_EX                                          ~23     ~23, ->42
         38    >   INIT_FCALL_BY_NAME                                       'is_cyclic'
         39        SEND_VAR_EX                                              !4
         40        DO_FCALL                                      0  $24     
         41        BOOL                                             ~23     $24
         42    > > JMPZ                                                     ~23, ->45
   31    43    >   FE_FREE                                                  $22
         44      > RETURN                                                   <true>
   28    45    > > JMP                                                      ->35
         46    >   FE_FREE                                                  $22
   35    47      > RETURN                                                   <false>
   36    48*     > RETURN                                                   null

End of function is_cyclic

Function craft_bomb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1d90
function name:  craft_bomb
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ASSIGN                                                   !0, <array>
   40     1        FETCH_DIM_W                                      $2      !0, 1
          2        FETCH_DIM_W                                      $3      $2, 1
          3        ASSIGN_REF                                               $3, !0
   41     4      > RETURN                                                   !0
   42     5*     > RETURN                                                   null

End of function craft_bomb

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.01 ms | 1453 KiB | 17 Q