3v4l.org

run code in 300+ 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      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   17     3        NEW                                              $6      'FriendOfFoo'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   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        ASSIGN                                                   !2, $10
   21    14        INIT_DYNAMIC_CALL                                        !2
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

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        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 = 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        ECHO                                                     ~1
   11     3      > RETURN                                                   null

End of Dynamic Function 0

End of function dosomething

End of class FriendOfFoo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.64 ms | 1449 KiB | 13 Q