3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PrivacyViolator { private $_caller; function __construct() { $this->_caller = function ($object, $method, $args) { return call_user_func_array(array($object, $method), $args); }; } function callPrivateMethod($object, $method, $args) { $this->_caller = Closure::bind($this->_caller, null, $object); return $this->_caller->__invoke($object, $method, $args); } } class MyClass { private function _hello($args) { var_dump($args); } } $myObject = new MyClass(); $privacyViolator = new PrivacyViolator(); $privacyViolator->callPrivateMethod($myObject, '_hello', array('world'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOt5C
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%2FYOt5C%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOt5C
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $object, !1 = $method, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    9     3        INIT_ARRAY                                       ~3      !0
          4        ADD_ARRAY_ELEMENT                                ~3      !1
          5        INIT_USER_CALL                                0          'call_user_func_array', ~3
          6        SEND_ARRAY                                               !2
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      0  $4      
          9      > RETURN                                                   $4
   10    10*     > RETURN                                                   null

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

Class PrivacyViolator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOt5C
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%2FYOt5C%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/YOt5C
function name:  callPrivateMethod
number of ops:  19
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      
   14     3        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          4        FETCH_OBJ_R                                      ~4      '_caller'
          5        SEND_VAL                                                 ~4
          6        SEND_VAL                                                 null
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $5      
          9        ASSIGN_OBJ                                               '_caller'
         10        OP_DATA                                                  $5
   15    11        FETCH_OBJ_R                                      ~6      '_caller'
         12        INIT_METHOD_CALL                                         ~6, '__invoke'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !1
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $7      
         17      > RETURN                                                   $7
   16    18*     > 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/YOt5C
function name:  _hello
number of ops:  5
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   23     4      > RETURN                                                   null

End of function _hello

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.22 ms | 1400 KiB | 15 Q