3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = 'baz'; } $foo = new Foo(); echo spl_object_hash($foo); $reader = function & ($object, $property) { $value = & Closure::bind(function & () use ($property) { return $this->$property; }, $object, $object)->__invoke(); return $value; }; $bar = & $reader($foo, 'bar'); //var_dump($bar); $bar = 'tab1'; unset($bar); echo spl_object_hash($foo); var_dump($foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kj8nc
function name:  (null)
number of ops:  24
compiled vars:  !0 = $foo, !1 = $reader, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    8     3        INIT_FCALL                                               'spl_object_hash'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ECHO                                                     $6
   11     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FKj8nc%3A11%240'
          8        ASSIGN                                                   !1, ~7
   20     9        INIT_DYNAMIC_CALL                                        !1
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              'bar'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN_REF                                               !2, $9
   22    14        ASSIGN                                                   !2, 'tab1'
   23    15        UNSET_CV                                                 !2
   24    16        INIT_FCALL                                               'spl_object_hash'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $12     
         19        ECHO                                                     $12
   25    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FKj8nc%3A11%240:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/Kj8nc
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $object, !1 = $property, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FKj8nc%3A12%241'
          4        BIND_LEXICAL                                             ~3, !1
   14     5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $4      
          9        INIT_METHOD_CALL                                         $4, '__invoke'
         10        DO_FCALL                                      0  $5      
         11        ASSIGN_REF                                               !2, $5
   16    12      > RETURN_BY_REF                                            !2
   17    13*     > RETURN_BY_REF                                            null

End of function %00%7Bclosure%7D%2Fin%2FKj8nc%3A11%240

Function %00%7Bclosure%7D%2Fin%2FKj8nc%3A12%241:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/Kj8nc
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   BIND_STATIC                                              !0
   13     1        FETCH_THIS                                       $1      
          2        FETCH_OBJ_W                                      $2      $1, !0
          3      > RETURN_BY_REF                                            $2
   14     4*     > RETURN_BY_REF                                            null

End of function %00%7Bclosure%7D%2Fin%2FKj8nc%3A12%241

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.07 ms | 1400 KiB | 17 Q