3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { private static $instance; private function __construct() { return 12; } private function __clone() {} private function __wakeup() {} public static function getInstance() { if (empty(self::$instance)) self::$instance = new self(); return self::$instance; } } $Object1 = Singleton::getInstance(); // ------------------------------------------------------- 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); } } $privacyViolator = new PrivacyViolator(); $c = $privacyViolator->callPrivateMethod($Object1, '__construct', []); echo $c;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2T6Xi
function name:  (null)
number of ops:  14
compiled vars:  !0 = $Object1, !1 = $privacyViolator, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   40     3        NEW                                              $5      'PrivacyViolator'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   41     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
   43    12        ECHO                                                     !2
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2T6Xi%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2T6Xi
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     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
   32    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2T6Xi%3A30%240

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2T6Xi
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   12
    8     1*     > 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/2T6Xi
function name:  __clone
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   null

End of function __clone

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

End of function __wakeup

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

End of function getinstance

End of class Singleton.

Class PrivacyViolator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2T6Xi
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2T6Xi%3A30%240'
          1        ASSIGN_OBJ                                               '_caller'
   32     2        OP_DATA                                                  ~1
   33     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/2T6Xi
function name:  callPrivateMethod
number of ops:  14
compiled vars:  !0 = $object, !1 = $method, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   36     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
   37    13*     > RETURN                                                   null

End of function callprivatemethod

End of class PrivacyViolator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173 ms | 1403 KiB | 13 Q