From f66e91566af20a66c4a672e44000c4922154b439 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Thu, 14 Jun 2018 23:08:07 +0200
Subject: [PATCH] [TASK] Streamline imports in PHP cache classes

Most Cache classes haven't been streamlined since their inception,
some unnecessary imports.

The patch organizes the files so their are all imported the same way.

Resolves: #85261
Releases: master
Change-Id: I814bb88562711ccdf509262b7846ceb625674fe1
Reviewed-on: https://review.typo3.org/57219
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 .../core/Classes/Cache/Backend/ApcBackend.php | 32 +++++++-------
 .../Classes/Cache/Backend/ApcuBackend.php     | 30 ++++++-------
 .../Cache/Backend/BackendInterface.php        |  6 ++-
 .../Classes/Cache/Backend/FileBackend.php     | 23 +++++-----
 .../Backend/FreezableBackendInterface.php     |  2 +-
 .../Classes/Cache/Backend/NullBackend.php     |  2 +-
 .../core/Classes/Cache/Backend/PdoBackend.php | 31 ++++++++------
 .../Backend/PhpCapableBackendInterface.php    |  2 +-
 .../Classes/Cache/Backend/RedisBackend.php    | 16 +++----
 .../Cache/Backend/SimpleFileBackend.php       | 42 ++++++++++---------
 .../Backend/TaggableBackendInterface.php      |  2 +-
 .../Cache/Backend/TransientMemoryBackend.php  | 12 +++---
 .../Classes/Cache/Backend/WincacheBackend.php | 28 +++++++------
 13 files changed, 129 insertions(+), 99 deletions(-)

diff --git a/typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php b/typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php
index ea77c6851461..d8a82bb1f29b 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php
@@ -14,7 +14,11 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\Environment;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * A caching backend which stores cache entries by using APC.
@@ -72,15 +76,15 @@ class ApcBackend extends AbstractBackend implements TaggableBackendInterface
      *
      * @param string $context Unused, for backward compatibility only
      * @param array $options Configuration options - unused here
-     * @throws \TYPO3\CMS\Core\Cache\Exception
+     * @throws Exception
      */
     public function __construct($context, array $options = [])
     {
         if (!extension_loaded('apc')) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The PHP extension "apc" or "apcu" must be installed and loaded in order to use the APC backend.', 1232985414);
+            throw new Exception('The PHP extension "apc" or "apcu" must be installed and loaded in order to use the APC backend.', 1232985414);
         }
         if (PHP_SAPI === 'cli' && ini_get('apc.enable_cli') == 0) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The APC backend cannot be used because apc is disabled on CLI.', 1232985415);
+            throw new Exception('The APC backend cannot be used because apc is disabled on CLI.', 1232985415);
         }
         parent::__construct($context, $options);
     }
@@ -88,13 +92,13 @@ class ApcBackend extends AbstractBackend implements TaggableBackendInterface
     /**
      * Initializes the identifier prefix when setting the cache.
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache
+     * @param FrontendInterface $cache
      */
-    public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
+    public function setCache(FrontendInterface $cache)
     {
         parent::setCache($cache);
         $processUser = $this->getCurrentUserData();
-        $pathHash = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(Environment::getProjectPath() . $processUser['name'] . $this->context . $cache->getIdentifier(), 12);
+        $pathHash = GeneralUtility::shortMD5(Environment::getProjectPath() . $processUser['name'] . $this->context . $cache->getIdentifier(), 12);
         $this->setIdentifierPrefix('TYPO3_' . $pathHash);
     }
 
@@ -116,17 +120,17 @@ class ApcBackend extends AbstractBackend implements TaggableBackendInterface
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
-     * @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set.
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if $data is not a string
+     * @throws Exception if no cache frontend has been set.
+     * @throws InvalidDataException if $data is not a string
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('No cache frontend has been set yet via setCache().', 1232986818);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('No cache frontend has been set yet via setCache().', 1232986818);
         }
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1232986825);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1232986825);
         }
         $tags[] = '%APCBE%' . $this->cacheIdentifier;
         $expiration = $lifetime ?? $this->defaultLifetime;
