[TASK] Harden \TYPO3\CMS\Extbase\Service\CacheService 91/59591/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Thu, 31 Jan 2019 17:22:31 +0000 (18:22 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 11:50:21 +0000 (12:50 +0100)
- Use strict type mode
- Use type hints whereever possible

Releases: master
Resolves: #87596
Change-Id: I99fe661ff7ee0c29d34c0fde7c5c2c83f0f39201
Reviewed-on: https://review.typo3.org/59591
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Documentation/Changelog/master/Important-87603-ClassesUseStrictModeAndScarlarTypeHints.rst
typo3/sysext/extbase/Classes/Service/CacheService.php

index 16f1f98..d223a7a 100644 (file)
@@ -14,5 +14,6 @@ and their methods will force parameter types with scalar type hints:
 
 - :php:`\TYPO3\CMS\Extbase\Core\Bootstrap`
 - :php:`\TYPO3\CMS\Extbase\Security\Cryptography\HashService`
+- :php:`\TYPO3\CMS\Extbase\Service\CacheService`
 
 .. index:: Backend, PHP-API, ext:extbase
index fcbf1de..c287dcc 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Extbase\Service;
 
 /*
@@ -33,7 +35,7 @@ class CacheService implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * @param \TYPO3\CMS\Core\Cache\CacheManager $cacheManager
      */
-    public function injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager)
+    public function injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager): void
     {
         $this->cacheManager = $cacheManager;
     }
@@ -49,7 +51,7 @@ class CacheService implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * @return \SplStack
      */
-    public function getPageIdStack()
+    public function getPageIdStack(): \SplStack
     {
         return $this->pageIdStack;
     }
@@ -57,9 +59,9 @@ class CacheService implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * Clears the page cache
      *
-     * @param mixed $pageIdsToClear (int) single or (array) multiple pageIds to clear the cache for
+     * @param int|int[] $pageIdsToClear single or multiple pageIds to clear the cache for
      */
-    public function clearPageCache($pageIdsToClear = null)
+    public function clearPageCache($pageIdsToClear = null): void
     {
         if ($pageIdsToClear === null) {
             $this->cacheManager->flushCachesInGroup('pages');
@@ -78,7 +80,7 @@ class CacheService implements \TYPO3\CMS\Core\SingletonInterface
      * Walks through the pageIdStack, collects all pageIds
      * as array and passes them on to clearPageCache.
      */
-    public function clearCachesOfRegisteredPageIds()
+    public function clearCachesOfRegisteredPageIds(): void
     {
         if (!$this->pageIdStack->isEmpty()) {
             $pageIds = [];