diff -u b/core/lib/Drupal/Component/Utility/StaticStorage.php b/core/lib/Drupal/Component/Utility/StaticStorage.php --- b/core/lib/Drupal/Component/Utility/StaticStorage.php +++ b/core/lib/Drupal/Component/Utility/StaticStorage.php @@ -11,16 +11,16 @@ * Provides central static variable storage. * * All functions requiring a static variable to persist or cache data within - * a single page request are encouraged to use this function unless it is + * a single page request are encouraged to use this class unless it is * absolutely certain that the static variable will not need to be reset during * the page request. By centralizing static variable storage through this - * function, other functions can rely on a consistent API for resetting any + * class, other functions can rely on a consistent API for resetting any * other function's static variables. * * Example: * @code * function example_list($field = 'default') { - * $examples = &drupal_static(__FUNCTION__); + * $examples = &StaticStorage::get(__FUNCTION__); * if (!isset($examples)) { * // If this function is being called for the first time after a reset, * // query the database and execute any other code needed to retrieve @@ -41,7 +41,7 @@ * function examples_admin_overview() { * // When building the content for the overview page, make sure to get * // completely fresh information. - * drupal_static_reset('example_list'); + * StaticStorage::reset('example_list'); * ... * } * @endcode @@ -52,7 +52,7 @@ * which it will be used. A guideline is that if a function's static variable * does not depend on any information outside of the function that might change * during a single page request, then it's ok to use the "static" keyword - * instead of the drupal_static() function. + * instead of calling StaticStorage::get(). * * Example: * @code @@ -69,20 +69,21 @@ * function is called many times (100+) during a single page request, so * every microsecond of execution time that can be removed from the function * counts. These functions can use a more cumbersome, but faster variant of - * calling drupal_static(). It works by storing the reference returned by - * drupal_static() in the calling function's own static variable, thereby - * removing the need to call drupal_static() for each iteration of the function. + * calling StaticStorage::get(). It works by storing the reference returned by + * StaticStorage::get() in the calling function's own static variable, thereby + * removing the need to call StaticStorage::get() for each iteration of the + * function. * Conceptually, it replaces: * @code - * $foo = &drupal_static(__FUNCTION__); + * $foo = &StaticStorage::get(__FUNCTION__); * @endcode * with: * @code * // Unfortunately, this does not work. - * static $foo = &drupal_static(__FUNCTION__); + * static $foo = &StaticStorage::get(__FUNCTION__); * @endcode * However, the above line of code does not work, because PHP only allows static - * variables to be initializied by literal values, and does not allow static + * variables to be initialized by literal values, and does not allow static * variables to be assigned to references. * - http://php.net/manual/language.variables.scope.php#language.variables.scope.static * - http://php.net/manual/language.variables.scope.php#language.variables.scope.references @@ -92,12 +93,12 @@ * Example: * @code * function user_access($string, $account = NULL) { - * // Use the advanced drupal_static() pattern, since this is called very often. - * static $drupal_static_fast; - * if (!isset($drupal_static_fast)) { - * $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__); + * // Use the advanced StaticStorage::get() pattern, since this is called very often. + * static $static_storage_fast; + * if (!isset($static_storage_fast)) { + * $static_storage_fast['perm'] = &StaticStorage::get(__FUNCTION__); * } - * $perm = &$drupal_static_fast['perm']; + * $perm = &$static_storage_fast['perm']; * ... * } * @endcode @@ -164,8 +165,8 @@ public static function reset($name = NULL) { if (!isset($name)) { // Reset all: ($name == NULL). This needs to be done one at a time so that - // references returned by earlier invocations of drupal_static() also get - // reset. + // references returned by earlier invocations of StaticStorage::get() also + // get reset. foreach (static::$default as $name => $value) { static::$data[$name] = $value; }