3v4l.org

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

Function %00%7Bclosure%7D%2Fin%2FpXav1%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pXav1
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $obj, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ASSIGN_OBJ                                               !0, 'baz'
          3        OP_DATA                                                  !1
          4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpXav1%3A12%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/pXav1
function name:  __construct
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpXav1%3A12%240'
          1        ASSIGN_OBJ                                               'writer'
          2        OP_DATA                                                  ~1
   14     3        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          4        FETCH_OBJ_R                                      ~3      'writer'
          5        SEND_VAL                                                 ~3
          6        FETCH_THIS                                       ~4      
          7        SEND_VAL                                                 ~4
          8        SEND_VAL                                                 'Bar'
          9        DO_FCALL                                      0  $5      
         10        ASSIGN_OBJ                                               'writer'
         11        OP_DATA                                                  $5
   15    12      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.16 ms | 1401 KiB | 15 Q