[TASK] Use a cast to float instead of doubleval 49/50549/7
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 8 Nov 2016 22:14:07 +0000 (23:14 +0100)
committerBenni Mack <benni@typo3.org>
Wed, 9 Nov 2016 21:54:07 +0000 (22:54 +0100)
The method doubleval is an alias of floatval and
this could be used. But using a cast to float is
quicker.

Resolves: #78617
Releases: master
Change-Id: If5d6c39583534a1878bd94b41f37f3e523627d77
Reviewed-on: https://review.typo3.org/50549
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
13 files changed:
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/core/Classes/Database/QueryGenerator.php
typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
typo3/sysext/core/Classes/Utility/ClientUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Classes/Utility/MathUtility.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php
typo3/sysext/form/Classes/Domain/Validator/FloatValidator.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
typo3/sysext/install/Classes/SystemEnvironment/Check.php
typo3/sysext/rtehtmlarea/Classes/Controller/SpellCheckingController.php
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php

index f6ec681..bc860d9 100644 (file)
@@ -487,10 +487,10 @@ abstract class AbstractConditionMatcher
             $rightValue = $matches[2];
             switch ($operator) {
                 case '>=':
-                    return $leftValue >= doubleval($rightValue);
+                    return $leftValue >= (float)$rightValue;
                     break;
                 case '<=':
-                    return $leftValue <= doubleval($rightValue);
+                    return $leftValue <= (float)$rightValue;
                     break;
                 case '!=':
                     // multiple values may be split with '|'
@@ -498,7 +498,7 @@ abstract class AbstractConditionMatcher
                     $found = false;
                     $rightValueParts = GeneralUtility::trimExplode('|', $rightValue);
                     foreach ($rightValueParts as $rightValueSingle) {
-                        if ($leftValue == doubleval($rightValueSingle)) {
+                        if ($leftValue == (float)$rightValueSingle) {
                             $found = true;
                             break;
                         }
@@ -506,10 +506,10 @@ abstract class AbstractConditionMatcher
                     return $found === false;
                     break;
                 case '<':
-                    return $leftValue < doubleval($rightValue);
+                    return $leftValue < (float)$rightValue;
                     break;
                 case '>':
-                    return $leftValue > doubleval($rightValue);
+                    return $leftValue > (float)$rightValue;
                     break;
                 default:
                     // nothing valid found except '=', use '='
index ed1adfe..fecf77a 100644 (file)
@@ -1347,7 +1347,7 @@ class QueryGenerator
                 $inputVal = 0;
             }
         } else {
-            $inputVal = doubleval($conf['inputValue' . $suffix]);
+            $inputVal = (float)$conf['inputValue' . $suffix];
         }
         return $inputVal;
     }
