3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($a) { if (!is_array($a) && ! $a instanceof \Traversable) { throw new \Exception("here"); } return implode(' ', $a); } $traversable = new ArrayObject(); $traversable['test'] = 'that'; echo test(['a', 'b', 'c']); echo test((array) $traversable);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oZ5S9
function name:  (null)
number of ops:  15
compiled vars:  !0 = $traversable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $1      'ArrayObject'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   11     3        ASSIGN_DIM                                               !0, 'test'
          4        OP_DATA                                                  'that'
   12     5        INIT_FCALL                                               'test'
          6        SEND_VAL                                                 <array>
          7        DO_FCALL                                      0  $5      
          8        ECHO                                                     $5
   13     9        INIT_FCALL                                               'test'
         10        CAST                                          7  ~6      !0
         11        SEND_VAL                                                 ~6
         12        DO_FCALL                                      0  $7      
         13        ECHO                                                     $7
         14      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/oZ5S9
function name:  test
number of ops:  18
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        TYPE_CHECK                                  128  ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ_EX                                          ~2      ~2, ->7
          4    >   INSTANCEOF                                       ~3      !0, 'Traversable'
          5        BOOL_NOT                                         ~4      ~3
          6        BOOL                                             ~2      ~4
          7    > > JMPZ                                                     ~2, ->12
    5     8    >   NEW                                              $5      'Exception'
          9        SEND_VAL_EX                                              'here'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $5
    7    12    >   INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '+'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $7      
         16      > RETURN                                                   $7
    8    17*     > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.77 ms | 1390 KiB | 17 Q