[TASK] Apply code cleanup 80/56080/3
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 9 Mar 2018 17:28:25 +0000 (18:28 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 12 Mar 2018 22:34:45 +0000 (23:34 +0100)
* Reapply usage of null coalescing operator from review:54810 that have
  been lost by the revert review:55422
* Prevent E_NOTICES within InheritancesResolverService
* Fix typos in unit tests

Releases: master
Resolves: #84189
Change-Id: If77ff3eddf51fa821314800cebaaf76d482b22e7
Reviewed-on: https://review.typo3.org/56080
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Controller/FormEditorController.php
typo3/sysext/form/Classes/Mvc/Configuration/InheritancesResolverService.php
typo3/sysext/form/Tests/Unit/Controller/FormEditorControllerTest.php
typo3/sysext/form/Tests/Unit/Controller/FormManagerControllerTest.php
typo3/sysext/form/Tests/Unit/Domain/Finishers/AbstractFinisherTest.php
typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php
typo3/sysext/form/Tests/Unit/Mvc/ProcessingRuleTest.php

index cf60953..0fa2b38 100644 (file)
@@ -72,11 +72,10 @@ class FormEditorController extends AbstractBackendController
             throw new PersistenceManagerException('Edit a extension formDefinition is not allowed.', 1478265661);
         }
 
+        $prototypeName = $prototypeName ?: $formDefinition['prototypeName'] ?? 'standard';
         $formDefinition = $this->formPersistenceManager->load($formPersistenceIdentifier);
         $formDefinition = ArrayUtility::stripTagsFromValuesRecursive($formDefinition);
-        if (empty($prototypeName)) {
-            $prototypeName = $formDefinition['prototypeName'] ?? 'standard';
-        }
+
         $formDefinition['prototypeName'] = $prototypeName;
 
         $configurationService = $this->objectManager->get(ConfigurationService::class);
