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 instead of function #735

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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 @@ -249,7 +249,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) {
$row = Mage::getModel('admin/role')->load($rid)->getData();
} 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 @@ -154,7 +154,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 @@ -96,7 +96,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 @@ -52,7 +52,7 @@ protected function _beforeToHtml()
'content' => $this->getLayout()->createBlock('adminhtml/api_tab_rolesedit')->toHtml(),
));

if( intval($roleId) > 0 ) {
if( (int)$roleId > 0 ) {
$this->addTab('roles', array(
'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 @@ -79,8 +79,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 @@ -63,7 +63,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/Notification/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Mage_Adminhtml_Block_Notification_Survey extends Mage_Adminhtml_Block_Temp
public function canShow()
{
$adminSession = Mage::getSingleton('admin/session');
$seconds = intval(date('s', time()));
$seconds = (int)date('s', time());
if ($adminSession->getHideSurveyQuestion() || !$adminSession->isAllowed('all')
|| Mage_AdminNotification_Model_Survey::isSurveyViewed()
|| !Mage_AdminNotification_Model_Survey::isSurveyUrlValid())
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 @@ -95,7 +95,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 @@ -50,7 +50,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 @@ -87,10 +87,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 @@ -359,7 +359,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 @@ -37,6 +37,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 @@ -38,6 +38,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 @@ -37,7 +37,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 @@ -103,7 +103,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 @@ -57,7 +57,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 @@ -92,10 +92,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 @@ -55,7 +55,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 @@ -89,10 +89,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 @@ -64,7 +64,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 @@ -73,7 +73,7 @@ protected function _getCurrencyBase()
$this->getScopeId()
);
}
return strval($value);
return (string)$value;
}

/**
Expand All @@ -90,6 +90,6 @@ protected function _getCurrencyDefault()
$this->getScopeId()
);
}
return strval($value);
return (string)$value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ protected function _afterSave()
$cronDayOfWeek = date('N');

$cronExprArray = array(
intval($time[1]), # Minute
intval($time[0]), # Hour
($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
(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
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protected function _afterSave()
if ($enabled) {
$cronDayOfWeek = date('N');
$cronExprArray = array(
intval($time[1]), # Minute
intval($time[0]), # Hour
(int)$time[1], # Minute
(int)$time[0], # Hour
($frequncy == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequncy == $frequencyWeekly) ? '1' : '*', # Day of the Week
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ protected function _afterSave()
$cronDayOfWeek = date('N');

$cronExprArray = array(
intval($time[1]), # Minute
intval($time[0]), # Hour
(int)$time[1], # Minute
(int)$time[0], # Hour
($frequncy == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequncy == $frequencyWeekly) ? '1' : '*', # Day of the Week
($frequncy == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ protected function _afterSave()
$cronDayOfWeek = date('N');

$cronExprArray = array(
intval($time[1]), # Minute
intval($time[0]), # Hour
(int)$time[1], # Minute
(int)$time[0], # Hour
($frequncy == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
($frequncy == $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 @@ -291,7 +291,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 @@ -68,7 +68,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 @@ -278,7 +278,7 @@ public function _saveRelations(Mage_Core_Model_Abstract $user)
$this->getTable('api/role'),
array('user_id = ?' => (int) $user->getId()));
foreach ($rolesIds as $rid) {
$rid = intval($rid);
$rid = (int)$rid;
if ($rid > 0) {
//$row = $this->load($user, $rid);
} else {
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 @@ -103,7 +103,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 @@ -134,37 +134,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
4 changes: 2 additions & 2 deletions app/code/core/Mage/Backup/Model/Config/Backend/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ protected function _afterSave()

if ($enabled) {
$cronExprArray = array(
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
Loading