3v4l.org

run code in 200+ PHP versions simultaneously
<?php class Foo { private $bar = 'hello world'; } class FriendOfFoo { public function doSomething($foo) { return function() use ($foo) { echo $foo->bar; }; } } $foo = new Foo(); $service = new FriendOfFoo(); $closure = $service->doSomething($foo)->bindTo(null, $foo); $closure();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3YdLN
function name:  (null)
number of ops:  17
compiled vars:  !0 = $foo, !1 = $service, !2 = $closure
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   NEW                                              $3      :29
         1        DO_FCALL                                      0          
         2        QM_ASSIGN                                                !0
  17     3        NEW                                              $6      :25
         4        DO_FCALL                                      0          
         5        QM_ASSIGN                                                !1
  19     6        INIT_METHOD_CALL                                         !1, 'doSomething'
         7        SEND_VAR_EX                                              !0
         8        DO_FCALL                                      0  $9      
         9        INIT_METHOD_CALL                                         $9, 'bindTo'
        10        SEND_VAL_EX                                              null
        11        SEND_VAR_EX                                              !0
        12        DO_FCALL                                      0  $10     
        13        QM_ASSIGN                                                !2
  21    14        INIT_DYNAMIC_CALL                                        !2
        15        DO_FCALL                                      0          
        16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F3YdLN0x7fe741c7a0bf:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3YdLN
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   9     0  E >   BIND_STATIC                                              !0
  10     1        FETCH_OBJ_R                                      ~1      !0, 'bar'
         2        ASSIGN_OBJ                                               ~1
  11     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F3YdLN0x7fe741c7a0bf

Class Foo: [no user functions]
Class FriendOfFoo:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3YdLN
function name:  doSomething
number of ops:  5
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   8     0  E >   RECV                                             !0      
   9     1        RAISE_ABSTRACT_ERROR                             ~1      '%00%7Bclosure%7D%2Fin%2F3YdLN0x7fe741c7a0bf'
         2        BIND_LEXICAL                                             ~1, !0
  11     3      > RETURN                                                   ~1
  12     4*     > RETURN                                                   null

End of function dosomething

End of class FriendOfFoo.

Generated using Vulcan Logic Dumper, using php 7.4.0