@@ -217,13 +221,13 @@ class ApcBackend extends AbstractBackend implements TaggableBackendInterface
     /**
      * Removes all cache entries of this cache.
      *
-     * @throws \TYPO3\CMS\Core\Cache\Exception
+     * @throws Exception
      * @api
      */
     public function flush()
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('Yet no cache frontend has been set via setCache().', 1232986971);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('Yet no cache frontend has been set via setCache().', 1232986971);
         }
         $this->flushByTag('%APCBE%' . $this->cacheIdentifier);
     }
diff --git a/typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php b/typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php
index a0076ab0f21f..2ada163c2943 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php
@@ -14,7 +14,9 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Cache;
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -74,15 +76,15 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
      *
      * @param string $context Unused, for backward compatibility only
      * @param array $options Configuration options - unused here
-     * @throws Cache\Exception
+     * @throws Exception
      */
     public function __construct($context, array $options = [])
     {
         if (!extension_loaded('apcu')) {
-            throw new Cache\Exception('The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.', 1232985914);
+            throw new Exception('The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.', 1232985914);
         }
         if (PHP_SAPI === 'cli' && ini_get('apc.enable_cli') == 0) {
-            throw new Cache\Exception('The APCu backend cannot be used because apcu is disabled on CLI.', 1232985915);
+            throw new Exception('The APCu backend cannot be used because apcu is disabled on CLI.', 1232985915);
         }
         parent::__construct($context, $options);
     }
@@ -90,9 +92,9 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
     /**
      * Initializes the identifier prefix when setting the cache.
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache
+     * @param FrontendInterface $cache
      */
-    public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
+    public function setCache(FrontendInterface $cache)
     {
         parent::setCache($cache);
         $processUser = $this->getCurrentUserData();
@@ -118,17 +120,17 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
-     * @throws Cache\Exception if no cache frontend has been set.
-     * @throws Cache\Exception\InvalidDataException if $data is not a string
+     * @throws Exception if no cache frontend has been set.
+     * @throws InvalidDataException if $data is not a string
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
-        if (!$this->cache instanceof Cache\Frontend\FrontendInterface) {
-            throw new Cache\Exception('No cache frontend has been set yet via setCache().', 1232986118);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('No cache frontend has been set yet via setCache().', 1232986118);
         }
         if (!is_string($data)) {
-            throw new Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1232986125);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1232986125);
         }
         $tags[] = '%APCBE%' . $this->cacheIdentifier;
         $expiration = $lifetime ?? $this->defaultLifetime;
@@ -219,13 +221,13 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
     /**
      * Removes all cache entries of this cache.
      *
-     * @throws Cache\Exception
+     * @throws Exception
      * @api
      */
     public function flush()
     {
-        if (!$this->cache instanceof Cache\Frontend\FrontendInterface) {
-            throw new Cache\Exception('Yet no cache frontend has been set via setCache().', 1232986571);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('Yet no cache frontend has been set via setCache().', 1232986571);
         }
         $this->flushByTag('%APCBE%' . $this->cacheIdentifier);
     }
diff --git a/typo3/sysext/core/Classes/Cache/Backend/BackendInterface.php b/typo3/sysext/core/Classes/Cache/Backend/BackendInterface.php
index 815d9cfd2039..0e1bf1aca616 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/BackendInterface.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/BackendInterface.php
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache;
+
 /**
  * A contract for a Cache Backend
  * @api
@@ -23,10 +25,10 @@ interface BackendInterface
     /**
      * Sets a reference to the cache frontend which uses this backend
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The frontend for this backend
+     * @param Cache\Frontend\FrontendInterface $cache The frontend for this backend
      * @api
      */
-    public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache);
+    public function setCache(Cache\Frontend\FrontendInterface $cache);
 
     /**
      * Saves data in the cache.
diff --git a/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php b/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php
index 3118a1395cdf..3adc246fa94d 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/FileBackend.php
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -24,7 +27,7 @@ use TYPO3\CMS\Core\Utility\StringUtility;
  *
  * @api
  */
