From a5313d6a54e73b67abb29709c135ca2776cc08b0 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Thu, 11 Oct 2012 11:14:07 +0100
Subject: [PATCH] Issue #1808112 by sun: Fixed Missing method visibility, bogus
 phpDoc and coding style in Cache backend classes.

---
 .../Core/Cache/CacheBackendInterface.php      | 26 ++++++++---------
 .../lib/Drupal/Core/Cache/DatabaseBackend.php | 28 +++++++++----------
 core/lib/Drupal/Core/Cache/InstallBackend.php | 20 ++++++-------
 core/lib/Drupal/Core/Cache/MemoryBackend.php  | 11 ++++----
 core/lib/Drupal/Core/Cache/NullBackend.php    | 20 ++++++-------
 .../Tests/Cache/MemoryBackendUnitTest.php     |  2 +-
 6 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
index 02c9dd22e2fc..9c4f8fcbf794 100644
--- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
@@ -38,8 +38,8 @@
  * To access your custom cache bin, specify the name of the bin when storing
  * or retrieving cached data:
  * @code
- *  cache_set($cid, $data, 'custom_bin', $expire);
- *  cache_get($cid, 'custom_bin');
+ *  cache('custom_bin')->set($cid, $data, $expire);
+ *  cache('custom_bin')->get($cid);
  * @endcode
  *
  * @see cache()
@@ -60,7 +60,7 @@ interface CacheBackendInterface {
    * @param $bin
    *   The cache bin for which the object is created.
    */
-  function __construct($bin);
+  public function __construct($bin);
 
   /**
    * Returns data from the persistent cache.
@@ -74,7 +74,7 @@ function __construct($bin);
    * @return
    *   The cache or FALSE on failure.
    */
-  function get($cid);
+  public function get($cid);
 
   /**
    * Returns data from the persistent cache when given an array of cache IDs.
@@ -87,7 +87,7 @@ function get($cid);
    * @return
    *   An array of the items successfully returned from cache indexed by cid.
    */
-  function getMultiple(&$cids);
+  public function getMultiple(&$cids);
 
   /**
    * Stores data in the persistent cache.
@@ -111,7 +111,7 @@ function getMultiple(&$cids);
    *   a node, both the node ID and the author's user ID might be passed in as
    *   tags. For example array('node' => array(123), 'user' => array(92)).
    */
-  function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array());
+  public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array());
 
   /**
    * Deletes an item from the cache.
@@ -119,7 +119,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
    * @param $cid
    *    The cache ID to delete.
    */
-  function delete($cid);
+  public function delete($cid);
 
   /**
    * Deletes multiple items from the cache.
@@ -127,17 +127,17 @@ function delete($cid);
    * @param $cids
    *   An array of $cids to delete.
    */
-  function deleteMultiple(Array $cids);
+  public function deleteMultiple(Array $cids);
 
   /**
    * Flushes all cache items in a bin.
    */
-  function flush();
+  public function flush();
 
   /**
    * Expires temporary items from the cache.
    */
-  function expire();
+  public function expire();
 
   /**
    * Invalidates each tag in the $tags array.
@@ -148,12 +148,12 @@ function expire();
    *
    * @see CacheBackendInterface::set()
    */
-  function invalidateTags(array $tags);
+  public function invalidateTags(array $tags);
 
   /**
    * Performs garbage collection on a cache bin.
    */
-  function garbageCollection();
+  public function garbageCollection();
 
   /**
    * Checks if a cache bin is empty.
@@ -164,5 +164,5 @@ function garbageCollection();
    * @return
    *   TRUE if the cache bin specified is empty.
    */
