From 5580c3499b7bdcbc967834eaf7ef17ce596c7ab3 Mon Sep 17 00:00:00 2001 From: Daniel Fahlke Date: Tue, 19 Jan 2021 15:22:00 +0100 Subject: [PATCH] TypeError: round(): Argument #1 ($num) must be of type int|float (#1403) * TypeError: round(): Argument #1 ($num) must be of type int|float --- app/code/core/Mage/Core/Model/Store.php | 2 +- app/code/core/Mage/Paypal/Model/Payflowpro.php | 2 +- .../Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php | 2 +- .../core/Mage/Usa/Model/Shipping/Carrier/Dhl.php | 10 +++++----- .../Usa/Model/Shipping/Carrier/Dhl/International.php | 6 +++--- .../core/Mage/Usa/Model/Shipping/Carrier/Usps.php | 12 ++++++------ lib/Zend/Db/Profiler/Firebug.php | 2 +- lib/Zend/Locale/Format.php | 8 ++++---- lib/Zend/Locale/Math.php | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index 03686194ae2..e15efd48828 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -1001,7 +1001,7 @@ public function convertPrice($price, $format = false, $includeContainer = true) */ public function roundPrice($price) { - return round($price, 2); + return round((float)$price, 2); } /** diff --git a/app/code/core/Mage/Paypal/Model/Payflowpro.php b/app/code/core/Mage/Paypal/Model/Payflowpro.php index 87e1e0f980f..7db26cc805b 100644 --- a/app/code/core/Mage/Paypal/Model/Payflowpro.php +++ b/app/code/core/Mage/Paypal/Model/Payflowpro.php @@ -299,7 +299,7 @@ public function refund(Varien_Object $payment, $amount) $request = $this->_buildBasicRequest($payment); $request->setTrxtype(self::TRXTYPE_CREDIT); $request->setOrigid($payment->getParentTransactionId()); - $request->setAmt(round($amount,2)); + $request->setAmt(round((float)$amount,2)); $response = $this->_postRequest($request); $this->_processErrors($response); diff --git a/app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php b/app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php index c89cbe75429..e9961bc2a09 100644 --- a/app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php +++ b/app/code/core/Mage/Usa/Block/Adminhtml/Dhl/Unitofmeasure.php @@ -59,7 +59,7 @@ public function _construct() ); $weight = round( - Mage::helper('usa')->convertMeasureWeight( + (float) Mage::helper('usa')->convertMeasureWeight( $kgWeight, Zend_Measure_Weight::KILOGRAM, Zend_Measure_Weight::POUND), 3); $this->setDivideOrderWeightNoteLbp( diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php index 228f8a32e74..ab43bb35712 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php @@ -292,24 +292,24 @@ public function setRequest(Varien_Object $request) $packageParams = $request->getPackageParams(); $shippingWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != Zend_Measure_Weight::POUND) { - $shippingWeight = round(Mage::helper('usa')->convertMeasureWeight( + $shippingWeight = round((float) Mage::helper('usa')->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), Zend_Measure_Weight::POUND )); } if ($packageParams->getDimensionUnits() != Zend_Measure_Length::INCH) { - $packageParams->setLength(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->setLength(round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getLength(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH ))); - $packageParams->setWidth(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->setWidth(round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getWidth(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH ))); - $packageParams->setHeight(round(Mage::helper('usa')->convertMeasureDimension( + $packageParams->setHeight(round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getHeight(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH @@ -618,7 +618,7 @@ protected function _createShipmentXml($shipment, $shipKey) $apValue = ceil($apValue); break; case self::ADDITIONAL_PROTECTION_ROUNDING_ROUND: - $apValue = round($apValue); + $apValue = round((float) $apValue); break; default: case self::ADDITIONAL_PROTECTION_ROUNDING_FLOOR: diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php index d6e4b89853b..72f3a25c8c2 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl/International.php @@ -560,13 +560,13 @@ protected function _getWeight($weight, $maxWeight = false, $configWeightUnit = f if ($configWeightUnit != $countryWeightUnit) { $weight = Mage::helper('usa')->convertMeasureWeight( - round($weight,3), + round((float) $weight,3), $configWeightUnit, $countryWeightUnit ); } - return round($weight, 3); + return round((float) $weight, 3); } /** @@ -748,7 +748,7 @@ protected function _getDimension($dimension, $configWeightUnit = false) $countryDimensionUnit = $this->getCode('dimensions_variables', $this->_getDimensionUnit()); if ($configDimensionUnit != $countryDimensionUnit) { - $dimension = Mage::helper('usa')->convertMeasureDimension( + $dimension = (float) Mage::helper('usa')->convertMeasureDimension( round($dimension, 3), $configDimensionUnit, $countryDimensionUnit diff --git a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php index 1b774e5b743..cd3b474d9fa 100644 --- a/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php +++ b/app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php @@ -1357,7 +1357,7 @@ protected function _formUsExpressShipmentRequest(Varien_Object $request) $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != Zend_Measure_Weight::OUNCE) { - $packageWeight = round(Mage::helper('usa')->convertMeasureWeight( + $packageWeight = round((float) Mage::helper('usa')->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), Zend_Measure_Weight::OUNCE @@ -1449,7 +1449,7 @@ protected function _formUsSignatureConfirmationShipmentRequest(Varien_Object $re $packageParams = $request->getPackageParams(); $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != Zend_Measure_Weight::OUNCE) { - $packageWeight = round(Mage::helper('usa')->convertMeasureWeight( + $packageWeight = round((float) Mage::helper('usa')->convertMeasureWeight( $request->getPackageWeight(), $packageParams->getWeightUnits(), Zend_Measure_Weight::OUNCE @@ -1535,24 +1535,24 @@ protected function _formIntlShipmentRequest(Varien_Object $request) ); } if ($packageParams->getDimensionUnits() != Zend_Measure_Length::INCH) { - $length = round(Mage::helper('usa')->convertMeasureDimension( + $length = round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getLength(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH )); - $width = round(Mage::helper('usa')->convertMeasureDimension( + $width = round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getWidth(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH )); - $height = round(Mage::helper('usa')->convertMeasureDimension( + $height = round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getHeight(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH )); } if ($packageParams->getGirthDimensionUnits() != Zend_Measure_Length::INCH) { - $girth = round(Mage::helper('usa')->convertMeasureDimension( + $girth = round((float) Mage::helper('usa')->convertMeasureDimension( $packageParams->getGirth(), $packageParams->getGirthDimensionUnits(), Zend_Measure_Length::INCH diff --git a/lib/Zend/Db/Profiler/Firebug.php b/lib/Zend/Db/Profiler/Firebug.php index 94192c5a0fe..ef9cbdf5485 100644 --- a/lib/Zend/Db/Profiler/Firebug.php +++ b/lib/Zend/Db/Profiler/Firebug.php @@ -133,7 +133,7 @@ public function queryEnd($queryId) $this->_totalElapsedTime += $profile->getElapsedSecs(); - $this->_message->addRow(array((string)round($profile->getElapsedSecs(),5), + $this->_message->addRow(array((string)round((float) $profile->getElapsedSecs(),5), $profile->getQuery(), ($params=$profile->getQueryParams())?$params:null)); diff --git a/lib/Zend/Locale/Format.php b/lib/Zend/Locale/Format.php index 68959eb1558..ae9d59f16f0 100644 --- a/lib/Zend/Locale/Format.php +++ b/lib/Zend/Locale/Format.php @@ -311,7 +311,7 @@ public static function toNumber($value, array $options = array()) $symbols = Zend_Locale_Data::getList($options['locale'], 'symbols'); $oenc = self::_getEncoding(); self::_setEncoding('UTF-8'); - + // Get format $format = $options['number_format']; if ($format === null) { @@ -319,14 +319,14 @@ public static function toNumber($value, array $options = array()) $format = self::_seperateFormat($format, $value, $options['precision']); if ($options['precision'] !== null) { - $value = Zend_Locale_Math::normalize(Zend_Locale_Math::round($value, $options['precision'])); + $value = Zend_Locale_Math::normalize(Zend_Locale_Math::round((float) $value, $options['precision'])); } } else { // seperate negative format pattern when available $format = self::_seperateFormat($format, $value, $options['precision']); if (strpos($format, '.')) { if (is_numeric($options['precision'])) { - $value = Zend_Locale_Math::round($value, $options['precision']); + $value = Zend_Locale_Math::round((float) $value, $options['precision']); } else { if (substr($format, iconv_strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; @@ -338,7 +338,7 @@ public static function toNumber($value, array $options = array()) } } } else { - $value = Zend_Locale_Math::round($value, 0); + $value = Zend_Locale_Math::round((float) $value, 0); $options['precision'] = 0; } $value = Zend_Locale_Math::normalize($value); diff --git a/lib/Zend/Locale/Math.php b/lib/Zend/Locale/Math.php index 91e1905d8a6..080ab475e8b 100644 --- a/lib/Zend/Locale/Math.php +++ b/lib/Zend/Locale/Math.php @@ -65,9 +65,9 @@ public static function isBcmathDisabled() public static function round($op1, $precision = 0) { if (self::$_bcmathDisabled) { - $op1 = round($op1, $precision); + $op1 = round((float) $op1, $precision); if (strpos((string) $op1, 'E') === false) { - return self::normalize(round($op1, $precision)); + return self::normalize(round((float) $op1, $precision)); } }