Skip to content

Commit

Permalink
TypeError: round(): Argument #1 ($num) must be of type int|float (Ope…
Browse files Browse the repository at this point in the history
…nMage#1403)

* TypeError: round(): Argument #1 ($num) must be of type int|float
  • Loading branch information
Flyingmana committed Jan 19, 2021
1 parent 62d9431 commit 5580c34
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Paypal/Model/Payflowpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions app/code/core/Mage/Usa/Model/Shipping/Carrier/Dhl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Db/Profiler/Firebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
8 changes: 4 additions & 4 deletions lib/Zend/Locale/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,22 @@ 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) {
$format = Zend_Locale_Data::getContent($options['locale'], 'decimalnumber');
$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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/Zend/Locale/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 5580c34

Please sign in to comment.