-  function isEmpty();
+  public function isEmpty();
 }
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index e62f1da833d5..9ab6b1161f0d 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -31,7 +31,7 @@ class DatabaseBackend implements CacheBackendInterface {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::__construct().
    */
-  function __construct($bin) {
+  public function __construct($bin) {
     // All cache tables should be prefixed with 'cache_', except for the
     // default 'cache' bin.
     if ($bin != 'cache') {
@@ -43,7 +43,7 @@ function __construct($bin) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::get().
    */
-  function get($cid) {
+  public function get($cid) {
     $cids = array($cid);
     $cache = $this->getMultiple($cids);
     return reset($cache);
@@ -52,7 +52,7 @@ function get($cid) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
    */
-  function getMultiple(&$cids) {
+  public function getMultiple(&$cids) {
     try {
       // When serving cached pages, the overhead of using ::select() was found
       // to add around 30% overhead to the request. Since $this->bin is a
@@ -93,8 +93,6 @@ function getMultiple(&$cids) {
    *   valid item to load.
    */
   protected function prepareItem($cache) {
-    global $user;
-
     if (!isset($cache->data)) {
       return FALSE;
     }
@@ -118,7 +116,7 @@ protected function prepareItem($cache) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::set().
    */
-  function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
+  public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
     $fields = array(
       'serialized' => 0,
       'created' => REQUEST_TIME,
@@ -149,7 +147,7 @@ function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, arra
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
-  function delete($cid) {
+  public function delete($cid) {
     Database::getConnection()->delete($this->bin)
       ->condition('cid', $cid)
       ->execute();
@@ -158,7 +156,7 @@ function delete($cid) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
    */
-  function deleteMultiple(array $cids) {
+  public function deleteMultiple(array $cids) {
     // Delete in chunks when a large array is passed.
     do {
       Database::getConnection()->delete($this->bin)
@@ -171,14 +169,14 @@ function deleteMultiple(array $cids) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::flush().
    */
-  function flush() {
+  public function flush() {
     Database::getConnection()->truncate($this->bin)->execute();
   }
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::expire().
    */
-  function expire() {
+  public function expire() {
     Database::getConnection()->delete($this->bin)
       ->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>')
       ->condition('expire', REQUEST_TIME, '<')
@@ -188,7 +186,7 @@ function expire() {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
    */
-  function garbageCollection() {
+  public function garbageCollection() {
     $this->expire();
   }
 
@@ -196,9 +194,9 @@ function garbageCollection() {
    * Compares two checksums of tags. Used to determine whether to serve a cached
    * item or treat it as invalidated.
    *
-   * @param integer @checksum
+   * @param integer $checksum
    *   The initial checksum to compare against.
-   * @param array @tags
+   * @param array $tags
    *   An array of tags to calculate a checksum for.
    *
    * @return boolean
@@ -214,7 +212,7 @@ protected function validTags($checksum, array $tags) {
    * @param array $tags
    *   Associative array of tags to flatten.
    *
-   * @return
+   * @return array
    *   Numeric array of flattened tag identifiers.
    */
   protected function flattenTags(array $tags) {
@@ -288,7 +286,7 @@ protected function checksumTags($tags) {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::isEmpty().
    */
-  function isEmpty() {
+  public function isEmpty() {
     $this->garbageCollection();
     $query = Database::getConnection()->select($this->bin);
     $query->addExpression('1');
diff --git a/core/lib/Drupal/Core/Cache/InstallBackend.php b/core/lib/Drupal/Core/Cache/InstallBackend.php
index 73aae39ae476..e23294aeaea3 100644
--- a/core/lib/Drupal/Core/Cache/InstallBackend.php
+++ b/core/lib/Drupal/Core/Cache/InstallBackend.php
@@ -36,26 +36,26 @@ class InstallBackend extends DatabaseBackend {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::get().
    */
-  function get($cid) {
+  public function get($cid) {
     return FALSE;
   }
 
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::getMultiple().
    */
-  function getMultiple(&$cids) {
+  public function getMultiple(&$cids) {
     return array();
   }
 
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::set().
    */
-  function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
+  public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
 
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::delete().
    */
-  function delete($cid) {
+  public function delete($cid) {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::delete($cid);
@@ -67,7 +67,7 @@ function delete($cid) {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::deleteMultiple().
    */
-  function deleteMultiple(array $cids) {
+  public function deleteMultiple(array $cids) {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::deleteMultiple($cids);
@@ -79,7 +79,7 @@ function deleteMultiple(array $cids) {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::invalidateTags().
    */
-  function invalidateTags(array $tags) {
+  public function invalidateTags(array $tags) {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::invalidateTags($tags);
@@ -91,7 +91,7 @@ function invalidateTags(array $tags) {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::flush().
    */
-  function flush() {
+  public function flush() {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::flush();
@@ -103,7 +103,7 @@ function flush() {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::expire().
    */
-  function expire() {
+  public function expire() {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::expire();
@@ -115,7 +115,7 @@ function expire() {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::garbageCollection().
    */
-  function garbageCollection() {
+  public function garbageCollection() {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         parent::garbageCollection();
@@ -127,7 +127,7 @@ function garbageCollection() {
   /**
    * Overrides Drupal\Core\Cache\DatabaseBackend::isEmpty().
    */
-  function isEmpty() {
+  public function isEmpty() {
     try {
       if (class_exists('Drupal\Core\Database\Database')) {
         return parent::isEmpty();
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php
index ce74c2f76ddd..b17e06b7451f 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php
@@ -105,13 +105,13 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN
     );
   }
 
-  /*
+  /**
    * Calculates a checksum so data can be invalidated using tags.
    */
-  function checksum($tags) {
-    $checksum = "";
+  public function checksum($tags) {
+    $checksum = '';
 
-    foreach($tags as $tag) {
+    foreach ($tags as $tag) {
       // Has the tag already been invalidated.
       if (isset($this->invalidatedTags[$tag])) {
         $checksum = $checksum . $tag . ':' . $this->invalidatedTags[$tag];
@@ -201,8 +201,7 @@ protected function flattenTags(array $tags) {
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
    */
   public function invalidateTags(array $tags) {
-    $flat_tags = $this->flattenTags($tags);
-    foreach($flat_tags as $tag) {
+    foreach ($this->flattenTags($tags) as $tag) {
       if (isset($this->invalidatedTags[$tag])) {
         $this->invalidatedTags[$tag] = $this->invalidatedTags[$tag] + 1;
       }
diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php
index 862a3bd6dee1..ee8b1d3fd3c3 100644
--- a/core/lib/Drupal/Core/Cache/NullBackend.php
+++ b/core/lib/Drupal/Core/Cache/NullBackend.php
@@ -23,51 +23,51 @@ class NullBackend implements CacheBackendInterface {
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::__construct().
    */
-  function __construct($bin) {}
+  public function __construct($bin) {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::get().
    */
-  function get($cid) {
+  public function get($cid) {
     return FALSE;
   }
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::getMultiple().
    */
-  function getMultiple(&$cids) {
+  public function getMultiple(&$cids) {
     return array();
   }
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::set().
    */
-  function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
+  public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
    */
-  function delete($cid) {}
+  public function delete($cid) {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().
    */
-  function deleteMultiple(array $cids) {}
+  public function deleteMultiple(array $cids) {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::flush().
    */
-  function flush() {}
+  public function flush() {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::expire().
    */
-  function expire() {}
+  public function expire() {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
    */
-  function garbageCollection() {}
+  public function garbageCollection() {}
 
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
@@ -77,7 +77,7 @@ public function invalidateTags(array $tags) {}
   /**
    * Implements Drupal\Core\Cache\CacheBackendInterface::isEmpty().
    */
-  function isEmpty() {
+  public function isEmpty() {
     return TRUE;
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/MemoryBackendUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/MemoryBackendUnitTest.php
index 843eb23b957b..499ddaf3a5ed 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/MemoryBackendUnitTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/MemoryBackendUnitTest.php
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * Definition of Drupal\system\Tests\Cache\ArrayBackendUnitTest.
+ * Definition of Drupal\system\Tests\Cache\MemoryBackendUnitTest.
  */
 
 namespace Drupal\system\Tests\Cache;
-- 
GitLab