[TASK] Harden \TYPO3\CMS\Extbase\Core\Bootstrap 98/59598/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Thu, 31 Jan 2019 19:54:02 +0000 (20:54 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 10:49:35 +0000 (11:49 +0100)
- Use strict type mode
- Use type hints whereever possible

Releases: master
Resolves: #87603
Change-Id: I3430b59e93133d9b19d6520d3fd7cca83c0fdb49
Reviewed-on: https://review.typo3.org/59598
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
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 [new file with mode: 0644]
typo3/sysext/extbase/Classes/Core/Bootstrap.php
typo3/sysext/extbase/Classes/Core/BootstrapInterface.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-87603-ClassesUseStrictModeAndScarlarTypeHints.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-87603-ClassesUseStrictModeAndScarlarTypeHints.rst
new file mode 100644 (file)
index 0000000..87179c9
--- /dev/null
@@ -0,0 +1,17 @@
+.. include:: ../../Includes.txt
+
+==================================================================
+Important: #87594 - Classes use strict mode and scarlar type hints
+==================================================================
+
+See :issue:`87594`
+
+Description
+===========
+
+The following PHP classes now use strict mode
+and their methods will force parameter types with scalar type hints:
+
+- :php:`\TYPO3\CMS\Extbase\Core\Bootstrap`
+
+.. index:: Backend, PHP-API, ext:extbase
\ No newline at end of file
index 1e490a2..f15204a 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Extbase\Core;
 
 /*
@@ -61,7 +63,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
      * @throws \RuntimeException
      * @see run()
      */
-    public function initialize($configuration)
+    public function initialize(array $configuration): void
     {
         if (!Environment::isCli()) {
             if (!isset($configuration['vendorName']) || $configuration['vendorName'] === '') {
@@ -84,7 +86,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
      *
      * @see initialize()
      */
-    protected function initializeObjectManager()
+    protected function initializeObjectManager(): void
     {
         $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     }
@@ -96,7 +98,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
      * @see initialize()
      * @internal
      */
-    public function initializeConfiguration($configuration)
+    public function initializeConfiguration(array $configuration): void
     {
         $this->configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
         /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject */
@@ -117,7 +119,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
      * @see initialize()
      * @internal
      */
-    public function initializePersistence()
+    public function initializePersistence(): void
     {
         $this->persistenceManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
     }
@@ -130,7 +132,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
      * @param array $configuration The TS configuration array
      * @return string $content The processed content
      */
-    public function run($content, $configuration)
+    public function run(string $content, array $configuration): string
     {
         $this->initialize($configuration);
         return $this->handleRequest();
@@ -139,7 +141,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
     /**
      * @return string
      */
-    protected function handleRequest()
+    protected function handleRequest(): string
     {
         /** @var \TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver $requestHandlerResolver */
         $requestHandlerResolver = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\RequestHandlerResolver::class);
@@ -219,7 +221,7 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface
     /**
      * Resets global singletons for the next plugin
      */
-    protected function resetSingletons()
+    protected function resetSingletons(): void
     {
         $this->persistenceManager->persistAll();
     }
index 0f25419..22bc0a8 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Extbase\Core;
 
 /*
@@ -28,5 +30,5 @@ interface BootstrapInterface
      * @param array $configuration The TS configuration array
      * @return string $content The processed content
      */
-    public function run($content, $configuration);
+    public function run(string $content, array $configuration): string;
 }