3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_closure() { return function(){ echo $this->bobo; }; } class Test { static function blah() { $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/VHJ37
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a, !1 = $ss
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'Test', 'blah'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   25     3        FETCH_OBJ_R                                      ~4      !0, 'clos'
          4        ASSIGN                                                   !1, ~4
   26     5        INIT_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

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

End of function get_closure

Function %00%7Bclosure%7D%2Fin%2FVHJ37%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VHJ37
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     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%2FVHJ37%3A4%240

Class Test:
Function blah:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VHJ37
function name:  blah
number of ops:  8
compiled vars:  !0 = $a, !1 = $get_closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                          static              $2      
          1        INIT_DYNAMIC_CALL                                        !1
          2        DO_FCALL                                      0  $3      
          3        SEND_VAR_NO_REF_EX                                       $3
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $2
   13     6      > RETURN                                                   !0
   14     7*     > 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/VHJ37
function name:  __construct
number of ops:  10
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     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
   21     9      > RETURN                                                   null

End of function __construct

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.79 ms | 1399 KiB | 13 Q