3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo =2; } class Proxy extends Foo { public function getFoo() { $getter = function(){return $this->foo;}; return \Closure::bind($getter, $this, 'Foo'); } } $hydrated = new Proxy(); $getter = $hydrated->getFoo(); var_dump($getter());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kraek
function name:  (null)
number of ops:  12
compiled vars:  !0 = $hydrated, !1 = $getter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'Proxy'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   16     3        INIT_METHOD_CALL                                         !0, 'getFoo'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   18     6        INIT_FCALL                                               'var_dump'
          7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0  $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

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

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

Class Foo: [no user functions]
Class Proxy:
Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kraek
function name:  getFoo
number of ops:  10
compiled vars:  !0 = $getter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FKraek%3A10%240'
          1        ASSIGN                                                   !0, ~1
   11     2        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          3        SEND_VAR                                                 !0
          4        FETCH_THIS                                       ~3      
          5        SEND_VAL                                                 ~3
          6        SEND_VAL                                                 'Foo'
          7        DO_FCALL                                      0  $4      
          8      > RETURN                                                   $4
   12     9*     > RETURN                                                   null

End of function getfoo

End of class Proxy.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.58 ms | 1396 KiB | 15 Q