-class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implements \TYPO3\CMS\Core\Cache\Backend\FreezableBackendInterface, \TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface
+class FileBackend extends SimpleFileBackend implements FreezableBackendInterface, TaggableBackendInterface
 {
     const SEPARATOR = '^';
     const EXPIRYTIME_FORMAT = 'YmdHis';
@@ -98,9 +101,9 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
      * This method also detects if this backend is frozen and sets the internal
      * flag accordingly.
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The cache frontend
+     * @param FrontendInterface $cache The cache frontend
      */
-    public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
+    public function setCache(FrontendInterface $cache)
     {
         parent::setCache($cache);
         if (file_exists($this->cacheDirectory . 'FrozenCache.data')) {
@@ -117,15 +120,15 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
      * @throws \RuntimeException
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
-     * @throws \TYPO3\CMS\Core\Cache\Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
+     * @throws InvalidDataException if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
+     * @throws Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
      * @throws \InvalidArgumentException
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1204481674);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1204481674);
         }
         if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
             throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
@@ -142,9 +145,9 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
         $expiryTime = $lifetime === 0 ? 0 : $GLOBALS['EXEC_TIME'] + $lifetime;
         $metaData = str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . implode(' ', $tags) . str_pad(strlen($data), self::DATASIZE_DIGITS);
         $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data . $metaData);
-        \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
+        GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
         if ($result === false) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1204026251);
+            throw new Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1204026251);
         }
         $i = 0;
         $cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
@@ -152,7 +155,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
             $i++;
         }
         if ($result === false) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
