Skip to content

Commit

Permalink
Merge pull request #1755 from magento-eqp/MM-2551-EQP-Sniffs-To-Magento
Browse files Browse the repository at this point in the history
[Kraken] Move EQP static tests to Magento core
  • Loading branch information
cpartica authored Dec 4, 2017
2 parents 4067591 + 704f3d1 commit f93b914
Show file tree
Hide file tree
Showing 63 changed files with 412 additions and 69 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function addTab($tabId, $tab)
*/
protected function _addTabByName($tab, $tabId)
{
if (strpos($tab, '\Block\\')) {
if (strpos($tab, '\Block\\') !== false) {
$this->_tabs[$tabId] = $this->getLayout()->createBlock($tab, $this->getNameInLayout() . '_tab_' . $tabId);
} elseif ($this->getChildBlock($tab)) {
$this->_tabs[$tabId] = $this->getChildBlock($tab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ protected function parseOption($values)
$option = [];
foreach ($values as $keyValue) {
$keyValue = trim($keyValue);
if ($pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR)) {
$pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR);
if ($pos !== false) {
$key = substr($keyValue, 0, $pos);
$value = substr($keyValue, $pos + 1);
if ($key == 'type') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getOptionText($value)
$value = '0';
}
$isMultiple = false;
if (strpos($value, ',')) {
if (strpos($value, ',') !== false) {
$isMultiple = true;
$value = explode(',', $value);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Deploy/Service/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function hasMinVersion($filePath)
}

$info = pathinfo($filePath);
if (strpos($filePath, '.min.') === true) {
if (strpos($filePath, '.min.') !== false) {
$this->excludedCache[] = str_replace(".min.{$info['extension']}", ".{$info['extension']}", $filePath);
} else {
$pathToMinVersion = $info['dirname'] . '/' . $info['filename'] . '.min.' . $info['extension'];
Expand Down Expand Up @@ -216,7 +216,7 @@ private function isExcluded($filePath, $area, $theme)
*/
private function prepareExcludePath($path)
{
if (strpos($path, Repository::FILE_ID_SEPARATOR) > 0) {
if (strpos($path, Repository::FILE_ID_SEPARATOR) !== false) {
list($excludedModule, $excludedPath) = explode(Repository::FILE_ID_SEPARATOR, $path);
if ($excludedModule == 'Lib') {
return $excludedPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ protected function parseLinkOption(array $values)
$option = [];
foreach ($values as $keyValue) {
$keyValue = trim($keyValue);
if ($pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR)) {
$pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR);
if ($pos !== false) {
$key = substr($keyValue, 0, $pos);
$value = substr($keyValue, $pos + 1);
if ($key == 'sample') {
Expand Down Expand Up @@ -810,7 +811,8 @@ protected function parseSampleOption($values)
$option = [];
foreach ($values as $keyValue) {
$keyValue = trim($keyValue);
if ($pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR)) {
$pos = strpos($keyValue, self::PAIR_VALUE_SEPARATOR);
if ($pos !== false) {
$key = substr($keyValue, 0, $pos);
$value = substr($keyValue, $pos + 1);
if ($key == self::URL_OPTION_VALUE || $key == self::FILE_OPTION_VALUE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private function addEmptyOption(array $options)
public function getOptionText($value)
{
$isMultiple = false;
if (strpos($value, ',')) {
if (strpos($value, ',') !== false) {
$isMultiple = true;
$value = explode(',', $value);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Email/Model/AbstractTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function loadDefault($templateId)
/**
* trim copyright message
*/
if (preg_match('/^<!--[\w\W]+?-->/m', $templateText, $matches) && strpos($matches[0], 'Copyright') > 0) {
if (preg_match('/^<!--[\w\W]+?-->/m', $templateText, $matches) && strpos($matches[0], 'Copyright') !== false) {
$templateText = str_replace($matches[0], '', $templateText);
}

Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Fedex/Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
$mapsOld = $conn->fetchAll($select);
foreach ($mapsOld as $mapOld) {
$mapNew = '';
if (stripos($mapOld['path'], 'packaging') && isset($codes['packaging'][$mapOld['value']])) {
if (stripos($mapOld['path'], 'packaging') !== false && isset($codes['packaging'][$mapOld['value']])) {
$mapNew = $codes['packaging'][$mapOld['value']];
} elseif (stripos($mapOld['path'], 'dropoff') && isset($codes['dropoff'][$mapOld['value']])) {
} elseif (stripos($mapOld['path'], 'dropoff') !== false && isset($codes['dropoff'][$mapOld['value']])) {
$mapNew = $codes['dropoff'][$mapOld['value']];
} elseif (stripos($mapOld['path'], 'free_method') && isset($codes['method'][$mapOld['value']])) {
} elseif (stripos($mapOld['path'], 'free_method') !== false && isset($codes['method'][$mapOld['value']])) {
$mapNew = $codes['method'][$mapOld['value']];
} elseif (stripos($mapOld['path'], 'allowed_methods')) {
} elseif (stripos($mapOld['path'], 'allowed_methods') !== false) {
foreach (explode(',', $mapOld['value']) as $shippingMethod) {
if (isset($codes['method'][$shippingMethod])) {
$mapNew[] = $codes['method'][$shippingMethod];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function testParseXmlXXEXml()

$xmlElement = $this->carrier->parseXml($xmlString);

// @codingStandardsIgnoreLine
echo $xmlElement->asXML();
}

Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/Usps/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ private function updateAllowedMethods(ModuleDataSetupInterface $setup)
$oldConfigValues = $connection->fetchAll($select);

foreach ($oldConfigValues as $oldValue) {
if (stripos($oldValue['path'], 'free_method') && isset($oldToNewMethodCodesMap[$oldValue['value']])) {
if (stripos($oldValue['path'], 'free_method') !== false
&& isset($oldToNewMethodCodesMap[$oldValue['value']])
) {
$newValue = $oldToNewMethodCodesMap[$oldValue['value']];
} elseif (stripos($oldValue['path'], 'allowed_methods')) {
} elseif (stripos($oldValue['path'], 'allowed_methods') !== false) {
$newValuesList = [];
foreach (explode(',', $oldValue['value']) as $shippingMethod) {
if (isset($oldToNewMethodCodesMap[$shippingMethod])) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ protected function getObjectSchema($typeName, $description = '')
if ($simpleType = $this->getSimpleType($trimedTypeName)) {
$result['items'] = ['type' => $simpleType];
} else {
if (strpos($typeName, '[]')) {
if (strpos($typeName, '[]') !== false) {
$result['items'] = ['$ref' => $this->getDefinitionReference($trimedTypeName)];
} else {
$result = ['$ref' => $this->getDefinitionReference($trimedTypeName)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function authorize()
];
$this->transport->write($url, $data, CurlInterface::POST);
$response = $this->read();
if (strpos($response, 'login-form')) {
if (strpos($response, 'login-form') !== false) {
throw new \Exception(
'Admin user cannot be logged in by curl handler!'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function authorize(Customer $customer)
];
$this->transport->write($url, $data, CurlInterface::POST, ['Set-Cookie:' . $this->cookies]);
$response = $this->read();
if (strpos($response, 'customer/account/login')) {
if (strpos($response, 'customer/account/login') !== false) {
throw new \Exception($customer->getFirstname() . ', cannot be logged in by curl handler!');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function prepareBundleOptions(BundleProduct $product, array $cartItemOpt
'price' => number_format($price, 2),
];
foreach ($cartItemOptions as $option) {
if (strpos($option['value'], $title)) {
if (strpos($option['value'], $title) !== false) {
$optionData['options'][$productKey]['selected'] = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ protected function optionNameConvert($inputType)
{
$option = substr($inputType, strpos($inputType, "/") + 1);
$option = str_replace([' ', '&'], "", $option);
if ($end = strpos($option, '-')) {
$end = strpos($option, '-');
if ($end !== false) {
$option = substr($option, 0, $end) . ucfirst(substr($option, ($end + 1)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
$this->_eventManager->dispatchEvent(['curl_failed'], [$response]);
throw new \Exception($this->responseExceptionMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function createProduct(array $data, array $config)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
$this->_eventManager->dispatchEvent(['curl_failed'], [$response]);
throw new \Exception('Product creation by curl handler was not successful!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $this->backendTransport->read();
$this->backendTransport->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
$this->_eventManager->dispatchEvent(['curl_failed'], [$response]);
throw new \Exception('Category creation by curl handler was not successful!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
"Catalog Price Rule entity creating by curl handler was not successful! Response: $response"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Checkout agreement creating by curl handler was not successful! Response: $response");
}
preg_match('~id\/(\d*?)\/~', $response, $matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function openTab($tabName)
$this->browser->find($this->header)->hover();
$tab = $this->getContainerElement($tabName);
$tabHeader = $tab->find('.//*[contains(@class,"admin__collapsible-title")]', Locator::SELECTOR_XPATH);
if ($tabHeader->isVisible() && !strpos($tabHeader->getAttribute('class'), '_show')) {
if ($tabHeader->isVisible() && strpos($tabHeader->getAttribute('class'), '_show') === false) {
$tabHeader->hover();
$tabHeader->click();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("CMS Block entity creating by curl handler was not successful! Response: $response");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Cms page entity creating by curl handler was not successful! Response: $response");
}
preg_match("~page_id\/(\d*?)\/~", $response, $matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function persist(FixtureInterface $customer = null)
$response = $curl->read();
$curl->close();
// After caching My Account page we cannot check by success message
if (!strpos($response, 'block-dashboard-info')) {
if (strpos($response, 'block-dashboard-info') === false) {
throw new \Exception("Customer entity creating by curl handler was not successful! Response: $response");
}

Expand Down Expand Up @@ -192,7 +192,7 @@ protected function updateCustomer(array $data)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
$this->_eventManager->dispatchEvent(['curl_failed'], [$response]);
throw new \Exception('Failed to update customer!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
"Customer Group entity creating by curl handler was not successful! Response: $response"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Currency rates setting by curl handler was not successful! Response:\n" . $response);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function createProduct(array $data, array $config)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Product creation by curl handler was not successful! Response: $response");
}
preg_match("~Location: [^\s]*\/id\/(\d+)~", $response, $matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Integration creation by curl handler was not successful! Response: $response");
}
$result['integration_id'] = $this->getIntegrationId($fixture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Newsletter template creation by curl was not successful! Response: $response");
}
$curl->close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function persist(FixtureInterface $rating = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
'Product Rating entity creating by curl handler was not successful! Response:' . $response
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function persist(FixtureInterface $review = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
'Product Review entity creating by curl handler was not successful! Response:' . $response
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected function createOrder(array $data)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Order creation by curl handler was not successful! Response: $response");
}
preg_match("~<h1 class=\"page-title\">#(.*)</h1>~", $response, $matches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("OrderStatus entity creating by curl handler was not successful! Response: $response");
}

Expand All @@ -73,7 +73,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
"Assigning OrderStatus entity by curl handler was not successful! Response: $response"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Sales rule entity creating by curl handler was not successful! Response: $response");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception(
"Synonym Group entity creation by curl handler was not successful! Response: $response"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function persist(FixtureInterface $fixture = null)
$response = $curl->read();
$curl->close();

if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Sitemap entity creating by curl handler was not successful! Response: $response");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function persist(FixtureInterface $fixture = null)
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
if (strpos($response, 'data-ui-id="messages-message-success"') === false) {
throw new \Exception("Store View entity creating by curl handler was not successful! Response: $response");
}

Expand Down
Loading

0 comments on commit f93b914

Please sign in to comment.