3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Zend_Registry extends ArrayObject { /** * Class name of the singleton registry object. * @var string */ private static $_registryClassName = 'Zend_Registry'; /** * Registry object provides storage for shared objects. * @var Zend_Registry */ private static $_registry = null; /** * Retrieves the default registry instance. * * @return Zend_Registry */ public static function getInstance() { if (self::$_registry === null) { self::init(); } return self::$_registry; } /** * Set the default registry instance to a specified instance. * * @param Zend_Registry $registry An object instance of type Zend_Registry, * or a subclass. * @return void * @throws Zend_Exception if registry is already initialized. */ public static function setInstance(Zend_Registry $registry) { if (self::$_registry !== null) { require_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } self::setClassName(get_class($registry)); self::$_registry = $registry; } /** * Initialize the default registry instance. * * @return void */ protected static function init() { self::setInstance(new self::$_registryClassName()); } /** * Set the class name to use for the default registry instance. * Does not affect the currently initialized instance, it only applies * for the next time you instantiate. * * @param string $registryClassName * @return void * @throws Zend_Exception if the registry is initialized or if the * class name is not valid. */ public static function setClassName($registryClassName = 'Zend_Registry') { if (self::$_registry !== null) { require_once 'Zend/Exception.php'; throw new Zend_Exception('Registry is already initialized'); } if (!is_string($registryClassName)) { require_once 'Zend/Exception.php'; throw new Zend_Exception("Argument is not a class name"); } /** * @see Zend_Loader */ if (!class_exists($registryClassName)) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass($registryClassName); } self::$_registryClassName = $registryClassName; } /** * Unset the default registry instance. * Primarily used in tearDown() in unit tests. * @returns void */ public static function _unsetInstance() { self::$_registry = null; } /** * getter method, basically same as offsetGet(). * * This method can be called from an object of type Zend_Registry, or it * can be called statically. In the latter case, it uses the default * static instance stored in the class. * * @param string $index - get the value associated with $index * @return mixed * @throws Zend_Exception if no entry is registerd for $index. */ public static function get($index) { $instance = self::getInstance(); if (!$instance->offsetExists($index)) { require_once 'Zend/Exception.php'; throw new Zend_Exception("No entry is registered for key '$index'"); } return $instance->offsetGet($index); } /** * setter method, basically same as offsetSet(). * * This method can be called from an object of type Zend_Registry, or it * can be called statically. In the latter case, it uses the default * static instance stored in the class. * * @param string $index The location in the ArrayObject in which to store * the value. * @param mixed $value The object to store in the ArrayObject. * @return void */ public static function set($index, $value) { $instance = self::getInstance(); $instance->offsetSet($index, $value); } /** * Returns TRUE if the $index is a named value in the registry, * or FALSE if $index was not found in the registry. * * @param string $index * @return boolean */ public static function isRegistered($index) { if (self::$_registry === null) { return false; } return self::$_registry->offsetExists($index); } /** * Constructs a parent ArrayObject with default * ARRAY_AS_PROPS to allow acces as an object * * @param array $array data array * @param integer $flags ArrayObject flags */ public function __construct($array = array(), $flags = parent::ARRAY_AS_PROPS) { parent::__construct($array, $flags); } /** * @param string $index * @returns mixed * * Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960). */ public function offsetExists($index) { return array_key_exists($index, $this); } } $registry = Zend_Registry::getInstance(); $registry['null'] = null; var_dump(isset($registry['null'])); var_dump(Zend_Registry::isRegistered('null'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  (null)
number of ops:  16
compiled vars:  !0 = $registry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  185     0  E >   INIT_STATIC_METHOD_CALL                                  'Zend_Registry', 'getInstance'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
  186     3        ASSIGN_DIM                                               !0, 'null'
          4        OP_DATA                                                  null
  187     5        INIT_FCALL                                               'var_dump'
          6        ISSET_ISEMPTY_DIM_OBJ                         0  ~4      !0, 'null'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
  188     9        INIT_FCALL                                               'var_dump'
         10        INIT_STATIC_METHOD_CALL                                  'Zend_Registry', 'isRegistered'
         11        SEND_VAL                                                 'null'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class Zend_Registry:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/0LFWo
function name:  getInstance
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      '_registry'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->5
   24     3    >   INIT_STATIC_METHOD_CALL                                  'init'
          4        DO_FCALL                                      0          
   27     5    >   FETCH_STATIC_PROP_R          unknown             ~3      '_registry'
          6      > RETURN                                                   ~3
   28     7*     > RETURN                                                   null

End of function getinstance

Function setinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  setInstance
number of ops:  16
compiled vars:  !0 = $registry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   40     1        FETCH_STATIC_PROP_R          global lock         ~1      '_registry'
          2        TYPE_CHECK                                  1020          ~1
          3      > JMPZ                                                     ~2, ->9
   41     4    >   INCLUDE_OR_EVAL                                          'Zend%2FException.php', REQUIRE_ONCE
   42     5        NEW                                              $4      'Zend_Exception'
          6        SEND_VAL_EX                                              'Registry+is+already+initialized'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $4
   45     9    >   INIT_STATIC_METHOD_CALL                                  'setClassName'
         10        GET_CLASS                                        ~6      !0
         11        SEND_VAL_EX                                              ~6
         12        DO_FCALL                                      0          
   46    13        ASSIGN_STATIC_PROP                                       '_registry'
         14        OP_DATA                                                  !0
   47    15      > RETURN                                                   null

End of function setinstance

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  init
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   INIT_STATIC_METHOD_CALL                                  'setInstance'
          1        FETCH_STATIC_PROP_R          unknown             ~0      '_registryClassName'
          2        FETCH_CLASS                                   0  $1      ~0
          3        NEW                                              $2      $1
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $2
          6        DO_FCALL                                      0          
   57     7      > RETURN                                                   null

End of function init

Function setclassname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/0LFWo
function name:  setClassName
number of ops:  29
compiled vars:  !0 = $registryClassName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV_INIT                                        !0      'Zend_Registry'
   71     1        FETCH_STATIC_PROP_R          unknown             ~1      '_registry'
          2        TYPE_CHECK                                  1020          ~1
          3      > JMPZ                                                     ~2, ->9
   72     4    >   INCLUDE_OR_EVAL                                          'Zend%2FException.php', REQUIRE_ONCE
   73     5        NEW                                              $4      'Zend_Exception'
          6        SEND_VAL_EX                                              'Registry+is+already+initialized'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $4
   76     9    >   TYPE_CHECK                                   64  ~6      !0
         10        BOOL_NOT                                         ~7      ~6
         11      > JMPZ                                                     ~7, ->17
   77    12    >   INCLUDE_OR_EVAL                                          'Zend%2FException.php', REQUIRE_ONCE
   78    13        NEW                                              $9      'Zend_Exception'
         14        SEND_VAL_EX                                              'Argument+is+not+a+class+name'
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $9
   84    17    >   INIT_FCALL                                               'class_exists'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $11     
         20        BOOL_NOT                                         ~12     $11
         21      > JMPZ                                                     ~12, ->26
   85    22    >   INCLUDE_OR_EVAL                                          'Zend%2FLoader.php', REQUIRE_ONCE
   86    23        INIT_STATIC_METHOD_CALL                                  'Zend_Loader', 'loadClass'
         24        SEND_VAR_EX                                              !0
         25        DO_FCALL                                      0          
   89    26    >   ASSIGN_STATIC_PROP                                       '_registryClassName'
         27        OP_DATA                                                  !0
   90    28      > RETURN                                                   null

End of function setclassname

Function _unsetinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  _unsetInstance
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   ASSIGN_STATIC_PROP                                       '_registry'
          1        OP_DATA                                                  null
  100     2      > RETURN                                                   null

End of function _unsetinstance

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  get
number of ops:  22
compiled vars:  !0 = $index, !1 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  113     0  E >   RECV                                             !0      
  115     1        INIT_STATIC_METHOD_CALL                                  'getInstance'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !1, $2
  117     4        INIT_METHOD_CALL                                         !1, 'offsetExists'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $4      
          7        BOOL_NOT                                         ~5      $4
          8      > JMPZ                                                     ~5, ->17
  118     9    >   INCLUDE_OR_EVAL                                          'Zend%2FException.php', REQUIRE_ONCE
  119    10        NEW                                              $7      'Zend_Exception'
         11        ROPE_INIT                                     3  ~9      'No+entry+is+registered+for+key+%27'
         12        ROPE_ADD                                      1  ~9      ~9, !0
         13        ROPE_END                                      2  ~8      ~9, '%27'
         14        SEND_VAL_EX                                              ~8
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $7
  122    17    >   INIT_METHOD_CALL                                         !1, 'offsetGet'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0  $12     
         20      > RETURN                                                   $12
  123    21*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  set
number of ops:  10
compiled vars:  !0 = $index, !1 = $value, !2 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  137     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  139     2        INIT_STATIC_METHOD_CALL                                  'getInstance'
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !2, $3
  140     5        INIT_METHOD_CALL                                         !2, 'offsetSet'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
  141     9      > RETURN                                                   null

End of function set

Function isregistered:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  isRegistered
number of ops:  11
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  150     0  E >   RECV                                             !0      
  152     1        FETCH_STATIC_PROP_R          unknown             ~1      '_registry'
          2        TYPE_CHECK                                    2          ~1
          3      > JMPZ                                                     ~2, ->5
  153     4    > > RETURN                                                   <false>
  155     5    >   FETCH_STATIC_PROP_R          unknown             ~3      '_registry'
          6        INIT_METHOD_CALL                                         ~3, 'offsetExists'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $4      
          9      > RETURN                                                   $4
  156    10*     > RETURN                                                   null

End of function isregistered

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  __construct
number of ops:  7
compiled vars:  !0 = $array, !1 = $flags
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  165     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      <const ast>
  167     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
  168     6      > RETURN                                                   null

End of function __construct

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0LFWo
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  176     0  E >   RECV                                             !0      
  178     1        FETCH_THIS                                       ~1      
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
  179     4*     > RETURN                                                   null

End of function offsetexists

End of class Zend_Registry.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.55 ms | 1404 KiB | 17 Q