Skip to content

Commit

Permalink
[PSR-2 Compliance] Fix magento#8612: Hundreds of PHPCS-based static t…
Browse files Browse the repository at this point in the history
…ests violations in mainline

- apply automatic PHPCBF fixes to make PHPCS happy
- Step 0. Install phpcs globally: composer global require squizlabs/php_codesniffer:2.8.0
- Step 1. Execute tool to fix PSR-2 violations in PHP files: ~/.composer/vendor/bin/phpcbf --standard=PSR2 --extensions=php --ignore=generated/*,vendor/*,var/* .
  • Loading branch information
orlangur committed Feb 26, 2017
1 parent 74f3a5a commit bc79f6d
Show file tree
Hide file tree
Showing 448 changed files with 504 additions and 832 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Store\Model\Store;

/**
* @deprecated
* @deprecated
*/
class Baseurl implements \Magento\Framework\Notification\MessageInterface
{
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/AdminNotification/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,5 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$installer->getConnection()->createTable($table);

$installer->endSetup();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase
/**
* @var \Magento\Store\Model\WebSite|\PHPUnit_Framework_MockObject_MockObject
*/
protected $webSiteModel;
protected $webSiteModel;

/**
* @var \Magento\CatalogImportExport\Model\Import\Product\StoreResolver|\PHPUnit_Framework_MockObject_MockObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function __construct(
$this->notificationTime = $notificationTime;
$this->logger = $logger;
parent::__construct($context);

}

/**
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Analytics/Model/ReportWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function write(WriteInterface $directory, $path)
if (!$headers) {
$headers = array_keys($row);
$stream->writeCsv($headers);

}
$stream->writeCsv($row);
}
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Analytics/ReportXml/Config/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function execute($configData)
$entityData = array_shift($queryData['source']);
$queries[$queryData['name']] = $queryData;
$queries[$queryData['name']]['source'] = $entityData;

}
return $queries;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function getColumns(SelectBuilder $selectBuilder, $entityConfig)
if (isset($attributeData['group'])) {
$group[$columnAlias] = $expression;
}

}
$selectBuilder->setGroup(array_merge($selectBuilder->getGroup(), $group));
return $columns;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/ReportXml/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Query implements \JsonSerializable
private $selectHydrator;

/**
* @var string
* @var string
*/
private $connectionName;

Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Analytics/ReportXml/ReportProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ public function getReport($name, SearchCriteria $criteria = null)
$connection = $this->connectionFactory->getConnection($query->getConnectionName());
$statement = $connection->query($query->getSelect());
return new \IteratorIterator($statement);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function setUp()
/**
* @param int|null $value null means that $value was not changed
* @param bool $isTokenExist
*
*
* @dataProvider processDataProvider
*/
public function testProcess($value, $isTokenExist)
Expand Down
15 changes: 6 additions & 9 deletions app/code/Magento/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,14 @@ protected function processCapture($result, $payment)
switch ($result->getXResponseCode()) {
case self::RESPONSE_CODE_APPROVED:
case self::RESPONSE_CODE_HELD:
if (
in_array(
$result->getXResponseReasonCode(),
[
if (in_array(
$result->getXResponseReasonCode(),
[
self::RESPONSE_REASON_CODE_APPROVED,
self::RESPONSE_REASON_CODE_PENDING_REVIEW,
self::RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED
]
)
)
) {
if (!$payment->getParentTransactionId()
|| $result->getXTransId() != $payment->getParentTransactionId()
Expand Down Expand Up @@ -534,8 +533,7 @@ public function validateResponse()
{
$response = $this->getResponse();
//md5 check
if (
!$this->getConfigData('trans_md5')
if (!$this->getConfigData('trans_md5')
|| !$this->getConfigData('login')
|| !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login'))
) {
Expand Down Expand Up @@ -802,8 +800,7 @@ protected function declineOrder(\Magento\Sales\Model\Order $order, $message = ''
{
try {
$response = $this->getResponse();
if (
$voidPayment && $response->getXTransId() && strtoupper($response->getXType())
if ($voidPayment && $response->getXTransId() && strtoupper($response->getXType())
== self::REQUEST_TYPE_AUTH_ONLY
) {
$order->getPayment()->setTransactionId(null)->setParentTransactionId($response->getXTransId())->void();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function beforeSave()
throw new LocalizedException(
__('Admin session lifetime must be less than or equal to 31536000 seconds (one year)')
);
} else if ($value < self::MIN_LIFETIME) {
} elseif ($value < self::MIN_LIFETIME) {
throw new LocalizedException(
__('Admin session lifetime must be greater than or equal to 60 seconds')
);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Model/Locale/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function switchBackendInterfaceLocale($localeCode)
}

/**
* Get general interface locale
* Get general interface locale
*
* @return string
*/
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Backend/Model/Menu/Item/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public function validate($data)
}

foreach ($data as $param => $value) {
if (
$data[$param] !== null
if ($data[$param] !== null
&& isset(
$this->_validators[$param]
) && !$this->_validators[$param]->isValid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* </argument>
* </arguments>
* </type>
*
*
* Registered condition can be used by ui component declaration in layout
*
* <uiComponent name="form" condition="condition::identifier" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/**
* Class ConditionPool
*
*
* Registry for \Magento\Backend\Model\View\Layout\ConditionInterface
* @see usage details in \Magento\Backend\Model\View\Layout\ConditionInterface description
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* </argument>
* </arguments>
* </type>
*
*
*/
interface FilterInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testProcessNotLoggedInUser($isIFrameParam, $isAjaxParam, $isForw
if ($isIFrameParam) {
$getParamCalls = 1;
$actionName = 'deniedIframe';
} else if ($isAjaxParam) {
} elseif ($isAjaxParam) {
$getParamCalls = 2;
$actionName = 'deniedJson';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Class ResetTest
* @deprecated
* @deprecated
* @package Magento\Backend\Test\Unit\Block\Page\System\Config\Robots
*/
class ResetTest extends \PHPUnit_Framework_TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function _toHtml()

/**
* Sets name for input element
*
*
* @param string $value
* @return $this
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CountryCreditCard extends AbstractFieldArray

/**
* Returns renderer for country element
*
*
* @return Countries
*/
protected function getCountryRenderer()
Expand All @@ -42,7 +42,7 @@ protected function getCountryRenderer()

/**
* Returns renderer for country element
*
*
* @return CcTypes
*/
protected function getCcTypesRenderer()
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Braintree/Controller/Payment/GetNonce.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function execute()
$customerId = $this->session->getCustomerId();
$result = $this->command->execute(['public_hash' => $publicHash, 'customer_id' => $customerId])->get();
$response->setData(['paymentMethodNonce' => $result['paymentMethodNonce']]);

} catch (\Exception $e) {
$this->logger->critical($e);
return $this->processBadRequest($response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PaymentAction implements ArrayInterface
{
/**
* Possible actions on order place
*
*
* @return array
*/
public function toOptionArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ public function execute($shippingMethod, Quote $quote)
}

if (!$quote->getIsVirtual()) {

$shippingAddress = $quote->getShippingAddress();
if ($shippingMethod !== $shippingAddress->getShippingMethod()) {

$this->disabledQuoteAddressValidation($quote);

$shippingAddress->setShippingMethod($shippingMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function apply($field, $condition, $value)
{
$result = false;

switch($condition) {
switch ($condition) {
case ApplierInterface::IN:
$field->in($value);
$result = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function apply($field, $condition, $value)
{
$result = false;

switch($condition) {
switch ($condition) {
case ApplierInterface::QTEQ:
$field->greaterThanOrEqualTo($value);
$result = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function apply($field, $condition, $value)
$result = false;

$value = trim($value, "% \r\n\t");
switch($condition) {
switch ($condition) {
case ApplierInterface::EQ:
$field->is($value);
$result = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getCustomAttributes()
$output = [];
foreach ($this->getMappedValues() as $key => $value) {
$attribute = $this->attributeValueFactory->create();
if(in_array($key, $shouldBeLocalized)) {
if (in_array($key, $shouldBeLocalized)) {
$value = __($value);
}
$output[] = $attribute->setAttributeCode($key)->setValue($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/**
* Class PaymentDataBuilderTest
*
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class PaymentDataBuilderTest extends \PHPUnit_Framework_TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testGetItemsWithNullLimit()

/**
* Add fields to filter
*
*
* @dataProvider addToFilterDataProvider
*/
public function testAddToFilter($field, $condition, $filterMapperCall, $expectedCondition)
Expand All @@ -211,7 +211,7 @@ public function testAddToFilter($field, $condition, $filterMapperCall, $expected

/**
* addToFilter DataProvider
*
*
* @return array
*/
public function addToFilterDataProvider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ public function testPrepare($name, $filterData, $expectedCondition)

/**
* Gets Filter mock
*
*
* @param string $name
* @param string $expectedType
* @param string $expectedDate
* @param int $i
*
*
* @return Filter|\PHPUnit_Framework_MockObject_MockObject
*/
private function getFilterMock($name, $expectedType, $expectedDate, &$i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public function isDisabledField()
&& $this->getAttribute()->getAttributeCode() === 'price'
)
|| $this->getElement()->getReadonly();

}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Bundle/Model/OptionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ private function compareLinks(
}
foreach ($firstArray as $obj) {
foreach ($secondArray as $objToCompare) {
if (
$obj->getId() != $objToCompare->getId()
if ($obj->getId() != $objToCompare->getId()
&& $obj instanceof \Magento\Bundle\Api\Data\LinkInterface
&& $objToCompare instanceof \Magento\Bundle\Api\Data\LinkInterface
) {
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Bundle/Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$setup->startSetup();
$connection = $setup->getConnection();
if (version_compare($context->getVersion(), '2.0.1', '<')) {

$fields = [
['table' => 'catalog_product_index_price_bundle_opt_idx', 'column' => 'alt_group_price'],
['table' => 'catalog_product_index_price_bundle_opt_tmp', 'column' => 'alt_group_price'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if (!empty($tags)) {
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}

}
}

Expand Down
6 changes: 2 additions & 4 deletions app/code/Magento/Captcha/Model/DefaultModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public function getBlockName()
*/
public function isRequired($login = null)
{
if (
$this->isUserAuth()
if ($this->isUserAuth()
&& !$this->isShownToLoggedInUser()
|| !$this->isEnabled()
|| !in_array(
Expand Down Expand Up @@ -425,8 +424,7 @@ private function isShowAlways()
return true;
}

if (
(string)$this->captchaData->getConfig('mode') == \Magento\Captcha\Helper\Data::MODE_AFTER_FAIL
if ((string)$this->captchaData->getConfig('mode') == \Magento\Captcha\Helper\Data::MODE_AFTER_FAIL
&& $this->getAllowedAttemptsForSameLogin() == 0
) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) {
if ($captchaModel->isRequired()) {
$controller = $observer->getControllerAction();
if (
!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
) {
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
Expand Down
Loading

0 comments on commit bc79f6d

Please sign in to comment.