+            throw new Exception('The cache file "' . $cacheEntryPathAndFilename . '" could not be written.', 1222361632);
         }
         if ($this->cacheEntryFileExtension === '.php') {
             GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive($cacheEntryPathAndFilename);
@@ -252,7 +255,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
         $entryIdentifiers = [];
         $now = $GLOBALS['EXEC_TIME'];
         $cacheEntryFileExtensionLength = strlen($this->cacheEntryFileExtension);
-        for ($directoryIterator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\DirectoryIterator::class, $this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
+        for ($directoryIterator = GeneralUtility::makeInstance(\DirectoryIterator::class, $this->cacheDirectory); $directoryIterator->valid(); $directoryIterator->next()) {
             if ($directoryIterator->isDot()) {
                 continue;
             }
diff --git a/typo3/sysext/core/Classes/Cache/Backend/FreezableBackendInterface.php b/typo3/sysext/core/Classes/Cache/Backend/FreezableBackendInterface.php
index dc72335493b4..e7035530552b 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/FreezableBackendInterface.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/FreezableBackendInterface.php
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * @api
  */
-interface FreezableBackendInterface extends \TYPO3\CMS\Core\Cache\Backend\BackendInterface
+interface FreezableBackendInterface extends BackendInterface
 {
     /**
      * Freezes this cache backend.
diff --git a/typo3/sysext/core/Classes/Cache/Backend/NullBackend.php b/typo3/sysext/core/Classes/Cache/Backend/NullBackend.php
index 76d84aea09f4..62cc4c62a3e4 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/NullBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/NullBackend.php
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * @api
  */
-class NullBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implements \TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface, \TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface
+class NullBackend extends AbstractBackend implements PhpCapableBackendInterface, TaggableBackendInterface
 {
     /**
      * Acts as if it would save data
diff --git a/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php b/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php
index 48e7a4bccb77..3ad8446edae0 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/PdoBackend.php
@@ -14,11 +14,18 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Database\PdoHelper;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * A PDO database cache backend
  * @api
  */
-class PdoBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implements \TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface
+class PdoBackend extends AbstractBackend implements TaggableBackendInterface
 {
     /**
      * @var string
@@ -93,31 +100,31 @@ class PdoBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
-     * @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set.
+     * @throws Exception if no cache frontend has been set.
      * @throws \InvalidArgumentException if the identifier is not valid
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if $data is not a string
+     * @throws InvalidDataException if $data is not a string
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('No cache frontend has been set yet via setCache().', 1259515600);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('No cache frontend has been set yet via setCache().', 1259515600);
         }
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1259515601);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1259515601);
         }
         $this->remove($entryIdentifier);
         $lifetime = $lifetime ?? $this->defaultLifetime;
         $statementHandle = $this->databaseHandle->prepare('INSERT INTO "cache" ("identifier", "context", "cache", "created", "lifetime", "content") VALUES (?, ?, ?, ?, ?, ?)');
         $result = $statementHandle->execute([$entryIdentifier, $this->context, $this->cacheIdentifier, $GLOBALS['EXEC_TIME'], $lifetime, $data]);
         if ($result === false) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The cache entry "' . $entryIdentifier . '" could not be written.', 1259530791);
+            throw new Exception('The cache entry "' . $entryIdentifier . '" could not be written.', 1259530791);
         }
         $statementHandle = $this->databaseHandle->prepare('INSERT INTO "tags" ("identifier", "context", "cache", "tag") VALUES (?, ?, ?, ?)');
         foreach ($tags as $tag) {
             $result = $statementHandle->execute([$entryIdentifier, $this->context, $this->cacheIdentifier, $tag]);
             if ($result === false) {
-                throw new \TYPO3\CMS\Core\Cache\Exception('The tag "' . $tag . ' for cache entry "' . $entryIdentifier . '" could not be written.', 1259530751);
+                throw new Exception('The tag "' . $tag . ' for cache entry "' . $entryIdentifier . '" could not be written.', 1259530751);
             }
         }
     }
@@ -244,10 +251,10 @@ class PdoBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
             $splitdsn = explode(':', $this->dataSourceName, 2);
             $this->pdoDriver = $splitdsn[0];
             if ($this->pdoDriver === 'sqlite' && !file_exists($splitdsn[1])) {
-                $this->databaseHandle = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\PDO::class, $this->dataSourceName, $this->username, $this->password);
+                $this->databaseHandle = GeneralUtility::makeInstance(\PDO::class, $this->dataSourceName, $this->username, $this->password);
                 $this->createCacheTables();
             } else {
-                $this->databaseHandle = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\PDO::class, $this->dataSourceName, $this->username, $this->password);
+                $this->databaseHandle = GeneralUtility::makeInstance(\PDO::class, $this->dataSourceName, $this->username, $this->password);
             }
             $this->databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             if (substr($this->pdoDriver, 0, 5) === 'mysql') {
@@ -266,10 +273,10 @@ class PdoBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
     protected function createCacheTables()
     {
         try {
-            \TYPO3\CMS\Core\Database\PdoHelper::importSql(
+            PdoHelper::importSql(
                 $this->databaseHandle,
                 $this->pdoDriver,
-                \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('core') .
+                ExtensionManagementUtility::extPath('core') .
                 'Resources/Private/Sql/Cache/Backend/PdoBackendCacheAndTags.sql'
             );
         } catch (\PDOException $e) {
diff --git a/typo3/sysext/core/Classes/Cache/Backend/PhpCapableBackendInterface.php b/typo3/sysext/core/Classes/Cache/Backend/PhpCapableBackendInterface.php
index b98a362879a6..b71cc2bedf94 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/PhpCapableBackendInterface.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/PhpCapableBackendInterface.php
@@ -20,7 +20,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * @api
  */
-interface PhpCapableBackendInterface extends \TYPO3\CMS\Core\Cache\Backend\BackendInterface
+interface PhpCapableBackendInterface extends BackendInterface
 {
     /**
      * Loads PHP code from the cache and require_onces it right away.
diff --git a/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php b/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php
index 9598807ed1e3..90ab2cef4c35 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
 use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
@@ -134,12 +136,12 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
      *
      * @param string $context Unused, for backward compatibility only
      * @param array $options Configuration options
-     * @throws \TYPO3\CMS\Core\Cache\Exception if php redis module is not loaded
+     * @throws Exception if php redis module is not loaded
      */
     public function __construct($context, array $options = [])
     {
         if (!extension_loaded('redis')) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The PHP extension "redis" must be installed and loaded in order to use the redis backend.', 1279462933);
+            throw new Exception('The PHP extension "redis" must be installed and loaded in order to use the redis backend.', 1279462933);
         }
         parent::__construct($context, $options);
     }
@@ -147,7 +149,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
     /**
      * Initializes the redis backend
      *
-     * @throws \TYPO3\CMS\Core\Cache\Exception if access to redis with password is denied or if database selection fails
+     * @throws Exception if access to redis with password is denied or if database selection fails
      */
     public function initializeObject()
     {
@@ -165,13 +167,13 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
             if ($this->password !== '') {
                 $success = $this->redis->auth($this->password);
                 if (!$success) {
-                    throw new \TYPO3\CMS\Core\Cache\Exception('The given password was not accepted by the redis server.', 1279765134);
+                    throw new Exception('The given password was not accepted by the redis server.', 1279765134);
                 }
             }
             if ($this->database >= 0) {
                 $success = $this->redis->select($this->database);
                 if (!$success) {
-                    throw new \TYPO3\CMS\Core\Cache\Exception('The given database "' . $this->database . '" could not be selected.', 1279765144);
+                    throw new Exception('The given database "' . $this->database . '" could not be selected.', 1279765144);
                 }
             }
         }
@@ -308,7 +310,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, default lifetime is used. "0" means unlimited lifetime.
      * @throws \InvalidArgumentException if identifier is not valid
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if data is not a string
+     * @throws InvalidDataException if data is not a string
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
@@ -317,7 +319,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
             throw new \InvalidArgumentException('The specified identifier is of type "' . gettype($entryIdentifier) . '" which can\'t be converted to string.', 1377006651);
         }
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1279469941);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1279469941);
         }
         $lifetime = $lifetime ?? $this->defaultLifetime;
         if (!is_int($lifetime)) {
diff --git a/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php b/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php
index 158d2e97956f..3c7359122fcc 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php
@@ -14,6 +14,10 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -70,10 +74,10 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
      * Sets a reference to the cache frontend which uses this backend and
      * initializes the default cache directory.
      *
-     * @param \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache The cache frontend
-     * @throws \TYPO3\CMS\Core\Cache\Exception
+     * @param FrontendInterface $cache The cache frontend
+     * @throws Exception
      */
-    public function setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
+    public function setCache(FrontendInterface $cache)
     {
         parent::setCache($cache);
         if (empty($this->temporaryCacheDirectory)) {
@@ -83,16 +87,16 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
         } else {
             $temporaryCacheDirectory = $this->temporaryCacheDirectory;
         }
-        $codeOrData = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? 'code' : 'data';
+        $codeOrData = $cache instanceof PhpFrontend ? 'code' : 'data';
         $finalCacheDirectory = $temporaryCacheDirectory . 'cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
         if (!is_dir($finalCacheDirectory)) {
             $this->createFinalCacheDirectory($finalCacheDirectory);
         }
         unset($this->temporaryCacheDirectory);
         $this->cacheDirectory = $finalCacheDirectory;
-        $this->cacheEntryFileExtension = $cache instanceof \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend ? '.php' : '';
+        $this->cacheEntryFileExtension = $cache instanceof PhpFrontend ? '.php' : '';
         if (strlen($this->cacheDirectory) + 23 > PHP_MAXPATHLEN) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The length of the temporary cache file path "' . $this->cacheDirectory . '" exceeds the ' . 'maximum path length of ' . (PHP_MAXPATHLEN - 23) . '. Please consider ' . 'setting the temporaryDirectoryBase option to a shorter path.', 1248710426);
+            throw new Exception('The length of the temporary cache file path "' . $this->cacheDirectory . '" exceeds the ' . 'maximum path length of ' . (PHP_MAXPATHLEN - 23) . '. Please consider ' . 'setting the temporaryDirectoryBase option to a shorter path.', 1248710426);
         }
     }
 
@@ -107,7 +111,7 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
      * option was handled.
      *
      * @param string $cacheDirectory The cache base directory. If a relative path
-     * @throws \TYPO3\CMS\Core\Cache\Exception if the directory is not within allowed
+     * @throws Exception if the directory is not within allowed
      */
     public function setCacheDirectory($cacheDirectory)
     {
@@ -141,7 +145,7 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
                 if ($basedir[strlen($basedir) - 1] !== '/') {
                     $basedir .= '/';
                 }
-                if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($cacheDirectory, $basedir)) {
+                if (GeneralUtility::isFirstPartOfStr($cacheDirectory, $basedir)) {
                     $documentRoot = $basedir;
                     $cacheDirectory = str_replace($basedir, '', $cacheDirectory);
                     $cacheDirectoryInBaseDir = true;
@@ -149,7 +153,7 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
                 }
             }
             if (!$cacheDirectoryInBaseDir) {
-                throw new \TYPO3\CMS\Core\Cache\Exception(
+                throw new Exception(
                     'Open_basedir restriction in effect. The directory "' . $cacheDirectory . '" is not in an allowed path.',
                     1476045417
                 );
@@ -176,17 +180,17 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
      * Create the final cache directory if it does not exist.
      *
      * @param string $finalCacheDirectory Absolute path to final cache directory
-     * @throws \TYPO3\CMS\Core\Cache\Exception If directory is not writable after creation
+     * @throws Exception If directory is not writable after creation
      */
     protected function createFinalCacheDirectory($finalCacheDirectory)
     {
         try {
-            \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($finalCacheDirectory);
+            GeneralUtility::mkdir_deep($finalCacheDirectory);
         } catch (\RuntimeException $e) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The directory "' . $finalCacheDirectory . '" can not be created.', 1303669848, $e);
+            throw new Exception('The directory "' . $finalCacheDirectory . '" can not be created.', 1303669848, $e);
         }
         if (!is_writable($finalCacheDirectory)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The directory "' . $finalCacheDirectory . '" is not writable.', 1203965200);
+            throw new Exception('The directory "' . $finalCacheDirectory . '" is not writable.', 1203965200);
         }
     }
 
@@ -208,15 +212,15 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime This cache backend does not support life times
-     * @throws \TYPO3\CMS\Core\Cache\Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if the data to bes stored is not a string.
+     * @throws Exception if the directory does not exist or is not writable or exceeds the maximum allowed path length, or if no cache frontend has been set.
+     * @throws InvalidDataException if the data to bes stored is not a string.
      * @throws \InvalidArgumentException
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1334756734);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1334756734);
         }
         if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
             throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
