3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { private static $instance; private function __construct() {} 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 $Object1 == $c ? '+' : '-'; echo $Object1 === $c ? '+' : '-';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
Branch analysis from position: 22
filename:       /in/ss2mX
function name:  (null)
number of ops:  25
compiled vars:  !0 = $Object1, !1 = $privacyViolator, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   38     3        NEW                                              $5      'PrivacyViolator'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   39     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
   41    12        IS_EQUAL                                                 !0, !2
         13      > JMPZ                                                     ~10, ->16
         14    >   QM_ASSIGN                                        ~11     '%2B'
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~11     '-'
         17    >   ECHO                                                     ~11
   42    18        IS_IDENTICAL                                             !0, !2
         19      > JMPZ                                                     ~12, ->22
         20    >   QM_ASSIGN                                        ~13     '%2B'
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~13     '-'
         23    >   ECHO                                                     ~13
         24      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fss2mX%3A28%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss2mX
function name:  {closure}
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                                      0  $4      
          9      > RETURN                                                   $4
   30    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fss2mX%3A28%240

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss2mX
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     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/ss2mX
function name:  __clone
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     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/ss2mX
function name:  __wakeup
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     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/ss2mX
function name:  getInstance
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ISSET_ISEMPTY_STATIC_PROP                                'instance'
          1      > JMPZ                                                     ~0, ->6
   14     2    >   NEW                          self                $2      
          3        DO_FCALL                                      0          
          4        ASSIGN_STATIC_PROP                                       'instance'
          5        OP_DATA                                                  $2
   16     6    >   FETCH_STATIC_PROP_R          unknown             ~4      'instance'
          7      > RETURN                                                   ~4
   17     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/ss2mX
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                                  '%00%7Bclosure%7D%2Fin%2Fss2mX%3A28%240'
          1        ASSIGN_OBJ                                               '_caller'
   30     2        OP_DATA                                                  ~1
   31     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/ss2mX
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      
   34     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
   35    13*     > RETURN                                                   null

End of function callprivatemethod

End of class PrivacyViolator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.59 ms | 1403 KiB | 13 Q