Skip to content

Commit

Permalink
Revert "Added SimplifyDeMorganBinaryRector rule"
Browse files Browse the repository at this point in the history
This reverts commit 4fe6c68.
  • Loading branch information
sreichel committed Aug 12, 2024
1 parent 4fe6c68 commit 392d0a8
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function isScopeGlobal()
*/
public function isShowWebsiteColumn()
{
return !$this->isScopeGlobal() && !Mage::app()->isSingleStoreMode();
return !($this->isScopeGlobal() || Mage::app()->isSingleStoreMode());
}

/**
Expand All @@ -319,6 +319,6 @@ public function isShowWebsiteColumn()
*/
public function isAllowChangeWebsite()
{
return $this->isShowWebsiteColumn() && !$this->getProduct()->getStoreId();
return !(!$this->isShowWebsiteColumn() || $this->getProduct()->getStoreId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,6 @@ public function canShipPartiallyItem($order = null)

public function isShipmentRegular()
{
return $this->canShipPartiallyItem() && $this->canShipPartially();
return !(!$this->canShipPartiallyItem() || !$this->canShipPartially());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ protected function _prepareForm()

$useDefault = false;
if ($this->getVariable()->getId() && $this->getVariable()->getStoreId()) {
$useDefault = !(bool)$this->getVariable()->getStoreHtmlValue() && !(bool)$this->getVariable()->getStorePlainValue();
$useDefault = !(
(bool)$this->getVariable()->getStoreHtmlValue()
|| (bool)$this->getVariable()->getStorePlainValue()
);
$this->getVariable()->setUseDefaultValue((int)$useDefault);
$fieldset->addField('use_default_value', 'select', [
'name' => 'use_default_value',
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Adminhtml/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ protected function _validateSecretKey()
if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) {
return true;
}
return ($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null)) && hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey);
return !(!($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null))
|| !hash_equals(Mage::getSingleton('adminhtml/url')->getSecretKey(), $secretKey));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function _beforeSave()
$value = $this->getValue();
if ($value < 0 || $value > 1) {
throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.'));
} elseif (($value == 0) && ($value !== '0' && $value !== '0.0')) {
} elseif (($value == 0) && !($value === '0' || $value === '0.0')) {
throw new Exception(Mage::helper('sitemap')->__('The priority must be between 0 and 1.'));
}
return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getOptions()
public function hasOptions()
{
$this->getOptions();
return !empty($this->_options) && $this->getProduct()->isSalable();
return !(empty($this->_options) || !$this->getProduct()->isSalable());
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Catalog/Model/Api/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ protected function _isAllowedAttribute($attribute, $attributes = null)
}

if (is_array($attributes)
&& (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes))
&& !(in_array($attribute->getAttributeCode(), $attributes)
|| in_array($attribute->getAttributeId(), $attributes))
) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ protected function _isAllowedAttribute($attribute, $attributes = null)
{
$isAllowed = true;
if (is_array($attributes)
&& (!in_array($attribute->getAttributeCode(), $attributes) && !in_array($attribute->getAttributeId(), $attributes))
&& !(in_array($attribute->getAttributeCode(), $attributes)
|| in_array($attribute->getAttributeId(), $attributes))
) {
$isAllowed = false;
}
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Checkout/Block/Onepage/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected function _construct()
*/
public function isUseBillingAddressForShipping()
{
return !$this->getQuote()->getIsVirtual() && $this->getQuote()->getShippingAddress()->getSameAsBilling();
return !(($this->getQuote()->getIsVirtual())
|| !$this->getQuote()->getShippingAddress()->getSameAsBilling());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Model/Api/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function _getQuote($quoteId, $store = null)
/** @var Mage_Sales_Model_Quote $quote */
$quote = Mage::getModel("sales/quote");

if (!is_string($store) && !is_int($store)) {
if (!(is_string($store) || is_int($store))) {
$quote->loadByIdWithoutStore($quoteId);
} else {
$storeId = $this->_getStoreId($store);
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function _preparePaymentData($data)
*/
protected function _canUsePaymentMethod($method, $quote)
{
if (!$method->isGateway() && !$method->canUseInternal()) {
if (!($method->isGateway() || $method->canUseInternal())) {
return false;
}

Expand All @@ -59,7 +59,7 @@ protected function _canUsePaymentMethod($method, $quote)
$total = $quote->getBaseGrandTotal();
$minTotal = $method->getConfigData('min_order_total');
$maxTotal = $method->getConfigData('max_order_total');
return !(!empty($minTotal) && ($total < $minTotal)) && !(!empty($maxTotal) && ($total > $maxTotal));
return !((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Checkout/Model/Type/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function initCheckout()
$customerSession = $this->getCustomerSession();
if (is_array($checkout->getStepData())) {
foreach ($checkout->getStepData() as $step => $data) {
if ($step !== 'login' && !($customerSession->isLoggedIn() && $step === 'billing')) {
if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) {
$checkout->setStepData($step, 'allow', false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function isModuleEnabled($moduleName = null)
}

$isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active');
return $isActive && in_array((string)$isActive, ['true', '1']);
return !(!$isActive || !in_array((string)$isActive, ['true', '1']));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ public function getCacheBetaTypes()
*/
public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'global')
{
if (!is_array($source) && !$source instanceof Varien_Object
|| !is_array($target) && !$target instanceof Varien_Object
if (!(is_array($source) || $source instanceof Varien_Object)
|| !(is_array($target) || $target instanceof Varien_Object)
) {
return false;
}
Expand Down Expand Up @@ -525,7 +525,7 @@ public function copyFieldset($fieldset, $aspect, $source, $target, $root = 'glob
public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false)
{
// check if array or an object to be iterated given
if (!is_array($array) && !is_object($array)) {
if (!(is_array($array) || is_object($array))) {
return $array;
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function parseQueryStr($str)
*/
protected function _validateQueryStr($str)
{
return $str && str_contains($str, '=');
return !(!$str || !str_contains($str, '='));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Customer/Model/Api/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Mage_Customer_Model_Api_Resource extends Mage_Api_Model_Resource_Abstract
protected function _isAllowedAttribute($attribute, ?array $filter = null)
{
if (!is_null($filter)
&& (!in_array($attribute->getAttributeCode(), $filter) && !in_array($attribute->getAttributeId(), $filter))
&& !(in_array($attribute->getAttributeCode(), $filter)
|| in_array($attribute->getAttributeId(), $filter))
) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Eav/Model/Entity/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public function walkAttributes($partMethod, array $args = [])
*/
protected function _isCallableAttributeInstance($instance, $method, $args)
{
return is_object($instance) && method_exists($instance, $method);
return !(!is_object($instance) || !method_exists($instance, $method));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Paypal/Model/Express/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ protected function _setBillingAgreementRequest()
$isRequested = $this->_isBARequested || $this->_quote->getPayment()
->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);

if ($this->_config->allow_ba_signup != Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO && !($isRequested && $this->_config->shouldAskToCreateBillingAgreement())
if (!($this->_config->allow_ba_signup == Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO
|| $isRequested && $this->_config->shouldAskToCreateBillingAgreement())
) {
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sales/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ public function canVoidPayment()
*/
protected function _canVoidOrder()
{
return !$this->canUnhold() && !$this->isPaymentReview();
return !($this->canUnhold() || $this->isPaymentReview());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function canVoidAuthorizationCompletely()
{
try {
$authTransaction = $this->closeAuthorization('', true);
return !$authTransaction->hasChildTransaction() && !$this->_children;
return !($authTransaction->hasChildTransaction() || $this->_children);
} catch (Mage_Core_Exception $e) {
// jam all logical exceptions, fallback to false
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/File/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private function _createDestinationFolder($destinationFolder)
$destinationFolder = substr($destinationFolder, 0, -1);
}

if (!@is_dir($destinationFolder) && !@mkdir($destinationFolder, 0777, true)) {
if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true))) {
throw new Exception("Unable to create directory '{$destinationFolder}'.");
}
return $this;
Expand Down
2 changes: 0 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\Config\RectorConfig;

Expand All @@ -17,6 +16,5 @@
])
->withSkipPath(__DIR__ . '/vendor')
->withRules([
SimplifyDeMorganBinaryRector::class,
SimplifyIfReturnBoolRector::class
]);

0 comments on commit 392d0a8

Please sign in to comment.