@@ -226,9 +230,9 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
         }
         $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . StringUtility::getUniqueId() . '.temp';
         $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data);
-        \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
+        GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
         if ($result === false) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1334756737);
+            throw new Exception('The temporary cache file "' . $temporaryCacheEntryPathAndFilename . '" could not be written.', 1334756737);
         }
         $cacheEntryPathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
         rename($temporaryCacheEntryPathAndFilename, $cacheEntryPathAndFilename);
@@ -305,7 +309,7 @@ class SimpleFileBackend extends AbstractBackend implements PhpCapableBackendInte
      */
     public function flush()
     {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::flushDirectory($this->cacheDirectory, true);
+        GeneralUtility::flushDirectory($this->cacheDirectory, true);
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Cache/Backend/TaggableBackendInterface.php b/typo3/sysext/core/Classes/Cache/Backend/TaggableBackendInterface.php
index e800133a8f5c..dfea18ac4c06 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/TaggableBackendInterface.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/TaggableBackendInterface.php
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * @api
  */
-interface TaggableBackendInterface extends \TYPO3\CMS\Core\Cache\Backend\BackendInterface
+interface TaggableBackendInterface extends BackendInterface
 {
     /**
      * Removes all cache entries of this cache which are tagged by the specified tag.
diff --git a/typo3/sysext/core/Classes/Cache/Backend/TransientMemoryBackend.php b/typo3/sysext/core/Classes/Cache/Backend/TransientMemoryBackend.php
index e1199648cef6..15b5814b176d 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/TransientMemoryBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/TransientMemoryBackend.php
@@ -14,12 +14,15 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+
 /**
  * A caching backend which stores cache entries during one script run.
  *
  * @api
  */
-class TransientMemoryBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implements TaggableBackendInterface, TransientBackendInterface
+class TransientMemoryBackend extends AbstractBackend implements TaggableBackendInterface, TransientBackendInterface
 {
     /**
      * @var array
@@ -38,14 +41,13 @@ class TransientMemoryBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBacke
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
-     * @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set.
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
+     * @throws Exception if no cache frontend has been set.
      * @api
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('No cache frontend has been set yet via setCache().', 1238244992);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('No cache frontend has been set yet via setCache().', 1238244992);
         }
         $this->entries[$entryIdentifier] = $data;
         foreach ($tags as $tag) {
diff --git a/typo3/sysext/core/Classes/Cache/Backend/WincacheBackend.php b/typo3/sysext/core/Classes/Cache/Backend/WincacheBackend.php
index 107dcf3e3aea..a13c1fff3513 100644
--- a/typo3/sysext/core/Classes/Cache/Backend/WincacheBackend.php
+++ b/typo3/sysext/core/Classes/Cache/Backend/WincacheBackend.php
@@ -14,6 +14,10 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+
 /**
  * A caching backend which stores cache entries by using wincache.
  *
@@ -34,7 +38,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * This prefix makes sure that keys from the different installations do not
  * conflict.
  */
-class WincacheBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implements \TYPO3\CMS\Core\Cache\Backend\TaggableBackendInterface
+class WincacheBackend extends AbstractBackend implements TaggableBackendInterface
 {
     /**
      * A prefix to separate stored data from other data possible stored in the wincache
@@ -48,12 +52,12 @@ class WincacheBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impl
      *
      * @param string $context Unused, for backward compatibility only
      * @param array $options Configuration options
-     * @throws \TYPO3\CMS\Core\Cache\Exception If wincache PHP extension is not loaded
+     * @throws Exception If wincache PHP extension is not loaded
      */
     public function __construct($context, array $options = [])
     {
         if (!extension_loaded('wincache')) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('The PHP extension "wincache" must be installed and loaded in order to use the wincache backend.', 1343331520);
+            throw new Exception('The PHP extension "wincache" must be installed and loaded in order to use the wincache backend.', 1343331520);
         }
         parent::__construct($context, $options);
     }
@@ -65,17 +69,17 @@ class WincacheBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impl
      * @param string $data The data to be stored
      * @param array $tags Tags to associate with this cache entry
      * @param int $lifetime Lifetime of this cache entry in seconds. If NULL is specified, the default lifetime is used. "0" means unlimited lifetime.
-     * @throws \TYPO3\CMS\Core\Cache\Exception if no cache frontend has been set
+     * @throws Exception if no cache frontend has been set
      * @throws \InvalidArgumentException if the identifier is not valid
-     * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException if $data is not a string
+     * @throws InvalidDataException if $data is not a string
      */
     public function set($entryIdentifier, $data, array $tags = [], $lifetime = null)
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('No cache frontend has been set yet via setCache().', 1343331521);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('No cache frontend has been set yet via setCache().', 1343331521);
         }
         if (!is_string($data)) {
-            throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1343331522);
+            throw new InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1343331522);
         }
         $tags[] = '%WCBE%' . $this->cache->getIdentifier();
         $expiration = $lifetime ?? $this->defaultLifetime;
@@ -84,7 +88,7 @@ class WincacheBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impl
             $this->removeIdentifierFromAllTags($entryIdentifier);
             $this->addIdentifierToTags($entryIdentifier, $tags);
         } else {
-            throw new \TYPO3\CMS\Core\Cache\Exception('Could not set value.', 1343331523);
+            throw new Exception('Could not set value.', 1343331523);
         }
     }
 
@@ -160,12 +164,12 @@ class WincacheBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impl
     /**
      * Removes all cache entries of this cache
      *
-     * @throws \TYPO3\CMS\Core\Cache\Exception
+     * @throws Exception
      */
     public function flush()
     {
-        if (!$this->cache instanceof \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface) {
-            throw new \TYPO3\CMS\Core\Cache\Exception('Yet no cache frontend has been set via setCache().', 1343331524);
+        if (!$this->cache instanceof FrontendInterface) {
+            throw new Exception('Yet no cache frontend has been set via setCache().', 1343331524);
         }
         $this->flushByTag('%WCBE%' . $this->cache->getIdentifier());
     }
-- 
GitLab