[TASK] Avoid count() in test conditions 96/58496/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 30 Sep 2018 13:15:30 +0000 (15:15 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 30 Sep 2018 13:59:59 +0000 (15:59 +0200)
Resolves: #86474
Releases: master
Change-Id: I2265e9167dc0604f8d2605121028c029fe3eebfc
Reviewed-on: https://review.typo3.org/58496
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Resources/PHP/ClassMapGenerator.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php

index e4d04b2..920ef11 100644 (file)
@@ -173,7 +173,8 @@ class ClassMapGenerator
         $classes = [];
         $namespace = '';
 
-        for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
+        $typeCount = count($matches['type']);
+        for ($i = 0, $len = $typeCount; $i < $len; $i++) {
             if (!empty($matches['ns'][$i])) {
                 $namespace = str_replace([' ', "\t", "\r", "\n"], '', $matches['nsname'][$i]) . '\\';
             } else {
index 981caa8..b6c7f0b 100644 (file)
@@ -269,7 +269,8 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper
             'formObjectName'
         );
         // If count == 2 -> we need to go through the for-loop exactly once
-        for ($i = 1; $i < count($propertySegments); $i++) {
+        $propertySegmentsCount = count($propertySegments);
+        for ($i = 1; $i < $propertySegmentsCount; $i++) {
             $object = ObjectAccess::getPropertyPath($formObject, implode('.', array_slice($propertySegments, 0, $i)));
             $objectName .= '[' . $propertySegments[$i - 1] . ']';
             $hiddenIdentityField = $this->renderHiddenIdentityField($object, $objectName);
index 7657dc2..14d02c6 100644 (file)
@@ -138,7 +138,8 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
         // as often as there are elements in the box
         if (isset($this->arguments['multiple']) && $this->arguments['multiple']) {
             $content .= $this->renderHiddenFieldForEmptyValue();
-            for ($i = 0; $i < count($options); $i++) {
+            $optionsCount = count($options);
+            for ($i = 0; $i < $optionsCount; $i++) {
                 $this->registerFieldNameForFormTokenGeneration($name);
             }
             // save the parent field name so that any child f:form.select.option