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 {} // Not very exceptional... class FoundException extends Exception {} function anyFish(array $collection) { $found = false; try { array_walk_recursive($collection, function ($v) { if($v instanceof Fish) throw new FoundException('I found a fish.'); }); } catch (FoundException $e) { $found = true; } return $found; } $seas = [ 'pacific' => [new Whale, new Shark], 'atlantic' => [new Human, new Shark] ]; $pub = [new Human, new Human]; 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/OvMMm
function name:  (null)
number of ops:  35
compiled vars:  !0 = $seas, !1 = $pub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $2      'Whale'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~4      $2
          3        NEW                                              $5      'Shark'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~4      $5
          6        INIT_ARRAY                                       ~7      ~4, 'pacific'
   33     7        NEW                                              $8      'Human'
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~10     $8
         10        NEW                                              $11     'Shark'
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~10     $11
         13        ADD_ARRAY_ELEMENT                                ~7      ~10, 'atlantic'
   31    14        ASSIGN                                                   !0, ~7
   36    15        NEW                                              $14     'Human'
         16        DO_FCALL                                      0          
         17        INIT_ARRAY                                       ~16     $14
         18        NEW                                              $17     'Human'
         19        DO_FCALL                                      0          
         20        ADD_ARRAY_ELEMENT                                ~16     $17
         21        ASSIGN                                                   !1, ~16
   38    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'anyfish'
         24        SEND_VAR                                                 !0
         25        DO_FCALL                                      0  $20     
         26        SEND_VAR                                                 $20
         27        DO_ICALL                                                 
   39    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'anyfish'
         30        SEND_VAR                                                 !1
         31        DO_FCALL                                      0  $22     
         32        SEND_VAR                                                 $22
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Function anyfish:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OvMMm
function name:  anyFish
number of ops:  12
compiled vars:  !0 = $collection, !1 = $found, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, <false>
   18     2        INIT_FCALL                                               'array_walk_recursive'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOvMMm%3A18%240'
   21     5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
          7      > JMP                                                      ->10
   23     8  E > > CATCH                                       last         'FoundException'
   25     9    >   ASSIGN                                                   !1, <true>
   28    10    > > RETURN                                                   !1
   29    11*     > RETURN                                                   null

End of function anyfish

Function %00%7Bclosure%7D%2Fin%2FOvMMm%3A18%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OvMMm
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INSTANCEOF                                               !0, 'Fish'
          2      > JMPZ                                                     ~1, ->7
   20     3    >   NEW                                              $2      'FoundException'
          4        SEND_VAL_EX                                              'I+found+a+fish.'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
   21     7    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOvMMm%3A18%240

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]
Class FoundException: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.2 ms | 1403 KiB | 19 Q