3v4l.org

run code in 300+ PHP versions simultaneously
<?php class hell { private $ruler = 'devil'; function cry(){ echo $this->ruler; } } $inst = new hell(); $inst->cry(); $in2 = Closure::bind(function () {$this->ruler = 'jesus';}, $inst, get_class($inst)); $in2(); $inst->cry(); class Singleton { protected static $instance; // object instance private function __construct(){ /* ... @return Singleton */ } // Защищаем от создания через new Singleton private function __clone() { /* ... @return Singleton */ } // Защищаем от создания через клонирование private function __wakeup() { /* ... @return Singleton */ } // Защищаем от создания через unserialize public static function getInstance() { // Возвращает единственный экземпляр класса. @return Singleton if ( !isset(self::$instance) ) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; } public function doAction() { echo 'sing'; } } Singleton::getInstance()->doAction(); // Применение
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naec
function name:  (null)
number of ops:  22
compiled vars:  !0 = $inst, !1 = $in2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $2      'hell'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   13     3        INIT_METHOD_CALL                                         !0, 'cry'
          4        DO_FCALL                                      0          
   15     5        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F4Naec%3A15%240'
          7        SEND_VAL                                                 ~6
          8        SEND_VAR                                                 !0
          9        GET_CLASS                                        ~7      !0
         10        SEND_VAL                                                 ~7
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !1, $8
   16    13        INIT_DYNAMIC_CALL                                        !1
         14        DO_FCALL                                      0          
   17    15        INIT_METHOD_CALL                                         !0, 'cry'
         16        DO_FCALL                                      0          
   33    17        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
         18        DO_FCALL                                      0  $12     
         19        INIT_METHOD_CALL                                         $12, 'doAction'
         20        DO_FCALL                                      0          
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F4Naec%3A15%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naec
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_THIS                                       $0      
          1        ASSIGN_OBJ                                               $0, 'ruler'
          2        OP_DATA                                                  'jesus'
          3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F4Naec%3A15%240

Class hell:
Function cry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naec
function name:  cry
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                      ~0      'ruler'
          1        ECHO                                                     ~0
    8     2      > RETURN                                                   null

End of function cry

End of class hell.

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naec
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     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/4Naec
function name:  __clone
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     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/4Naec
function name:  __wakeup
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     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 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/4Naec
function name:  getInstance
number of ops:  12
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ISSET_ISEMPTY_STATIC_PROP                        ~1      'instance'
          1        BOOL_NOT                                         ~2      ~1
          2      > JMPZ                                                     ~2, ->9
   26     3    >   ASSIGN                                                   !0, 'Singleton'
   27     4        FETCH_CLASS                                   0  $5      !0
          5        NEW                                              $6      $5
          6        DO_FCALL                                      0          
          7        ASSIGN_STATIC_PROP                                       'instance'
          8        OP_DATA                                                  $6
   29     9    >   FETCH_STATIC_PROP_R          unknown             ~8      'instance'
         10      > RETURN                                                   ~8
   30    11*     > RETURN                                                   null

End of function getinstance

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

End of function doaction

End of class Singleton.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.06 ms | 1399 KiB | 13 Q