3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { private $baz = 'tab'; } class Foo { private $bar = 'baz'; public function __construct() { $this->accessor = function () { return $this->baz; }; } } $foo = new Foo(); $bar = new Bar(); $accessor = $foo->accessor->bindTo($bar); var_dump($accessor());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8JFRT
function name:  (null)
number of ops:  17
compiled vars:  !0 = $foo, !1 = $bar, !2 = $accessor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        NEW                                              $6      'Bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   21     6        FETCH_OBJ_R                                      ~9      !0, 'accessor'
          7        INIT_METHOD_CALL                                         ~9, 'bindTo'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !2, $10
   23    11        INIT_FCALL                                               'var_dump'
         12        INIT_DYNAMIC_CALL                                        !2
         13        DO_FCALL                                      0  $12     
         14        SEND_VAR                                                 $12
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8JFRT%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8JFRT
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'baz'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8JFRT%3A14%240

Class Bar: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8JFRT
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8JFRT%3A14%240'
          1        ASSIGN_OBJ                                               'accessor'
          2        OP_DATA                                                  ~1
   15     3      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.47 ms | 1396 KiB | 15 Q