3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public int $v; public function makeClosure(int $v) { return function () use ($v) { echo $this->v . '-' . $v . "\n"; throw new \Exception(); }; } } $foo = new Foo(); $foo->v = 2; $fx = $foo->makeClosure(3); try { $fx(); } catch (\Throwable $e) { print_r($e); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 12
Branch analysis from position: 12
2 jumps found. (Code = 107) Position 1 = 13, Position 2 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YqFcG
function name:  (null)
number of ops:  17
compiled vars:  !0 = $foo, !1 = $fx, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   16     3        ASSIGN_OBJ                                               !0, 'v'
          4        OP_DATA                                                  2
   17     5        INIT_METHOD_CALL                                         !0, 'makeClosure'
          6        SEND_VAL_EX                                              3
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !1, $7
   20     9        INIT_DYNAMIC_CALL                                        !1
         10        DO_FCALL                                      0          
         11      > JMP                                                      ->16
   21    12  E > > CATCH                                       last         'Throwable'
   22    13    >   INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
   23    16    > > RETURN                                                   1

Class Foo:
Function makeclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YqFcG
function name:  makeClosure
number of ops:  5
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          2        BIND_LEXICAL                                             ~1, !0
   11     3      > RETURN                                                   ~1
   12     4*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/YqFcG
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   BIND_STATIC                                              !0
    9     1        FETCH_THIS                                       $1      
          2        FETCH_OBJ_R                                      ~2      $1, 'v'
          3        CONCAT                                           ~3      ~2, '-'
          4        CONCAT                                           ~4      ~3, !0
          5        CONCAT                                           ~5      ~4, '%0A'
          6        ECHO                                                     ~5
   10     7        NEW                                              $6      'Exception'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $6
   11    10*     > RETURN                                                   null

End of Dynamic Function 0

End of function makeclosure

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.97 ms | 1010 KiB | 14 Q