3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { static function blah() { $get_closure = function() { return function(){ echo $this->bobo; }; }; $a = new static($get_closure()); return $a; } public $clos; public $bobo = 22; function __construct(\Closure $c) { $this->clos = $c->bindTo($this, $this); } } $a = Test::blah(); $ss = $a->clos; $ss();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nMnBG
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a, !1 = $ss
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_STATIC_METHOD_CALL                                  'Test', 'blah'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   22     3        FETCH_OBJ_R                                      ~4      !0, 'clos'
          4        ASSIGN                                                   !1, ~4
   23     5        INIT_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FnMnBG%3A8%240

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

End of function %00%7Bclosure%7D%2Fin%2FnMnBG%3A8%241

Class Test:
Function blah:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nMnBG
function name:  blah
number of ops:  10
compiled vars:  !0 = $get_closure, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FnMnBG%3A8%240'
          1        ASSIGN                                                   !0, ~2
    9     2        NEW                          static              $4      
          3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0  $5      
          5        SEND_VAR_NO_REF_EX                                       $5
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $4
   10     8      > RETURN                                                   !1
   11     9*     > RETURN                                                   null

End of function blah

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nMnBG
function name:  __construct
number of ops:  10
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_METHOD_CALL                                         !0, 'bindTo'
          2        FETCH_THIS                                       $2      
          3        SEND_VAR_EX                                              $2
          4        FETCH_THIS                                       $3      
          5        SEND_VAR_EX                                              $3
          6        DO_FCALL                                      0  $4      
          7        ASSIGN_OBJ                                               'clos'
          8        OP_DATA                                                  $4
   18     9      > RETURN                                                   null

End of function __construct

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.86 ms | 1399 KiB | 13 Q