3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(callable $fn, callable $decorator) { return function() use ($fn, $decorator) { $d = $decorator(); $gen = $d(); var_dump($gen->current()); }; } function foo() { throw new Exception("Error!"); } function catch_all_exceptions() { return function() { try { (yield ["foo" => "bar"]); } catch (\Exception $e) { echo "Caught Exception: $e\n"; } }; } $foo = decorate("foo", "catch_all_exceptions"); $foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfUgf
function name:  (null)
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'decorate'
          1        SEND_VAL                                                 'foo'
          2        SEND_VAL                                                 'catch_all_exceptions'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   29     5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function decorate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfUgf
function name:  decorate
number of ops:  7
compiled vars:  !0 = $fn, !1 = $decorator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVfUgf%3A5%240'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
    9     5      > RETURN                                                   ~2
   10     6*     > RETURN                                                   null

End of function decorate

Function %00%7Bclosure%7D%2Fin%2FVfUgf%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfUgf
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $fn, !1 = $decorator, !2 = $d, !3 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
    6     2        INIT_DYNAMIC_CALL                                        !1
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !2, $4
    7     5        INIT_DYNAMIC_CALL                                        !2
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !3, $6
    8     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !3, 'current'
         10        DO_FCALL                                      0  $8      
         11        SEND_VAR                                                 $8
         12        DO_ICALL                                                 
    9    13      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVfUgf%3A5%240

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/VfUgf
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $0      'Exception'
          1        SEND_VAL_EX                                              'Error%21'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $0
   15     4*     > RETURN                                                   null

End of function foo

Function catch_all_exceptions:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfUgf
function name:  catch_all_exceptions
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVfUgf%3A19%241'
   25     1      > RETURN                                                   ~0
   26     2*     > RETURN                                                   null

End of function catch_all_exceptions

Function %00%7Bclosure%7D%2Fin%2FVfUgf%3A19%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 161) Position 1 = -2
Found catch point at position: 3
Branch analysis from position: 3
2 jumps found. (Code = 107) Position 1 = 4, Position 2 = -2
Branch analysis from position: 4
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/VfUgf
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   GENERATOR_CREATE                                         
   21     1        YIELD                                                    <array>
          2      > JMP                                                      ->8
   22     3  E > > CATCH                                       last         'Exception'
   23     4    >   ROPE_INIT                                     3  ~3      'Caught+Exception%3A+'
          5        ROPE_ADD                                      1  ~3      ~3, !0
          6        ROPE_END                                      2  ~2      ~3, '%0A'
          7        ECHO                                                     ~2
   25     8    > > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FVfUgf%3A19%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.4 ms | 1394 KiB | 16 Q