3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PrivacyViolator { private $caller; function __construct() { $this->caller = function ($method, $args) { return call_user_func_array([$this, $method], $args); }; } function callPrivateMethod($object, $method, $args) { var_dump($method); $this->caller->bindTo($object, $object); return $this->caller($method, $args); } } class MyClass { private $private_var; private function hello() { return "I'm private method"; } } $myObject = new MyClass(); $privacyViolator = new PrivacyViolator(); $privacyViolator->callPrivateMethod($myObject, 'hello', ['world']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEdLe
function name:  (null)
number of ops:  12
compiled vars:  !0 = $myObject, !1 = $privacyViolator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   27     3        NEW                                              $5      'PrivacyViolator'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   28     6        INIT_METHOD_CALL                                         !1, 'callPrivateMethod'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAL_EX                                              'hello'
          9        SEND_VAL_EX                                              <array>
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FaEdLe%3A8%240

Class PrivacyViolator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEdLe
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaEdLe%3A8%240'
          1        ASSIGN_OBJ                                               'caller'
   10     2        OP_DATA                                                  ~1
   11     3      > RETURN                                                   null

End of function __construct

Function callprivatemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEdLe
function name:  callPrivateMethod
number of ops:  17
compiled vars:  !0 = $object, !1 = $method, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   15     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
   16     6        FETCH_OBJ_R                                      ~4      'caller'
          7        INIT_METHOD_CALL                                         ~4, 'bindTo'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
   17    11        INIT_METHOD_CALL                                         'caller'
         12        SEND_VAR_EX                                              !1
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $6      
         15      > RETURN                                                   $6
   18    16*     > RETURN                                                   null

End of function callprivatemethod

End of class PrivacyViolator.

Class MyClass:
Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aEdLe
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E > > RETURN                                                   'I%27m+private+method'
   24     1*     > RETURN                                                   null

End of function hello

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.24 ms | 1400 KiB | 15 Q