3v4l.org

run code in 500+ 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) { return $this->caller->bindTo($object, $object)->__invoke($method, $args); } } class MyClass { private function hello($args) { var_dump($args); } } $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/50bnu
function name:  (null)
number of ops:  12
compiled vars:  !0 = $myObject, !1 = $privacyViolator
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   NEW                                                  $2      'MyClass'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
   26     3        NEW                                                  $5      'PrivacyViolator'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $5
   27     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

Class PrivacyViolator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/50bnu
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                              ~1      [0]
          1        ASSIGN_OBJ                                                   'caller'
   10     2        OP_DATA                                                      ~1
   11     3      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/50bnu
function name:  {closure:PrivacyViolator::__construct():8}
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                                          1  $4      
          9      > RETURN                                                       $4
   10    10*     > RETURN                                                       null

End of Dynamic Function 0

End of function __construct

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

End of function hello

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.25 ms | 3273 KiB | 14 Q