Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast types, ref #735 #2872

Merged
merged 1 commit into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function _saveRelations(Mage_Core_Model_Abstract $user)

$adapter->delete($this->getTable('admin/role'), $conditions);
foreach ($rolesIds as $rid) {
$rid = intval($rid);
$rid = (int) $rid;
if ($rid > 0) {
$role = Mage::getModel('admin/role')->load($rid);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function _beforeSave()
$this->cleanPasswordsValidationData();

if (!is_null($this->getIsActive())) {
$data['is_active'] = intval($this->getIsActive());
$data['is_active'] = (int) $this->getIsActive();
}

$this->addData($data);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Api/Buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getSaveButtonHtml()

public function getDeleteButtonHtml()
{
if (intval($this->getRequest()->getParam('rid')) == 0) {
if ((int) $this->getRequest()->getParam('rid') == 0) {
return;
}
return $this->getChildHtml('deleteButton');
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Api/Editroles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _beforeToHtml()
'content' => $this->getLayout()->createBlock('adminhtml/api_tab_rolesedit')->toHtml(),
]);

if (intval($roleId) > 0) {
if ((int) $roleId > 0) {
$this->addTab('roles', [
'label' => Mage::helper('adminhtml')->__('Role Users'),
'title' => Mage::helper('adminhtml')->__('Role Users'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ protected function _prepareForm()

protected function _getSetId()
{
return (intval($this->getRequest()->getParam('id')) > 0)
? intval($this->getRequest()->getParam('id'))
return ((int) $this->getRequest()->getParam('id') > 0)
? (int) $this->getRequest()->getParam('id')
: Mage::getModel('eav/entity_type')
->load(Mage::registry('entityType'))
->getDefaultAttributeSetId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getFieldSuffix()
public function getStoreId()
{
$storeId = $this->getRequest()->getParam('store');
return intval($storeId);
return (int) $storeId;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Permissions/Buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getSaveButtonHtml()

public function getDeleteButtonHtml()
{
if (intval($this->getRequest()->getParam('rid')) == 0) {
if ((int) $this->getRequest()->getParam('rid') == 0) {
return;
}
return $this->getChildHtml('deleteButton');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function render(Varien_Object $row)
return $data;
}

$data = floatval($data) * $this->_getRate($row);
$data = (float) $data * $this->_getRate($row);
$data = sprintf("%F", $data);
$data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data);
return $data;
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Review/Rating/Detailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public function getRating()
->setPositionOrder()
->load()
->addOptionToItems();
if (intval($this->getRequest()->getParam('id'))) {
if ((int) $this->getRequest()->getParam('id')) {
$this->_voteCollection = Mage::getModel('rating/rating_option_vote')
->getResourceCollection()
->setReviewFilter(intval($this->getRequest()->getParam('id')))
->setReviewFilter((int) $this->getRequest()->getParam('id'))
->addOptionInfo()
->load()
->addRatingOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function displayPriceInclTax(Varien_Object $item)
$basePriceTax = 0;
$priceTax = 0;

if (floatval($qty)) {
if ((float) $qty) {
$basePriceTax = $item->getBasePrice() + $baseTax / $qty;
$priceTax = $item->getPrice() + $tax / $qty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class Mage_Adminhtml_Block_System_Config_Form_Field_Datetime extends Mage_Adminh
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
return Mage::app()->getLocale()->date(intval($element->getValue()))->toString($format);
return Mage::app()->getLocale()->date((int) $element->getValue())->toString($format);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->setValue(Mage::app()->loadCache('admin_notifications_lastcheck'));
$format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
return Mage::app()->getLocale()->date(intval($element->getValue()))->toString($format);
return Mage::app()->getLocale()->date((int) $element->getValue())->toString($format);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_Adminhtml_Block_Tax_Rate_Grid_Renderer_Data extends Mage_Adminhtml_Bl
protected function _getValue(Varien_Object $row)
{
$data = parent::_getValue($row);
if (intval($data) == $data) {
if ((int) $data == $data) {
return (string) number_format($data, 2);
}
if (!is_null($data)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getSaveButtonHtml()
*/
public function getDeleteButtonHtml()
{
if (intval($this->getRequest()->getParam('rate')) == 0) {
if ((int) $this->getRequest()->getParam('rate') == 0) {
return;
}
return $this->getChildHtml('deleteButton');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function render(Varien_Object $row)
return $data;
}

$data = floatval($data) * $this->_getRate($row);
$data = (float) $data * $this->_getRate($row);
$sign = (bool)(int)$this->getColumn()->getShowNumberSign() && ($data > 0) ? '+' : '';
$data = sprintf("%F", $data);
$data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data);
Expand Down Expand Up @@ -85,10 +85,10 @@ protected function _getCurrencyCode($row)
protected function _getRate($row)
{
if ($rate = $this->getColumn()->getRate()) {
return floatval($rate);
return (float) $rate;
}
if ($rate = $row->getData($this->getColumn()->getRateField())) {
return floatval($rate);
return (float) $rate;
}
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function render(Varien_Object $row)
return $data;
}

$data = floatval($data) * $this->_getRate($row);
$data = (float) $data * $this->_getRate($row);
$data = sprintf("%F", $data);
$data = Mage::app()->getLocale()->currency($currency_code)->toCurrency($data);
return $data;
Expand Down Expand Up @@ -83,10 +83,10 @@ protected function _getCurrencyCode($row)
protected function _getRate($row)
{
if ($rate = $this->getColumn()->getRate()) {
return floatval($rate);
return (float) $rate;
}
if ($rate = $row->getData($this->getColumn()->getRateField())) {
return floatval($rate);
return (float) $rate;
}
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$regionCollection = self::$_regionCollections[$countryId];
}

$regionId = intval($element->getForm()->getElement('region_id')->getValue());
$regionId = (int) $element->getForm()->getElement('region_id')->getValue();

$htmlAttributes = $element->getHtmlAttributes();
foreach ($htmlAttributes as $key => $attribute) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected function _getCurrencyBase()
$this->getScopeId()
);
}
return strval($value);
return (string) $value;
}

/**
Expand All @@ -84,6 +84,6 @@ protected function _getCurrencyDefault()
$this->getScopeId()
);
}
return strval($value);
return (string) $value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ protected function _afterSave()
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;

$cronExprArray = [
intval($time[1]), # Minute
intval($time[0]), # Hour
(int) $time[1], # Minute
(int) $time[0], # Hour
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ protected function _afterSave()

if ($enabled) {
$cronExprArray = [
intval($time[1]), # Minute
intval($time[0]), # Hour
(int) $time[1], # Minute
(int) $time[0], # Hour
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function _afterSave()
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;

$cronExprArray = [
intval($time[1]), # Minute
intval($time[0]), # Hour
(int) $time[1], # Minute
(int) $time[0], # Hour
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function _afterSave()
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;

$cronExprArray = [
intval($time[1]), # Minute
intval($time[0]), # Hour
(int) $time[1], # Minute
(int) $time[0], # Hour
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function editRoleAction()
$this->_initAction();

$roleId = $this->getRequest()->getParam('rid');
if (intval($roleId) > 0) {
if ((int) $roleId > 0) {
$breadCrumb = $this->__('Edit Role');
$breadCrumbTitle = $this->__('Edit Role');
$this->_title($this->__('Edit Role'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function jsonProductInfoAction()
{
$response = new Varien_Object();
$id = $this->getRequest()->getParam('id');
if (intval($id) > 0) {
if ((int) $id > 0) {
$product = Mage::getModel('catalog/product')
->load($id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function validateAction()
$_titles[] = $answer['title'];

$answerModel = Mage::getModel('poll/poll_answer');
if (intval($key) > 0) {
if ((int) $key > 0) {
$answerModel->setId($key);
}
$answerModel->setAnswerTitle($answer['title'])
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Resource/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object)
*/
public function load(Mage_Core_Model_Abstract $object, $value, $field = null)
{
if (!intval($value) && is_string($value)) {
if (!(int) $value && is_string($value)) {
$field = 'role_id';
}
return parent::load($object, $value, $field);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function _saveRelations(Mage_Core_Model_Abstract $user)
['user_id = ?' => (int) $user->getId()]
);
foreach ($rolesIds as $rid) {
$rid = intval($rid);
$rid = (int) $rid;
if ($rid > 0) {
//$row = $this->load($user, $rid);
$row = ['tree_level' => 0];
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Api/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function save()
}

if (!is_null($this->getIsActive())) {
$data['is_active'] = intval($this->getIsActive());
$data['is_active'] = (int) $this->getIsActive();
}

$this->setData($data);
Expand Down
50 changes: 25 additions & 25 deletions app/code/core/Mage/Authorizenet/Model/Directpost/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,37 +129,37 @@ public function setDataFromOrder(Mage_Sales_Model_Order $order, Mage_Authorizene
//need to use strval() because NULL values IE6-8 decodes as "null" in JSON in JavaScript, but we need "" for null values.
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$this->setXFirstName(strval($billing->getFirstname()))
->setXLastName(strval($billing->getLastname()))
->setXCompany(strval($billing->getCompany()))
->setXAddress(strval($billing->getStreet(1)))
->setXCity(strval($billing->getCity()))
->setXState(strval($billing->getRegion()))
->setXZip(strval($billing->getPostcode()))
->setXCountry(strval($billing->getCountry()))
->setXPhone(strval($billing->getTelephone()))
->setXFax(strval($billing->getFax()))
->setXCustId(strval($billing->getCustomerId()))
->setXCustomerIp(strval($order->getRemoteIp()))
->setXCustomerTaxId(strval($billing->getTaxId()))
->setXEmail(strval($order->getCustomerEmail()))
->setXEmailCustomer(strval($paymentMethod->getConfigData('email_customer')))
->setXMerchantEmail(strval($paymentMethod->getConfigData('merchant_email')));
$this->setXFirstName((string) $billing->getFirstname())
->setXLastName((string) $billing->getLastname())
->setXCompany((string) $billing->getCompany())
->setXAddress((string) $billing->getStreet(1))
->setXCity((string) $billing->getCity())
->setXState((string) $billing->getRegion())
->setXZip((string) $billing->getPostcode())
->setXCountry((string) $billing->getCountry())
->setXPhone((string) $billing->getTelephone())
->setXFax((string) $billing->getFax())
->setXCustId((string) $billing->getCustomerId())
->setXCustomerIp((string) $order->getRemoteIp())
->setXCustomerTaxId((string) $billing->getTaxId())
->setXEmail((string) $order->getCustomerEmail())
->setXEmailCustomer((string) $paymentMethod->getConfigData('email_customer'))
->setXMerchantEmail((string) $paymentMethod->getConfigData('merchant_email'));
}

$shipping = $order->getShippingAddress();
if (!empty($shipping)) {
$this->setXShipToFirstName(strval($shipping->getFirstname()))
->setXShipToLastName(strval($shipping->getLastname()))
->setXShipToCompany(strval($shipping->getCompany()))
->setXShipToAddress(strval($shipping->getStreet(1)))
->setXShipToCity(strval($shipping->getCity()))
->setXShipToState(strval($shipping->getRegion()))
->setXShipToZip(strval($shipping->getPostcode()))
->setXShipToCountry(strval($shipping->getCountry()));
$this->setXShipToFirstName((string) $shipping->getFirstname())
->setXShipToLastName((string) $shipping->getLastname())
->setXShipToCompany((string) $shipping->getCompany())
->setXShipToAddress((string) $shipping->getStreet(1))
->setXShipToCity((string) $shipping->getCity())
->setXShipToState((string) $shipping->getRegion())
->setXShipToZip((string) $shipping->getPostcode())
->setXShipToCountry((string) $shipping->getCountry());
}

$this->setXPoNum(strval($payment->getPoNumber()));
$this->setXPoNum((string) $payment->getPoNumber());

return $this;
}
Expand Down
Loading