3v4l.org

run code in 500+ PHP versions simultaneously
<?php class SingletonTest { protected static $_instance; private function __construct(){} private function __clone(){} public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } class PrivacyViolator { private $_caller; function __construct() { $this->_caller = function ($method, $args) { return call_user_func_array([$this, $method], $args); }; } function callPrivateMethod($object, $method, $args) { $this->_caller->bindTo($object, $object); return $this->_caller($method, $args); } } $myObject = SingletonTest::getInstance(); $privacyViolator = new PrivacyViolator(); $newObject = $privacyViolator->callPrivateMethod($myObject, '__construct', []);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S5j87
function name:  (null)
number of ops:  13
compiled vars:  !0 = $myObject, !1 = $privacyViolator, !2 = $newObject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   INIT_STATIC_METHOD_CALL                                      'SingletonTest', 'getInstance'
          1        DO_FCALL                                          0  $3      
          2        ASSIGN                                                       !0, $3
   41     3        NEW                                                  $5      'PrivacyViolator'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $5
   42     6        INIT_METHOD_CALL                                             !1, 'callPrivateMethod'
          7        SEND_VAR_EX                                                  !0
          8        SEND_VAL_EX                                                  '__construct'
          9        SEND_VAL_EX                                                  <array>
         10        DO_FCALL                                          0  $8      
         11        ASSIGN                                                       !2, $8
         12      > RETURN                                                       1

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

End of function __construct

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

End of function __clone

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/S5j87
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      '_instance'
          1        TYPE_CHECK                                        2          ~0
          2      > JMPZ                                                         ~1, ->7
   14     3    >   NEW                              self                $3      
          4        DO_FCALL                                          0          
          5        ASSIGN_STATIC_PROP                                           '_instance'
          6        OP_DATA                                                      $3
   17     7    >   FETCH_STATIC_PROP_R              unknown             ~5      '_instance'
          8      > RETURN                                                       ~5
   18     9*     > RETURN                                                       null

End of function getinstance

End of class SingletonTest.

Class PrivacyViolator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S5j87
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   DECLARE_LAMBDA_FUNCTION                              ~1      [0]
          1        ASSIGN_OBJ                                                   '_caller'
   30     2        OP_DATA                                                      ~1
   31     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/S5j87
function name:  {closure:PrivacyViolator::__construct():28}
number of ops:  11
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   29     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
   30    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/S5j87
function name:  callPrivateMethod
number of ops:  14
compiled vars:  !0 = $object, !1 = $method, !2 = $args
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   33     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   35     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          
   36     8        INIT_METHOD_CALL                                             '_caller'
          9        SEND_VAR_EX                                                  !1
         10        SEND_VAR_EX                                                  !2
         11        DO_FCALL                                          0  $5      
         12      > RETURN                                                       $5
   37    13*     > RETURN                                                       null

End of function callprivatemethod

End of class PrivacyViolator.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.13 ms | 3378 KiB | 13 Q