3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { static function blah() { $class = get_called_class(); $a = new $class(function(){ echo $this->bobo; }); 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/MZT3Z
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%2FMZT3Z%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MZT3Z
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     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%2FMZT3Z%3A9%240

Class Test:
Function blah:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MZT3Z
function name:  blah
number of ops:  10
compiled vars:  !0 = $class, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   GET_CALLED_CLASS                                 ~2      
          1        ASSIGN                                                   !0, ~2
    9     2        FETCH_CLASS                                   0  $4      !0
          3        NEW                                              $5      $4
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMZT3Z%3A9%240'
          5        SEND_VAL_EX                                              ~6
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   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/MZT3Z
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:
153.79 ms | 1399 KiB | 13 Q