index dab8321..ad972a0 100644 (file)
@@ -1658,7 +1658,7 @@ class GraphicalFunctions
             $effect = strtolower(trim($pairs[0]));
             switch ($effect) {
                 case 'gamma':
-                    $commands .= ' -gamma ' . doubleval($value);
+                    $commands .= ' -gamma ' . (float)$value;
                     break;
                 case 'blur':
                     if (!$this->NO_IM_EFFECTS) {
index 22554a7..0e57ad3 100644 (file)
@@ -169,7 +169,7 @@ class ClientUtility
     }
 
     /**
-     * Returns the version of a browser; Basically getting doubleval() of the input string,
+     * Returns the version of a browser; Basically getting float value of the input string,
      * stripping of any non-numeric values in the beginning of the string first.
      *
      * @param string $version A string with version number, eg. "/7.32 blablabla
@@ -177,7 +177,7 @@ class ClientUtility
      */
     public static function getVersion($version)
     {
-        return doubleval(preg_replace('/^[^0-9]*/', '', $version));
+        return (float)preg_replace('/^[^0-9]*/', '', $version);
     }
 
     /**
index 688260d..6176565 100644 (file)
@@ -2632,7 +2632,7 @@ class GeneralUtility
      */
     public static function getBytesFromSizeMeasurement($measurement)
     {
-        $bytes = doubleval($measurement);
+        $bytes = (float)$measurement;
         if (stripos($measurement, 'G')) {
             $bytes *= 1024 * 1024 * 1024;
         } elseif (stripos($measurement, 'M')) {
@@ -3179,29 +3179,29 @@ class GeneralUtility
             // Browser version
             switch ($bInfo['BROWSER']) {
                 case 'net':
-                    $bInfo['VERSION'] = doubleval(substr($useragent, 8));
+                    $bInfo['VERSION'] = (float)substr($useragent, 8);
                     if (strpos($useragent, 'Netscape6/') !== false) {
-                        $bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape6/'), 10));
+                        $bInfo['VERSION'] = (float)substr(strstr($useragent, 'Netscape6/'), 10);
                     }
                     // Will we ever know if this was a typo or intention...?! :-(
                     if (strpos($useragent, 'Netscape/6') !== false) {
-                        $bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/6'), 10));
+                        $bInfo['VERSION'] = (float)substr(strstr($useragent, 'Netscape/6'), 10);
                     }
                     if (strpos($useragent, 'Netscape/7') !== false) {
-                        $bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/7'), 9));
+                        $bInfo['VERSION'] = (float)substr(strstr($useragent, 'Netscape/7'), 9);
                     }
                     break;
                 case 'msie':
                     $tmp = strstr($useragent, 'MSIE');
-                    $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 4)));
+                    $bInfo['VERSION'] = (float)preg_replace('/^[^0-9]*/', '', substr($tmp, 4));
                     break;
                 case 'opera':
                     $tmp = strstr($useragent, 'Opera');
-                    $bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 5)));
+                    $bInfo['VERSION'] = (float)preg_replace('/^[^0-9]*/', '', substr($tmp, 5));
                     break;
                 case 'konqu':
                     $tmp = strstr($useragent, 'Konqueror/');
-                    $bInfo['VERSION'] = doubleval(substr($tmp, 10));
+                    $bInfo['VERSION'] = (float)substr($tmp, 10);
                     break;
             }
             // Client system
index eb622c0..855ada3 100644 (file)
@@ -123,11 +123,11 @@ class MathUtility
         $number = 0;
         $Msign = '+';
         $err = '';
