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/2cgoh
function name:  (null)
number of ops:  9
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
   21     6        INIT_DYNAMIC_CALL                                        !2
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2cgoh%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2cgoh
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 function %00%7Bclosure%7D%2Fin%2F2cgoh%3A9%240

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/2cgoh
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                                  '%00%7Bclosure%7D%2Fin%2F2cgoh%3A9%240'
          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 8.0.0


preferences:
146.46 ms | 1394 KiB | 13 Q