3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ private $a; function getAnon(){ $b = 1; return function() use ($b) { echo $b; echo $this->a; }; } } $x = new Foo(); $z = $x->getAnon(); $z(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/smvPt
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x, !1 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   16     3        INIT_METHOD_CALL                                         !0, 'getAnon'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   18     6        INIT_DYNAMIC_CALL                                        !1
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   1

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


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

End of Dynamic Function 0

End of function getanon

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.8 ms | 995 KiB | 13 Q