3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = 'baz'; } class Test { public static function getReader() { $reader = function & ($object, $property) { $value = & Closure::bind(function & () use ($property) { return $this->$property; }, $object, $object)->__invoke(); return $value; }; return $reader; } public function doStuff() { $reader = self::getReader(); $foo = new Foo(); $bar = & $reader($foo, 'bar'); $bar = 'tabb'; return $foo; } } $test = new Test(); $foo = $test->doStuff(); var_dump($foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pFnog
function name:  (null)
number of ops:  10
compiled vars:  !0 = $test, !1 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $2      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   34     3        INIT_METHOD_CALL                                         !0, 'doStuff'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   37     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FpFnog%3A12%240:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/pFnog
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $object, !1 = $property, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpFnog%3A13%241'
          4        BIND_LEXICAL                                             ~3, !1
   15     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
   17    12      > RETURN_BY_REF                                            !2
   18    13*     > RETURN_BY_REF                                            null

End of function %00%7Bclosure%7D%2Fin%2FpFnog%3A12%240

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

End of function %00%7Bclosure%7D%2Fin%2FpFnog%3A13%241

Class Foo: [no user functions]
Class Test:
Function getreader:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pFnog
function name:  getReader
number of ops:  4
compiled vars:  !0 = $reader
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpFnog%3A12%240'
          1        ASSIGN                                                   !0, ~1
   19     2      > RETURN                                                   !0
   20     3*     > RETURN                                                   null

End of function getreader

Function dostuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pFnog
function name:  doStuff
number of ops:  14
compiled vars:  !0 = $reader, !1 = $foo, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'getReader'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   25     3        NEW                                              $5      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   26     6        INIT_DYNAMIC_CALL                                        !0
          7        SEND_VAR_EX                                              !1
          8        SEND_VAL_EX                                              'bar'
          9        DO_FCALL                                      0  $8      
         10        ASSIGN_REF                                               !2, $8
   27    11        ASSIGN                                                   !2, 'tabb'
   28    12      > RETURN                                                   !1
   29    13*     > RETURN                                                   null

End of function dostuff

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.27 ms | 1400 KiB | 15 Q