method('render')
->willReturnMap($translateMap);
- $this->assertEquals($expectedResult, $this->model->getData($themePath));
+ $actualResult = $this->model->getData($themePath);
+ $this->assertEquals($expectedResult, $actualResult);
+ $this->assertEquals(
+ json_encode($expectedResult),
+ json_encode($actualResult),
+ "Translations should be sorted by key"
+ );
}
/**
diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php
index d89513b50c9c..8dcaabda93aa 100644
--- a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php
+++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php
@@ -99,7 +99,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getUserId()
{
@@ -108,7 +108,7 @@ public function getUserId()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getUserType()
{
@@ -187,6 +187,8 @@ protected function processRequest()
}
/**
+ * Set user data based on user type received from token data.
+ *
* @param Token $token
* @return void
*/
diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php
index 9ad051b686d4..6400a61b3ef3 100644
--- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php
+++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php
@@ -7,6 +7,7 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
+use Magento\Framework\Webapi\Exception as WebapiException;
use Magento\Webapi\Model\Soap\Fault;
use Magento\TestFramework\Helper\Bootstrap;
@@ -102,9 +103,11 @@ abstract class WebapiAbstract extends \PHPUnit\Framework\TestCase
/**
* Initialize fixture namespaces.
+ * //phpcs:disable
*/
public static function setUpBeforeClass()
{
+ //phpcs:enable
parent::setUpBeforeClass();
self::_setFixtureNamespace();
}
@@ -113,9 +116,11 @@ public static function setUpBeforeClass()
* Run garbage collector for cleaning memory
*
* @return void
+ * //phpcs:disable
*/
public static function tearDownAfterClass()
{
+ //phpcs:enable
//clear garbage in memory
gc_collect_cycles();
@@ -133,8 +138,7 @@ public static function tearDownAfterClass()
}
/**
- * Call safe delete for models which added to delete list
- * Restore config values changed during the test
+ * Call safe delete for models which added to delete list, Restore config values changed during the test
*
* @return void
*/
@@ -178,6 +182,8 @@ protected function _webApiCall(
/**
* Mark test to be executed for SOAP adapter only.
+ *
+ * @param ?string $message
*/
protected function _markTestAsSoapOnly($message = null)
{
@@ -188,6 +194,8 @@ protected function _markTestAsSoapOnly($message = null)
/**
* Mark test to be executed for REST adapter only.
+ *
+ * @param ?string $message
*/
protected function _markTestAsRestOnly($message = null)
{
@@ -203,9 +211,11 @@ protected function _markTestAsRestOnly($message = null)
* @param mixed $fixture
* @param int $tearDown
* @return void
+ * //phpcs:disable
*/
public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DOWN_AFTER_METHOD)
{
+ //phpcs:enable
$fixturesNamespace = self::_getFixtureNamespace();
if (!isset(self::$_fixtures[$fixturesNamespace])) {
self::$_fixtures[$fixturesNamespace] = [];
@@ -231,9 +241,11 @@ public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DO
*
* @param string $key
* @return mixed
+ * //phpcs:disable
*/
public static function getFixture($key)
{
+ //phpcs:enable
$fixturesNamespace = self::_getFixtureNamespace();
if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) {
return self::$_fixtures[$fixturesNamespace][$key];
@@ -247,9 +259,11 @@ public static function getFixture($key)
* @param \Magento\Framework\Model\AbstractModel $model
* @param bool $secure
* @return \Magento\TestFramework\TestCase\WebapiAbstract
+ * //phpcs:disable
*/
public static function callModelDelete($model, $secure = false)
{
+ //phpcs:enable
if ($model instanceof \Magento\Framework\Model\AbstractModel && $model->getId()) {
if ($secure) {
self::_enableSecureArea();
@@ -300,9 +314,11 @@ protected function _getWebApiAdapter($webApiAdapterCode)
* Set fixtures namespace
*
* @throws \RuntimeException
+ * //phpcs:disable
*/
protected static function _setFixtureNamespace()
{
+ //phpcs:enable
if (self::$_fixturesNamespace !== null) {
throw new \RuntimeException('Fixture namespace is already set.');
}
@@ -311,9 +327,11 @@ protected static function _setFixtureNamespace()
/**
* Unset fixtures namespace
+ * //phpcs:disable
*/
protected static function _unsetFixtureNamespace()
{
+ //phpcs:enable
$fixturesNamespace = self::_getFixtureNamespace();
unset(self::$_fixtures[$fixturesNamespace]);
self::$_fixturesNamespace = null;
@@ -324,9 +342,12 @@ protected static function _unsetFixtureNamespace()
*
* @throws \RuntimeException
* @return string
+ * //phpcs:disable
*/
protected static function _getFixtureNamespace()
{
+ //phpcs:enable
+
$fixtureNamespace = self::$_fixturesNamespace;
if ($fixtureNamespace === null) {
throw new \RuntimeException('Fixture namespace must be set.');
@@ -339,9 +360,12 @@ protected static function _getFixtureNamespace()
*
* @param bool $flag
* @return void
+ * //phpcs:disable
*/
protected static function _enableSecureArea($flag = true)
{
+ //phpcs:enable
+
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -388,9 +412,11 @@ protected function _assertMessagesEqual($expectedMessages, $receivedMessages)
* Delete array of fixtures
*
* @param array $fixtures
+ * //phpcs:disable
*/
protected static function _deleteFixtures($fixtures)
{
+ //phpcs:enable
foreach ($fixtures as $fixture) {
self::deleteFixture($fixture, true);
}
@@ -402,9 +428,11 @@ protected static function _deleteFixtures($fixtures)
* @param string $key
* @param bool $secure
* @return void
+ * //phpcs:disable
*/
public static function deleteFixture($key, $secure = false)
{
+ //phpcs:enable
$fixturesNamespace = self::_getFixtureNamespace();
if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) {
self::callModelDelete(self::$_fixtures[$fixturesNamespace][$key], $secure);
@@ -456,11 +484,11 @@ protected function _cleanAppConfigCache()
/**
* Update application config data
*
- * @param string $path Config path with the form "section/group/node"
- * @param string|int|null $value Value of config item
- * @param bool $cleanAppCache If TRUE application cache will be refreshed
- * @param bool $updateLocalConfig If TRUE local config object will be updated too
- * @param bool $restore If TRUE config value will be restored after test run
+ * @param string $path Config path with the form "section/group/node"
+ * @param string|int|null $value Value of config item
+ * @param bool $cleanAppCache If TRUE application cache will be refreshed
+ * @param bool $updateLocalConfig If TRUE local config object will be updated too
+ * @param bool $restore If TRUE config value will be restored after test run
* @return \Magento\TestFramework\TestCase\WebapiAbstract
* @throws \RuntimeException
*/
@@ -520,6 +548,8 @@ protected function _restoreAppConfig()
}
/**
+ * Process rest exception result.
+ *
* @param \Exception $e
* @return array
* ex.
@@ -666,11 +696,19 @@ protected function _checkWrappedErrors($expectedWrappedErrors, $errorDetails)
}
/**
+ * Get actual wrapped errors.
+ *
* @param \stdClass $errorNode
* @return array
*/
private function getActualWrappedErrors(\stdClass $errorNode)
{
+ if (!isset($errorNode->parameters)) {
+ return [
+ 'message' => $errorNode->message,
+ ];
+ }
+
$actualParameters = [];
$parameterNode = $errorNode->parameters->parameter;
if (is_array($parameterNode)) {
@@ -686,4 +724,42 @@ private function getActualWrappedErrors(\stdClass $errorNode)
'params' => $actualParameters,
];
}
+
+ /**
+ * Assert webapi errors.
+ *
+ * @param array $serviceInfo
+ * @param array $data
+ * @param array $expectedErrorData
+ * @return void
+ * @throws \Exception
+ */
+ protected function assertWebApiCallErrors(array $serviceInfo, array $data, array $expectedErrorData)
+ {
+ try {
+ $this->_webApiCall($serviceInfo, $data);
+ $this->fail('Expected throwing exception');
+ } catch (\Exception $e) {
+ if (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST) {
+ self::assertEquals($expectedErrorData, $this->processRestExceptionResult($e));
+ self::assertEquals(WebapiException::HTTP_BAD_REQUEST, $e->getCode());
+ } elseif (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) {
+ $this->assertInstanceOf('SoapFault', $e);
+ $expectedWrappedErrors = [];
+ foreach ($expectedErrorData['errors'] as $error) {
+ // @see \Magento\TestFramework\TestCase\WebapiAbstract::getActualWrappedErrors()
+ $expectedWrappedError = [
+ 'message' => $error['message'],
+ ];
+ if (isset($error['parameters'])) {
+ $expectedWrappedError['params'] = $error['parameters'];
+ }
+ $expectedWrappedErrors[] = $expectedWrappedError;
+ }
+ $this->checkSoapFault($e, $expectedErrorData['message'], 'env:Sender', [], $expectedWrappedErrors);
+ } else {
+ throw $e;
+ }
+ }
+ }
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php
index e805bc940704..b6687b4e171d 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php
@@ -198,6 +198,6 @@ private function checkImageExists(string $url): bool
curl_exec($connection);
$responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE);
// phpcs:enable Magento2.Functions.DiscouragedFunction
- return $responseStatus === 200 ? true : false;
+ return $responseStatus === 200;
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php
index b957292a3ac2..52463485a34f 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php
@@ -144,6 +144,6 @@ private function checkImageExists(string $url): bool
curl_exec($connection);
$responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE);
- return $responseStatus === 200 ? true : false;
+ return $responseStatus === 200;
}
}
diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php
index 49f2577b2621..bc3ae83643d3 100644
--- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php
+++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php
@@ -9,7 +9,6 @@
use Magento\Mtf\Client\Locator;
/**
- * Class LiselectstoreElement
* Typified element class for lists selectors
*/
class LiselectstoreElement extends SimpleElement
@@ -76,6 +75,7 @@ public function setValue($value)
$option = $this->context->find($optionSelector, Locator::SELECTOR_XPATH);
if (!$option->isVisible()) {
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.');
}
$option->click();
@@ -133,7 +133,7 @@ public function getValues()
*/
protected function isSubstring($haystack, $pattern)
{
- return preg_match("/$pattern/", $haystack) != 0 ? true : false;
+ return preg_match("/$pattern/", $haystack) != 0;
}
/**
@@ -157,8 +157,8 @@ protected function findNearestElement($criteria, $key, array $elements)
/**
* Get selected store value
*
- * @throws \Exception
* @return string
+ * @throws \Exception
*/
public function getValue()
{
diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php
index f1ab25501328..a06ee2332704 100644
--- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php
+++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php
@@ -311,7 +311,7 @@ public function fillBundleOptions($bundleOptions)
{
foreach ($bundleOptions as $option) {
$selector = sprintf($this->bundleOptionBlock, $option['title']);
- $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true' ? true : false;
+ $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true';
if (!$useDefault) {
/** @var Option $optionBlock */
$optionBlock = $this->blockFactory->create(
diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php
index e7dd72d1d426..da5e7101e4b3 100644
--- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php
+++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php
@@ -102,7 +102,7 @@ public function test($gridActions, $gridStatus)
$this->reviewIndex->getReviewGrid()->massaction(
[['title' => $this->review->getTitle()]],
[$gridActions => $gridStatus],
- ($gridActions == 'Delete' ? true : false)
+ ($gridActions == 'Delete')
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php
index d6ea08a2f7ca..55d8c6a6a217 100644
--- a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php
@@ -62,7 +62,7 @@ protected function tearDown()
* during creation second partial invoice.
*
* @return void
- * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magneto
+ * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magento
* @magentoConfigFixture current_store payment/braintree/merchant_account_id USA_Merchant
* @magentoDataFixture Magento/Braintree/Fixtures/partial_invoice.php
*/
@@ -71,11 +71,14 @@ public function testCreatePartialInvoiceWithNonDefaultMerchantAccount(): void
$order = $this->getOrder('100000002');
$this->adapter->method('sale')
- ->with(self::callback(function ($request) {
- self::assertEquals('USA_Merchant', $request['merchantAccountId']);
- return true;
- }))
- ->willReturn($this->getTransactionStub());
+ ->with(
+ self::callback(
+ function ($request) {
+ self::assertEquals('USA_Merchant', $request['merchantAccountId']);
+ return true;
+ }
+ )
+ )->willReturn($this->getTransactionStub());
$uri = 'backend/sales/order_invoice/save/order_id/' . $order->getEntityId();
$this->prepareRequest($uri);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php
index 23fd8d7fe324..928c036e8fb4 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php
@@ -41,7 +41,7 @@
$productRepository->save($product);
} catch (\Exception $e) {
// problems during save
-};
+}
/** @var ProductInterface $product */
$product = $objectManager->create(ProductInterface::class);
@@ -60,4 +60,4 @@
$productRepository->save($product);
} catch (\Exception $e) {
// problems during save
-};
+}
diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php
index 2a472371fd19..023421e4cd2b 100644
--- a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php
+++ b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php
@@ -118,7 +118,7 @@
$item->setQty(1);
$address->setTotalQty(1);
$address->addItem($item);
- };
+ }
}
$billingAddressData = [
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php
new file mode 100644
index 000000000000..1b68bc0520ce
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php
@@ -0,0 +1,65 @@
+cleanExpiredQuotes = $objectManager->get(CleanExpiredQuotes::class);
+ $this->quoteRepository = $objectManager->get(QuoteRepository::class);
+ $this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
+ }
+
+ /**
+ * Check if outdated quotes are deleted.
+ *
+ * @magentoConfigFixture default_store checkout/cart/delete_quote_after -365
+ * @magentoDataFixture Magento/Sales/_files/quotes.php
+ */
+ public function testExecute()
+ {
+ $this->cleanExpiredQuotes->execute();
+ $searchCriteria = $this->searchCriteriaBuilder->create();
+ $totalCount = $this->quoteRepository->getList($searchCriteria)->getTotalCount();
+
+ $this->assertEquals(
+ 1,
+ $totalCount
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
new file mode 100644
index 000000000000..b916fc024041
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
@@ -0,0 +1,35 @@
+get(QuoteFactory::class);
+/** @var QuoteRepository $quoteRepository */
+$quoteRepository = $objectManager->get(QuoteRepository::class);
+
+$quotes = [
+ 'quote for first store' => [
+ 'store' => 1,
+ ],
+ 'quote for second store' => [
+ 'store' => 2,
+ ],
+];
+
+foreach ($quotes as $quoteData) {
+ $quote = $quoteFactory->create();
+ $quote->setStoreId($quoteData['store']);
+ $quoteRepository->save($quote);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php
new file mode 100644
index 000000000000..7b7fd615e534
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php
@@ -0,0 +1,36 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var QuoteRepository $quoteRepository */
+$quoteRepository = $objectManager->get(QuoteRepository::class);
+/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
+$searchCriteria = $searchCriteriaBuilder->create();
+$items = $quoteRepository->getList($searchCriteria)
+ ->getItems();
+foreach ($items as $item) {
+ $quoteRepository->delete($item);
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require dirname(dirname(__DIR__)) . '/Store/_files/second_store_rollback.php';
diff --git a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php
index 68762a8a6c04..7f7a4761b17a 100644
--- a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php
+++ b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php
@@ -5,10 +5,13 @@
*/
namespace Magento\Framework\Acl\AclResource\Config\Converter;
+/**
+ * @inheritDoc
+ */
class Dom implements \Magento\Framework\Config\ConverterInterface
{
/**
- * {@inheritdoc}
+ * @inheritdoc
*
* @param \DOMDocument $source
* @return array
@@ -39,6 +42,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode)
$resourceAttributes = $resourceNode->attributes;
$idNode = $resourceAttributes->getNamedItem('id');
if ($idNode === null) {
+ // phpcs:ignore Magento2.Exceptions.DirectThrow
throw new \Exception('Attribute "id" is required for ACL resource.');
}
$resourceData['id'] = $idNode->nodeValue;
@@ -53,7 +57,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode)
$sortOrderNode = $resourceAttributes->getNamedItem('sortOrder');
$resourceData['sortOrder'] = $sortOrderNode !== null ? (int)$sortOrderNode->nodeValue : 0;
$disabledNode = $resourceAttributes->getNamedItem('disabled');
- $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true' ? true : false;
+ $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true';
// convert child resource nodes if needed
$resourceData['children'] = [];
/** @var $childNode \DOMNode */
diff --git a/lib/internal/Magento/Framework/App/MaintenanceMode.php b/lib/internal/Magento/Framework/App/MaintenanceMode.php
index e813522a0151..11347e4220c2 100644
--- a/lib/internal/Magento/Framework/App/MaintenanceMode.php
+++ b/lib/internal/Magento/Framework/App/MaintenanceMode.php
@@ -110,7 +110,7 @@ public function setAddresses($addresses)
throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n");
}
$result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses);
- return false !== $result ? true : false;
+ return false !== $result;
}
/**
diff --git a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php
index 8c22170a126f..f0ff31964512 100644
--- a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php
+++ b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php
@@ -50,7 +50,7 @@ public function resolveNamespace($type, array $availableNamespaces)
) {
$name = explode(self::NS_SEPARATOR, $type);
$unqualifiedName = $name[0];
- $isQualifiedName = count($name) > 1 ? true : false;
+ $isQualifiedName = count($name) > 1;
if (isset($availableNamespaces[$unqualifiedName])) {
$namespace = $availableNamespaces[$unqualifiedName];
if ($isQualifiedName) {
@@ -101,16 +101,22 @@ public function getImportedNamespaces(array $fileContent)
$imports[$importsCount][] = $item;
}
foreach ($imports as $import) {
- $import = array_filter($import, function ($token) {
- $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS];
- if (isset($token[0]) && in_array($token[0], $whitelist)) {
- return true;
+ $import = array_filter(
+ $import,
+ function ($token) {
+ $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS];
+ if (isset($token[0]) && in_array($token[0], $whitelist)) {
+ return true;
+ }
+ return false;
}
- return false;
- });
- $import = array_map(function ($element) {
- return $element[1];
- }, $import);
+ );
+ $import = array_map(
+ function ($element) {
+ return $element[1];
+ },
+ $import
+ );
$import = array_values($import);
if ($import[0] === self::NS_SEPARATOR) {
array_shift($import);
diff --git a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
index f3b26dc7a9bf..4a082d71ddd4 100644
--- a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
+++ b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
@@ -67,9 +67,11 @@ public function __construct(Factory $factoryElement, CollectionFactory $factoryC
* Please override this one instead of overriding real __construct constructor
*
* @return void
+ * @codingStandardsIgnoreStart
*/
protected function _construct()
{
+ //@codingStandardsIgnoreEnd
}
/**
@@ -137,14 +139,14 @@ public function addElement(AbstractElement $element, $after = null)
/**
* Add child element
*
- * if $after parameter is false - then element adds to end of collection
- * if $after parameter is null - then element adds to befin of collection
- * if $after parameter is string - then element adds after of the element with some id
+ * If $after parameter is false - then element adds to end of collection
+ * If $after parameter is null - then element adds to befin of collection
+ * If $after parameter is string - then element adds after of the element with some id
*
- * @param string $elementId
- * @param string $type
- * @param array $config
- * @param bool|string|null $after
+ * @param string $elementId
+ * @param string $type
+ * @param array $config
+ * @param bool|string|null $after
* @return AbstractElement
*/
public function addField($elementId, $type, $config, $after = false)
diff --git a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php
index dfb8b748469b..ebcbbeaa04ca 100644
--- a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php
+++ b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php
@@ -21,7 +21,7 @@ class ScalarTypes
public function isScalarType(string $typeName) : bool
{
$standardTypes = \GraphQL\Type\Definition\Type::getStandardTypes();
- return isset($standardTypes[$typeName]) ? true : false;
+ return isset($standardTypes[$typeName]);
}
/**
diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php
index 2cc2da62e71c..17d748260762 100644
--- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php
+++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php
@@ -1,22 +1,24 @@
isRedirect = (300 <= $code && 307 >= $code) ? true : false;
+ $this->isRedirect = (300 <= $code && 307 >= $code);
$this->setStatusCode($code);
return $this;
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStatusHeader($httpCode, $version = null, $phrase = null)
{
@@ -152,7 +154,7 @@ public function setStatusHeader($httpCode, $version = null, $phrase = null)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getHttpResponseCode()
{
@@ -170,7 +172,10 @@ public function isRedirect()
}
/**
+ * @inheritDoc
+ *
* @return string[]
+ * @SuppressWarnings(PHPMD.SerializationAware)
*/
public function __sleep()
{
diff --git a/lib/internal/Magento/Framework/Lock/Backend/Database.php b/lib/internal/Magento/Framework/Lock/Backend/Database.php
index 096e77a11768..a5a76ba60f4e 100644
--- a/lib/internal/Magento/Framework/Lock/Backend/Database.php
+++ b/lib/internal/Magento/Framework/Lock/Backend/Database.php
@@ -76,7 +76,7 @@ public function lock(string $name, int $timeout = -1): bool
{
if (!$this->deploymentConfig->isDbAvailable()) {
return true;
- };
+ }
$name = $this->addPrefix($name);
/**
@@ -117,7 +117,7 @@ public function unlock(string $name): bool
{
if (!$this->deploymentConfig->isDbAvailable()) {
return true;
- };
+ }
$name = $this->addPrefix($name);
@@ -145,7 +145,7 @@ public function isLocked(string $name): bool
{
if (!$this->deploymentConfig->isDbAvailable()) {
return false;
- };
+ }
$name = $this->addPrefix($name);
diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php
index 11aeb1c0c79b..c67a20f0a157 100644
--- a/lib/internal/Magento/Framework/Url.php
+++ b/lib/internal/Magento/Framework/Url.php
@@ -62,6 +62,7 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyFields)
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class Url extends \Magento\Framework\DataObject implements \Magento\Framework\UrlInterface
{
@@ -675,8 +676,7 @@ protected function _getControllerName($default = null)
}
/**
- * Set Action name
- * Reseted route path if action name has change
+ * Set Action name, reseated route path if action name has change
*
* @param string $data
* @return \Magento\Framework\UrlInterface
@@ -1067,7 +1067,7 @@ public function sessionUrlVar($html)
*/
// @codingStandardsIgnoreEnd
function ($match) {
- if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) {
+ if ($this->useSessionIdForUrl($match[2] == 'S')) {
return $match[1] . $this->_sidResolver->getSessionIdQueryParam($this->_session) . '='
. $this->_session->getSessionId() . (isset($match[3]) ? $match[3] : '');
} else {
diff --git a/lib/web/mage/popup-window.js b/lib/web/mage/popup-window.js
index 5d7b0d1ddfd5..86a12a095442 100644
--- a/lib/web/mage/popup-window.js
+++ b/lib/web/mage/popup-window.js
@@ -57,8 +57,8 @@ define([
settings.windowURL = settings.windowURL || element.attr('href');
if (settings.centerBrowser) {
- centeredY = window.screenY + ((window.outerHeight / 2 - settings.height / 2));
- centeredX = window.screenX + ((window.outerWidth / 2 - settings.width / 2));
+ centeredY = window.screenY + (window.outerHeight / 2 - settings.height / 2);
+ centeredX = window.screenX + (window.outerWidth / 2 - settings.width / 2);
windowFeatures += ',left=' + centeredX + ',top=' + centeredY;
} else if (settings.centerScreen) {
centeredY = (screen.height - settings.height) / 2;