@@ -152,6 +151,7 @@ class FormEditorController extends AbstractBackendController
     public function saveFormAction(string $formPersistenceIdentifier, FormDefinitionArray $formDefinition)
     {
         $formDefinition = $formDefinition->getArrayCopy();
+
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeFormSave'] ?? [] as $className) {
             $hookObj = GeneralUtility::makeInstance($className);
             if (method_exists($hookObj, 'beforeFormSave')) {
@@ -196,15 +196,14 @@ class FormEditorController extends AbstractBackendController
      */
     public function renderFormPageAction(FormDefinitionArray $formDefinition, int $pageIndex, string $prototypeName = null): string
     {
-        if (empty($prototypeName)) {
-            $prototypeName = $formDefinition['prototypeName'] ?? 'standard';
-        }
+        $prototypeName = $prototypeName ?: $formDefinition['prototypeName'] ?? 'standard';
 
         $formFactory = $this->objectManager->get(ArrayFormFactory::class);
         $formDefinition = $formFactory->build($formDefinition->getArrayCopy(), $prototypeName);
         $formDefinition->setRenderingOption('previewMode', true);
         $form = $formDefinition->bind($this->request, $this->response);
         $form->overrideCurrentPage($pageIndex);
+
         return $form->render();
     }
 
@@ -217,7 +216,6 @@ class FormEditorController extends AbstractBackendController
      */
     protected function getInsertRenderablesPanelConfiguration(array $formElementsDefinition): array
     {
-        $formElementGroups = $this->prototypeConfiguration['formEditor']['formElementGroups'] ?? [];
         $formElementsByGroup = [];
 
         foreach ($formElementsDefinition as $formElementName => $formElementConfiguration) {
@@ -243,7 +241,7 @@ class FormEditorController extends AbstractBackendController
         }
 
         $formGroups = [];
-        foreach ($formElementGroups as $groupName => $groupConfiguration) {
+        foreach ($this->prototypeConfiguration['formEditor']['formElementGroups'] ?? [] as $groupName => $groupConfiguration) {
             if (!isset($formElementsByGroup[$groupName])) {
                 continue;
             }
index 10edf3d..7a9118f 100644 (file)
@@ -302,7 +302,8 @@ class InheritancesResolverService
                     }
 
                     if (
-                        is_array($this->inheritanceStack[$pathToCheck])
+                        isset($this->inheritanceStack[$pathToCheck])
+                        && is_array($this->inheritanceStack[$pathToCheck])
                         && in_array($inheritancePath, $this->inheritanceStack[$pathToCheck])
                     ) {
                         $this->inheritanceStack[$pathToCheck][] = $inheritancePath;
index 36b0482..5a5f951 100644 (file)
@@ -61,8 +61,8 @@ class FormEditorControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             'dummy'
         ], [], '', false);
 
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translate'
@@ -73,7 +73,7 @@ class FormEditorControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             ->method('translate')
             ->willReturnArgument(4);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -159,8 +159,8 @@ class FormEditorControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             'dummy'
         ], [], '', false);
 
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateValuesRecursive'
@@ -171,7 +171,7 @@ class FormEditorControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes
             ->method('translateValuesRecursive')
             ->willReturnArgument(0);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
index e77bea7..b8fb4eb 100644 (file)
@@ -122,8 +122,8 @@ class FormManagerControllerTest extends UnitTestCase
      */
     public function getFormManagerAppInitialDataReturnsProcessedArray()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateValuesRecursive'
@@ -134,7 +134,7 @@ class FormManagerControllerTest extends UnitTestCase
             ->method('translateValuesRecursive')
             ->willReturnArgument(0);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
index 7144164..63e20d4 100644 (file)
@@ -150,8 +150,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsValueFromFormRuntimeIfOptionNameReferenceAFormElementIdentifierWhoseValueIsAString()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -162,7 +162,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -199,8 +199,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsNoReplacedValueFromFormRuntimeIfOptionNameReferenceAFormElementIdentifierWhoseValueIsNotAString()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -211,7 +211,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -249,8 +249,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsNoReplacedValueFromFormRuntimeIfOptionNameReferenceANonExistingFormElement()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -261,7 +261,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -298,8 +298,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsDefaultOptionValueIfOptionNameNotExistsWithinOptionsButWithinDefaultOptions()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -310,7 +310,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -347,8 +347,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsDefaultOptionValueIfOptionValueIsAFormElementReferenceAndTheFormElementValueIsEmpty()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -359,7 +359,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
@@ -399,8 +399,8 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function parseOptionReturnsTimestampIfOptionValueIsATimestampRequestTrigger()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
         $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
             'translateFinisherOption'
@@ -411,7 +411,7 @@ class AbstractFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
             ->method('translateFinisherOption')
             ->willReturnArgument(3);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(TranslationService::class)
             ->willReturn($mockTranslationService);
 
index 005463d..738a61a 100644 (file)
@@ -183,10 +183,10 @@ class DataStructureIdentifierHookTest extends \TYPO3\TestingFramework\Core\Unit\
      */
     public function parseDataStructureByIdentifierPostProcessAddsExistingFormItems(array $formDefinition, array $expectedItem)
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
         $formPersistenceManagerProphecy = $this->prophesize(FormPersistenceManager::class);
-        $objectMangerProphecy->get(FormPersistenceManagerInterface::class)
+        $objectManagerProphecy->get(FormPersistenceManagerInterface::class)
             ->willReturn($formPersistenceManagerProphecy->reveal());
 
         $formPersistenceManagerProphecy->listForms()->shouldBeCalled()->willReturn([$formDefinition]);
index ac8217f..aae41df 100644 (file)
@@ -71,11 +71,11 @@ class ProcessingRuleTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processNoPropertyMappingReturnsNotModifiedValue()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
         $resultProphecy = $this->prophesize(Result::class);
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(Result::class)
             ->willReturn($resultProphecy->reveal());
 
@@ -96,10 +96,10 @@ class ProcessingRuleTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processNoPropertyMappingAndHasErrorsIfValidatorContainsErrors()
     {
-        $objectMangerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectMangerProphecy->reveal());
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
 
-        $objectMangerProphecy
+        $objectManagerProphecy
             ->get(Result::class)
             ->willReturn(new Result);