3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RegularClass { private $name = 'REGULAR'; } class StaticFunctions { public static function doStuff() { $func = function () { // this is a static function unfortunately // try to access properties of bound instance echo $this->name; }; $rc = new RegularClass(); $bfunc = Closure::bind($func, $rc, 'RegularClass'); $bfunc(); } } StaticFunctions::doStuff();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d13XM
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'StaticFunctions', 'doStuff'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fd13XM%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d13XM
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, 'name'
          2        ECHO                                                     ~1
   15     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fd13XM%3A10%240

Class RegularClass: [no user functions]
Class StaticFunctions:
Function dostuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d13XM
function name:  doStuff
number of ops:  14
compiled vars:  !0 = $func, !1 = $rc, !2 = $bfunc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fd13XM%3A10%240'
          1        ASSIGN                                                   !0, ~3
   17     2        NEW                                              $5      'RegularClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
   19     5        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 'RegularClass'
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !2, $8
   21    11        INIT_DYNAMIC_CALL                                        !2
         12        DO_FCALL                                      0          
   22    13      > RETURN                                                   null

End of function dostuff

End of class StaticFunctions.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.04 ms | 1399 KiB | 13 Q