3v4l.org

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

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

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

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

End of function getprivate

End of class Hydrator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.64 ms | 1400 KiB | 15 Q