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

change all ands in conditional statements to && for better consistency #970

Merged
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/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public static function setRoot($appRoot = '')

$appRoot = realpath($appRoot);

if (is_dir($appRoot) and is_readable($appRoot)) {
if (is_dir($appRoot) && is_readable($appRoot)) {
self::$_appRoot = $appRoot;
} else {
self::throwException($appRoot . ' is not a directory or not readable by this user');
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Catalog/Model/Product/Option/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Mage_Catalog_Model_Product_Option_Api extends Mage_Catalog_Model_Api_Resou
public function add($productId, $data, $store = null)
{
$product = $this->_getProduct($productId, $store, null);
if (!(is_array($data['additional_fields']) and count($data['additional_fields']))) {
if (!(is_array($data['additional_fields']) && count($data['additional_fields']))) {
$this->_fault('invalid_data');
}
if (!$this->_isTypeAllowed($data['type'])) {
Expand Down Expand Up @@ -76,7 +76,7 @@ public function update($optionId, $data, $store = null)
}
$product = $this->_getProduct($option->getProductId(), $store, null);
$option = $product->getOptionById($optionId);
if (isset($data['type']) and !$this->_isTypeAllowed($data['type'])) {
if (isset($data['type']) && !$this->_isTypeAllowed($data['type'])) {
$this->_fault('invalid_type');
}
if (isset($data['additional_fields'])) {
Expand Down Expand Up @@ -109,7 +109,7 @@ protected function _prepareAdditionalFields(&$data, $groupType)
// reset can be used as there should be the only
// element in 'additional_fields' for options of all types except those from Select group
$field = reset($data['additional_fields']);
if (!(is_array($field) and count($field))) {
if (!(is_array($field) && count($field))) {
$this->_fault('invalid_data');
} else {
foreach ($field as $key => $value) {
Expand All @@ -119,7 +119,7 @@ protected function _prepareAdditionalFields(&$data, $groupType)
} else {
// convert Select rows array to appropriate format for saving in the model
foreach ($data['additional_fields'] as $row) {
if (!(is_array($row) and count($row))) {
if (!(is_array($row) && count($row))) {
$this->_fault('invalid_data');
} else {
foreach ($row as $key => $value) {
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 @@ -212,7 +212,7 @@ public function escapeHtml($data, $allowedTags = null)
} else {
// process single item
if (strlen($data)) {
if (is_array($allowedTags) and !empty($allowedTags)) {
if (is_array($allowedTags) && !empty($allowedTags)) {
$allowed = implode('|', $allowedTags);
$result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data);
$result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8', false);
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ public function getEscapedCSVData(array $data)
$value = (string)$value;

$firstLetter = substr($value, 0, 1);
if ($firstLetter !== false and in_array($firstLetter, array("=", "+", "-"))) {
if ($firstLetter !== false && in_array($firstLetter, array("=", "+", "-"))) {
$data[$key] = ' ' . $value;
}
}
Expand All @@ -958,7 +958,7 @@ public function getEscapedCSVData(array $data)
*/
public function unEscapeCSVData($data)
{
if (is_array($data) and Mage::getStoreConfigFlag(Mage_ImportExport_Model_Export_Adapter_Csv::CONFIG_ESCAPING_FLAG)) {
if (is_array($data) && Mage::getStoreConfigFlag(Mage_ImportExport_Model_Export_Adapter_Csv::CONFIG_ESCAPING_FLAG)) {

foreach ($data as $key => $value) {
$value = (string)$value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function validate(Varien_Object $object)
$valid = parent::validate($object);
if (!$valid && $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
$children = $object->getChildren();
if (is_array($children) and isset($children[0])) {
if (is_array($children) && isset($children[0])) {
$child = $children[0];

/** @var Mage_Catalog_Model_Product $childProduct */
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sendfriend/Model/Sendfriend.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ protected function _sentCountByCookies($increment = false)
$oldTimes = explode(',', $oldTimes);
foreach ($oldTimes as $oldTime) {
$periodTime = $time - $this->_getHelper()->getPeriod();
if (is_numeric($oldTime) AND $oldTime >= $periodTime) {
if (is_numeric($oldTime) && $oldTime >= $periodTime) {
$newTimes[] = $oldTime;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/XmlConnect/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ static public function arrayMergeRecursive($target, $changes)
$changes = array($changes);
}
foreach ($changes as $key => $value) {
if (!array_key_exists($key, $target) and !is_numeric($key)) {
if (!array_key_exists($key, $target) && !is_numeric($key)) {
$target[$key] = $changes[$key];
continue;
}
Expand Down
38 changes: 19 additions & 19 deletions app/code/core/Zend/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Zend_Date extends Zend_Date_DateObject
*/
public function __construct($date = null, $part = null, $locale = null)
{
if (is_object($date) and !($date instanceof Zend_TimeSync_Protocol) and
if (is_object($date) && !($date instanceof Zend_TimeSync_Protocol) &&
!($date instanceof Zend_Date)) {
if ($locale instanceof Zend_Locale) {
$locale = $date;
Expand All @@ -160,12 +160,12 @@ public function __construct($date = null, $part = null, $locale = null)
}
}

if (($date !== null) and !is_array($date) and !($date instanceof Zend_TimeSync_Protocol) and
!($date instanceof Zend_Date) and !defined($date) and Zend_Locale::isLocale($date, true, false)) {
if (($date !== null) && !is_array($date) && !($date instanceof Zend_TimeSync_Protocol) &&
!($date instanceof Zend_Date) && !defined($date) && Zend_Locale::isLocale($date, true, false)) {
$locale = $date;
$date = null;
$part = null;
} else if (($part !== null) and !defined($part) and Zend_Locale::isLocale($part, true, false)) {
} else if (($part !== null) && !defined($part) && Zend_Locale::isLocale($part, true, false)) {
$locale = $part;
$part = null;
}
Expand Down Expand Up @@ -460,7 +460,7 @@ public function toString($format = null, $type = null, $locale = null)
$format = null;
}

if (($type !== null) and ($type != 'php') and ($type != 'iso') and
if (($type !== null) && ($type != 'php') && ($type != 'iso') &&
Zend_Locale::isLocale($type, null, false)) {
$locale = $type;
$type = null;
Expand Down Expand Up @@ -1214,7 +1214,7 @@ public function getTimezoneFromString($zone)
}

preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
if (!empty($match) and ($match[count($match) - 1] <= 14) and ($match[count($match) - 1] >= -12)) {
if (!empty($match) && ($match[count($match) - 1] <= 14) && ($match[count($match) - 1] >= -12)) {
$zone = "Etc/GMT";
$zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
$zone .= (int) abs($match[count($match) - 1]);
Expand All @@ -1223,7 +1223,7 @@ public function getTimezoneFromString($zone)

preg_match('/([[:alpha:]\/_]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
try {
if (!empty($match) and (!is_int($match[count($match) - 1]))) {
if (!empty($match) && (!is_int($match[count($match) - 1]))) {
$oldzone = $this->getTimezone();
$this->setTimezone($match[count($match) - 1]);
$result = $this->getTimezone();
Expand Down Expand Up @@ -1273,7 +1273,7 @@ private function _assign($calc, $date, $comp = 0, $dst = false)
}

// dst-correction if 'fix_dst' = true and dst !== false but only for non UTC and non GMT
if ((self::$_options['fix_dst'] === true) and ($dst !== false) and ($this->_dst === true)) {
if ((self::$_options['fix_dst'] === true) && ($dst !== false) && ($this->_dst === true)) {
$hour = $this->toString(self::HOUR, 'iso');
if ($hour != $dst) {
if (($dst == ($hour + 1)) or ($dst == ($hour - 23))) {
Expand Down Expand Up @@ -1528,7 +1528,7 @@ private function _calculate($calc, $date, $part, $locale)

case self::WEEKDAY_8601:
$weekday = (int) $this->toString(self::WEEKDAY_8601, 'iso', $locale);
if ((intval($date) > 0) and (intval($date) < 8)) {
if ((intval($date) > 0) && (intval($date) < 8)) {
return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
$this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
}
Expand All @@ -1545,7 +1545,7 @@ private function _calculate($calc, $date, $part, $locale)

case self::WEEKDAY_DIGIT:
$weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
if (is_numeric($date) and (intval($date) >= 0) and (intval($date) < 7)) {
if (is_numeric($date) && (intval($date) >= 0) && (intval($date) < 7)) {
return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $date, 1970, true),
$this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
}
Expand Down Expand Up @@ -2084,7 +2084,7 @@ private function _calculate($calc, $date, $part, $locale)
if (empty($timematch)) {
preg_match('/[T,\s]{0,1}(\d{2})(\d{2})(\d{2})/', $tmpdate, $timematch);
}
if (empty($datematch) and empty($timematch)) {
if (empty($datematch) && empty($timematch)) {
#require_once 'Zend/Date/Exception.php';
throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
}
Expand Down Expand Up @@ -2644,7 +2644,7 @@ private function _calculate($calc, $date, $part, $locale)
}

$parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
if ((strpos(strtoupper($part), 'YY') !== false) and (strpos(strtoupper($part), 'YYYY') === false)) {
if ((strpos(strtoupper($part), 'YY') !== false) && (strpos(strtoupper($part), 'YYYY') === false)) {
$parsed['year'] = self::getFullYear($parsed['year']);
}

Expand Down Expand Up @@ -2974,7 +2974,7 @@ private function _date($calc, $date, $format, $locale)
}

$parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
if ((strpos(strtoupper($format), 'YY') !== false) and (strpos(strtoupper($format), 'YYYY') === false)) {
if ((strpos(strtoupper($format), 'YY') !== false) && (strpos(strtoupper($format), 'YYYY') === false)) {
$parsed['year'] = self::getFullYear($parsed['year']);
}
} catch (Zend_Locale_Exception $e) {
Expand Down Expand Up @@ -4800,34 +4800,34 @@ public static function isDate($date, $format = null, $locale = null)
$parsed = $date;
}

if (((strpos($format, 'Y') !== false) or (strpos($format, 'y') !== false)) and
if (((strpos($format, 'Y') !== false) or (strpos($format, 'y') !== false)) &&
(!isset($parsed['year']))) {
// Year expected but not found
return false;
}

if ((strpos($format, 'M') !== false) and (!isset($parsed['month']))) {
if ((strpos($format, 'M') !== false) && (!isset($parsed['month']))) {
// Month expected but not found
return false;
}

if ((strpos($format, 'd') !== false) and (!isset($parsed['day']))) {
if ((strpos($format, 'd') !== false) && (!isset($parsed['day']))) {
// Day expected but not found
return false;
}

if (((strpos($format, 'H') !== false) or (strpos($format, 'h') !== false)) and
if (((strpos($format, 'H') !== false) or (strpos($format, 'h') !== false)) &&
(!isset($parsed['hour']))) {
// Hour expected but not found
return false;
}

if ((strpos($format, 'm') !== false) and (!isset($parsed['minute']))) {
if ((strpos($format, 'm') !== false) && (!isset($parsed['minute']))) {
// Minute expected but not found
return false;
}

if ((strpos($format, 's') !== false) and (!isset($parsed['second']))) {
if ((strpos($format, 's') !== false) && (!isset($parsed['second']))) {
// Second expected but not found
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Zend/Validate/File/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function isValid($value, $file = null)
protected function _throw($file, $errorType)
{
if ($file !== null) {
if (is_array($file) and !empty($file['name'])) {
if (is_array($file) && !empty($file['name'])) {
$this->_value = $file['name'];
}
}
Expand Down