3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Fish {} class Mammal {} class Whale extends Mammal {} class Human extends Mammal {} class Shark extends Fish {} function anyFish(array $collection) { foreach ($collection as $item) { if((is_array($item) && anyFish($item)) || $item instanceof Fish) { return true; } } return false; } $solar_system = [ 'mars' => [ 'dirt' => [new Human] ], 'earth' => [ 'pacific' => [new Whale, new Whale, new Whale], 'atlantic' => [new Human] ] ]; $seas = [ 'pacific' => [new Whale, new Whale, new Shark, new Whale], 'atlantic' => [new Human, new Shark] ]; $pub = [new Human, new Human]; var_dump(anyFish($solar_system)); var_dump(anyFish($seas)); var_dump(anyFish($pub));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZTMcu
function name:  (null)
number of ops:  68
compiled vars:  !0 = $solar_system, !1 = $seas, !2 = $pub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $3      'Human'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~5      $3
          3        INIT_ARRAY                                       ~6      ~5, 'dirt'
          4        INIT_ARRAY                                       ~7      ~6, 'mars'
   25     5        NEW                                              $8      'Whale'
          6        DO_FCALL                                      0          
          7        INIT_ARRAY                                       ~10     $8
          8        NEW                                              $11     'Whale'
          9        DO_FCALL                                      0          
         10        ADD_ARRAY_ELEMENT                                ~10     $11
         11        NEW                                              $13     'Whale'
         12        DO_FCALL                                      0          
         13        ADD_ARRAY_ELEMENT                                ~10     $13
         14        INIT_ARRAY                                       ~15     ~10, 'pacific'
   26    15        NEW                                              $16     'Human'
         16        DO_FCALL                                      0          
         17        INIT_ARRAY                                       ~18     $16
         18        ADD_ARRAY_ELEMENT                                ~15     ~18, 'atlantic'
         19        ADD_ARRAY_ELEMENT                                ~7      ~15, 'earth'
   20    20        ASSIGN                                                   !0, ~7
   31    21        NEW                                              $20     'Whale'
         22        DO_FCALL                                      0          
         23        INIT_ARRAY                                       ~22     $20
         24        NEW                                              $23     'Whale'
         25        DO_FCALL                                      0          
         26        ADD_ARRAY_ELEMENT                                ~22     $23
         27        NEW                                              $25     'Shark'
         28        DO_FCALL                                      0          
         29        ADD_ARRAY_ELEMENT                                ~22     $25
         30        NEW                                              $27     'Whale'
         31        DO_FCALL                                      0          
         32        ADD_ARRAY_ELEMENT                                ~22     $27
         33        INIT_ARRAY                                       ~29     ~22, 'pacific'
   32    34        NEW                                              $30     'Human'
         35        DO_FCALL                                      0          
         36        INIT_ARRAY                                       ~32     $30
         37        NEW                                              $33     'Shark'
         38        DO_FCALL                                      0          
         39        ADD_ARRAY_ELEMENT                                ~32     $33
         40        ADD_ARRAY_ELEMENT                                ~29     ~32, 'atlantic'
   30    41        ASSIGN                                                   !1, ~29
   35    42        NEW                                              $36     'Human'
         43        DO_FCALL                                      0          
         44        INIT_ARRAY                                       ~38     $36
         45        NEW                                              $39     'Human'
         46        DO_FCALL                                      0          
         47        ADD_ARRAY_ELEMENT                                ~38     $39
         48        ASSIGN                                                   !2, ~38
   37    49        INIT_FCALL                                               'var_dump'
         50        INIT_FCALL                                               'anyfish'
         51        SEND_VAR                                                 !0
         52        DO_FCALL                                      0  $42     
         53        SEND_VAR                                                 $42
         54        DO_ICALL                                                 
   38    55        INIT_FCALL                                               'var_dump'
         56        INIT_FCALL                                               'anyfish'
         57        SEND_VAR                                                 !1
         58        DO_FCALL                                      0  $44     
         59        SEND_VAR                                                 $44
         60        DO_ICALL                                                 
   39    61        INIT_FCALL                                               'var_dump'
         62        INIT_FCALL                                               'anyfish'
         63        SEND_VAR                                                 !2
         64        DO_FCALL                                      0  $46     
         65        SEND_VAR                                                 $46
         66        DO_ICALL                                                 
         67      > RETURN                                                   1

Function anyfish:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/ZTMcu
function name:  anyFish
number of ops:  19
compiled vars:  !0 = $collection, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1      > FE_RESET_R                                       $2      !0, ->16
          2    > > FE_FETCH_R                                               $2, !1, ->16
   12     3    >   TYPE_CHECK                                  128  ~3      !1
          4      > JMPZ_EX                                          ~3      ~3, ->9
          5    >   INIT_FCALL_BY_NAME                                       'anyFish'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $4      
          8        BOOL                                             ~3      $4
          9    > > JMPNZ_EX                                         ~3      ~3, ->12
         10    >   INSTANCEOF                                       ~5      !1, 'Fish'
         11        BOOL                                             ~3      ~5
         12    > > JMPZ                                                     ~3, ->15
   14    13    >   FE_FREE                                                  $2
         14      > RETURN                                                   <true>
   10    15    > > JMP                                                      ->2
         16    >   FE_FREE                                                  $2
   17    17      > RETURN                                                   <false>
   18    18*     > RETURN                                                   null

End of function anyfish

Class Fish: [no user functions]
Class Mammal: [no user functions]
Class Whale: [no user functions]
Class Human: [no user functions]
Class Shark: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.1 ms | 1407 KiB | 18 Q