-        $buffer = doubleval(current($reg[2]));
+        $buffer = (float)current($reg[2]);
         // Advance pointer
         $regSliced = array_slice($reg[2], 1, null, true);
         foreach ($regSliced as $k => $v) {
-            $v = doubleval($v);
+            $v = (float)$v;
             $sign = $reg[1][$k];
             if ($sign == '+' || $sign == '-') {
                 $Msign == '-' ? ($number -= $buffer) : ($number += $buffer);
index 54263d0..f54cc57 100644 (file)
@@ -96,7 +96,7 @@ class CurrencyViewHelper extends AbstractViewHelper
         if (empty($floatToFormat)) {
             $floatToFormat = 0.0;
         } else {
-            $floatToFormat = floatval($floatToFormat);
+            $floatToFormat = (float)$floatToFormat;
         }
         $output = number_format($floatToFormat, $decimals, $decimalSeparator, $thousandsSeparator);
         if ($currencySign !== '') {
index 0be009c..4322d71 100644 (file)
@@ -48,7 +48,7 @@ class FloatValidator extends AbstractValidator
             ],
             $value
         );
-        if ($value != strval(floatval($valueFiltered))) {
+        if ($value != strval((float)$valueFiltered)) {
             $this->addError(
                 $this->renderMessage(
                     $this->options['errorMessage'][0],
index 26ba1fb..608b87d 100644 (file)
@@ -4495,7 +4495,7 @@ class ContentObjectRenderer
     {
         $decimals = isset($conf['decimals.']) ? $this->stdWrap($conf['decimals'], $conf['decimals.']) : $conf['decimals'];
         $type = isset($conf['roundType.']) ? $this->stdWrap($conf['roundType'], $conf['roundType.']) : $conf['roundType'];
-        $floatVal = floatval($content);
+        $floatVal = (float)$content;
         switch ($type) {
             case 'ceil':
                 $content = ceil($floatVal);
@@ -4524,7 +4524,7 @@ class ContentObjectRenderer
         $decimals = isset($conf['decimals.']) ? (int)$this->stdWrap($conf['decimals'], $conf['decimals.']) : (int)$conf['decimals'];
         $dec_point = isset($conf['dec_point.']) ? $this->stdWrap($conf['dec_point'], $conf['dec_point.']) : $conf['dec_point'];
         $thousands_sep = isset($conf['thousands_sep.']) ? $this->stdWrap($conf['thousands_sep'], $conf['thousands_sep.']) : $conf['thousands_sep'];
-        return number_format(floatval($content), $decimals, $dec_point, $thousands_sep);
+        return number_format((float)$content, $decimals, $dec_point, $thousands_sep);
     }
 
     /**
@@ -8098,7 +8098,7 @@ class ContentObjectRenderer
                     $markerValues[$marker] = (int)$tempValue;
                 } else {
                     // Handle float
-                    $markerValues[$marker] = floatval($tempValue);
+                    $markerValues[$marker] = (float)$tempValue;
                 }
             } elseif (is_null($tempValue)) {
                 // It represents NULL
@@ -8114,7 +8114,7 @@ class ContentObjectRenderer
                             if ((int)$listValue == $listValue) {
                                 $tempArray[] = (int)$listValue;
                             } else {
-                                $tempArray[] = floatval($listValue);
+                                $tempArray[] = (float)$listValue;
                             }
                         } else {
                             // If quoted, remove quotes before
index dd08877..1280dcc 100644 (file)
@@ -761,8 +761,8 @@ class GifBuilder extends GraphicalFunctions
                     }
                     $theVal = (int)$theVal;
                 }
-            } elseif (floatval($theVal)) {
-                $theVal = floatval($theVal);
+            } elseif ((float)$theVal) {
+                $theVal = (float)$theVal;
             } else {
                 $theVal = 0;
             }
index 46ffb10..087d7c6 100644 (file)
@@ -1217,7 +1217,7 @@ class Check
      */
     protected function getBytesFromSizeMeasurement($measurement)
     {
-        $bytes = doubleval($measurement);
+        $bytes = (float)$measurement;
         if (stripos($measurement, 'G')) {
             $bytes *= 1024 * 1024 * 1024;
         } elseif (stripos($measurement, 'M')) {
index f3065ff..8f52a95 100644 (file)
@@ -179,7 +179,7 @@ class SpellCheckingController
         if (!$this->pspell_is_available || $this->forceCommandMode) {
             $AspellVersionString = explode('Aspell', shell_exec($this->AspellDirectory . ' -v'));
             $AspellVersion = substr($AspellVersionString[1], 0, 4);
-            if (doubleval($AspellVersion) < doubleval('0.5') && (!$this->pspell_is_available || $this->forceCommandMode)) {
+            if ((float)$AspellVersion < 0.5 && (!$this->pspell_is_available || $this->forceCommandMode)) {
                 echo 'Configuration problem: Aspell version ' . $AspellVersion . ' too old. Spell checking cannot be performed in command mode.';
             }
             $this->defaultAspellEncoding = trim(shell_exec($this->AspellDirectory . ' config encoding'));
index 0cb9d8d..a853960 100644 (file)
@@ -1097,7 +1097,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                     $name = htmlspecialchars($registeredClasses[$class]['title'] . ' (' . $registeredClasses[$class]['extension'] . ')');
                     $additionalInformation = $task->getAdditionalInformation();
                     if ($task instanceof \TYPO3\CMS\Scheduler\ProgressProviderInterface) {
-                        $progress = round(floatval($task->getProgress()), 2);
+                        $progress = round((float)$task->getProgress(), 2);
                         $name .= $this->renderTaskProgressBar($progress);
                     }
                     if (!empty($additionalInformation)) {