3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $secretProperty = "Hello"; private function secretMethod() { return 'World'; } } $privatePropertyAccessor = function($prop) { return $this->$prop; }; $privateMethodAccessor = function($method) { return call_user_func(array($this, $method)); }; $foo = new Foo(); $x = $privatePropertyAccessor->bindTo($foo, 'Foo'); echo $x('secretProperty'); $y = $privateMethodAccessor->bindTo($foo, 'Foo'); echo $y('secretMethod'); //echo $privatePropertyAccessor->call($foo, 'secretProperty'); // Hello //echo $privateMethodAccessor->call($foo, 'secretMethod'); // World
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mujS
function name:  (null)
number of ops:  26
compiled vars:  !0 = $privatePropertyAccessor, !1 = $privateMethodAccessor, !2 = $foo, !3 = $x, !4 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9mujS%3A11%240'
          1        ASSIGN                                                   !0, ~5
   13     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9mujS%3A13%241'
          3        ASSIGN                                                   !1, ~7
   15     4        NEW                                              $9      'Foo'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $9
   17     7        INIT_METHOD_CALL                                         !0, 'bindTo'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAL_EX                                              'Foo'
         10        DO_FCALL                                      0  $12     
         11        ASSIGN                                                   !3, $12
   18    12        INIT_DYNAMIC_CALL                                        !3
         13        SEND_VAL_EX                                              'secretProperty'
         14        DO_FCALL                                      0  $14     
         15        ECHO                                                     $14
   20    16        INIT_METHOD_CALL                                         !1, 'bindTo'
         17        SEND_VAR_EX                                              !2
         18        SEND_VAL_EX                                              'Foo'
         19        DO_FCALL                                      0  $15     
         20        ASSIGN                                                   !4, $15
   21    21        INIT_DYNAMIC_CALL                                        !4
         22        SEND_VAL_EX                                              'secretMethod'
         23        DO_FCALL                                      0  $17     
         24        ECHO                                                     $17
   24    25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9mujS%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mujS
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !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%2F9mujS%3A11%240

Function %00%7Bclosure%7D%2Fin%2F9mujS%3A13%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mujS
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       ~1      
          2        INIT_ARRAY                                       ~2      ~1
          3        ADD_ARRAY_ELEMENT                                ~2      !0
          4        INIT_USER_CALL                                0          'call_user_func', ~2
          5        DO_FCALL                                      0  $3      
          6      > RETURN                                                   $3
          7*     > RETURN                                                   null

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

Class Foo:
Function secretmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mujS
function name:  secretMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   'World'
    8     1*     > RETURN                                                   null

End of function secretmethod

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.42 ms | 1399 KiB | 13 Q