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) { echo $this; return call_user_func_array([$this, $method], $args); }; } function callPrivateMethod($object, $method, $args) { return $this->_caller->bindTo($object, $object)->__invoke($method, $args); } } $privacyViolator1 = new PrivacyViolator(); $privacyViolator1->callPrivateMethod($Object1, '__construct', []); echo $Object1 == $privacyViolator1 ? '+' : '-'; echo $Object1 === $privacyViolator1 ? '+' : '-';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
Branch analysis from position: 21
filename:       /in/ffI8A
function name:  (null)
number of ops:  24
compiled vars:  !0 = $Object1, !1 = $privacyViolator1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   39     3        NEW                                              $4      'PrivacyViolator'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
   40     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          
   42    11        IS_EQUAL                                                 !0, !1
         12      > JMPZ                                                     ~8, ->15
         13    >   QM_ASSIGN                                        ~9      '%2B'
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~9      '-'
         16    >   ECHO                                                     ~9
   43    17        IS_IDENTICAL                                             !0, !1
         18      > JMPZ                                                     ~10, ->21
         19    >   QM_ASSIGN                                        ~11     '%2B'
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~11     '-'
         22    >   ECHO                                                     ~11
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FffI8A%3A28%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ffI8A
function name:  {closure}
number of ops:  13
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        ECHO                                                     ~2
   30     4        FETCH_THIS                                       ~3      
          5        INIT_ARRAY                                       ~4      ~3
          6        ADD_ARRAY_ELEMENT                                ~4      !0
          7        INIT_USER_CALL                                0          'call_user_func_array', ~4
          8        SEND_ARRAY                                               !1
          9        CHECK_UNDEF_ARGS                                         
         10        DO_FCALL                                      0  $5      
         11      > RETURN                                                   $5
   31    12*     > RETURN                                                   null

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

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ffI8A
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/ffI8A
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/ffI8A
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/ffI8A
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/ffI8A
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%2FffI8A%3A28%240'
          1        ASSIGN_OBJ                                               '_caller'
   31     2        OP_DATA                                                  ~1
   32     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/ffI8A
function name:  callPrivateMethod
number of ops:  14
compiled vars:  !0 = $object, !1 = $method, !2 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     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  $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
   36    13*     > RETURN                                                   null

End of function callprivatemethod

End of class PrivacyViolator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.38 ms | 1407 KiB | 13 Q