From 2110afd0551d9b2c6d1fe14ef6c523f54774ef5a Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 6 Aug 2019 13:49:27 +0300 Subject: [PATCH] magento/magento2#24005: Static test fix. --- .../Product/Form/Modifier/CustomOptions.php | 2 +- .../Product/Form/Modifier/General.php | 28 ++++-- .../ElementVisibility/ConcealInProduction.php | 2 + .../Tax/Model/Sales/Total/Quote/Tax.php | 1 - .../Weee/Block/Item/Price/Renderer.php | 64 +++++++++----- .../Composer/ComposerInformation.php | 1 + .../Framework/Composer/MagentoComponent.php | 3 + .../ResourceModel/Db/CreateEntityRow.php | 6 +- .../ResourceModel/Db/DeleteEntityRow.php | 5 ++ .../Db/ProcessEntityRelationInterface.php | 2 + .../ResourceModel/Db/UpdateEntityRow.php | 4 + .../View/Element/UiComponentFactory.php | 24 +++--- .../Magento/Framework/View/Layout.php | 16 +++- .../Framework/View/Layout/Generator/Block.php | 10 ++- .../Framework/View/Layout/Reader/Block.php | 13 +-- .../View/Layout/Reader/Container.php | 9 +- .../Test/Unit/Layout/Reader/BlockTest.php | 24 +++--- .../Framework/View/Test/Unit/LayoutTest.php | 34 +++++--- .../Console/InputValidationException.php | 3 + .../Setup/Console/Style/MagentoStyle.php | 85 +++++++++++-------- .../Setup/Fixtures/CartPriceRulesFixture.php | 14 ++- .../src/Magento/Setup/Model/SystemPackage.php | 30 ++++--- .../Fixtures/CartPriceRulesFixtureTest.php | 51 +++++------ 23 files changed, 271 insertions(+), 160 deletions(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index af43c84501f65..65792b395dc06 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -1153,7 +1153,7 @@ protected function getProductOptionTypes() if (count($group['optgroup'])) { $options[] = $group; - $groupIndex += 1; + $groupIndex++; } } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php index 26044eb91a309..91c74a2da5048 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php @@ -3,13 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Eav\Api\AttributeRepositoryInterface; -use Magento\Ui\Component\Form; use Magento\Framework\Stdlib\ArrayManager; +use Magento\Ui\Component\Form; /** * Data provider for main panel of product page @@ -60,10 +61,10 @@ public function __construct( /** * Customize number fields for advanced price and weight fields. * - * @since 101.0.0 * @param array $data * @return array * @throws \Magento\Framework\Exception\NoSuchEntityException + * @since 101.0.0 */ public function modifyData(array $data) { @@ -125,7 +126,7 @@ protected function customizeAdvancedPriceFormat(array $data) $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] = $this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]); $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] = - (float) $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]; + (float)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]; } } @@ -135,9 +136,9 @@ protected function customizeAdvancedPriceFormat(array $data) /** * Customize product form fields. * - * @since 101.0.0 * @param array $meta * @return array + * @since 101.0.0 */ public function modifyMeta(array $meta) { @@ -234,9 +235,13 @@ protected function customizeWeightField(array $meta) null, 'children' ); - $meta = $this->arrayManager->merge($containerPath . static::META_CONFIG_PATH, $meta, [ - 'component' => 'Magento_Ui/js/form/components/group', - ]); + $meta = $this->arrayManager->merge( + $containerPath . static::META_CONFIG_PATH, + $meta, + [ + 'component' => 'Magento_Ui/js/form/components/group', + ] + ); $hasWeightPath = $this->arrayManager->slicePath($weightPath, 0, -1) . '/' . ProductAttributeInterface::CODE_HAS_WEIGHT; @@ -438,8 +443,13 @@ protected function formatNumber($value) $precision = strlen(substr(strrchr($value, "."), 1)); $store = $this->locator->getStore(); $currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode()); - $value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL, - 'precision' => $precision]); + $value = $currency->toCurrency( + $value, + [ + 'display' => \Magento\Framework\Currency::NO_SYMBOL, + 'precision' => $precision + ] + ); return $value; } diff --git a/app/code/Magento/Config/Model/Config/Structure/ElementVisibility/ConcealInProduction.php b/app/code/Magento/Config/Model/Config/Structure/ElementVisibility/ConcealInProduction.php index d5ded9292864a..ec57d629e61da 100644 --- a/app/code/Magento/Config/Model/Config/Structure/ElementVisibility/ConcealInProduction.php +++ b/app/code/Magento/Config/Model/Config/Structure/ElementVisibility/ConcealInProduction.php @@ -11,6 +11,8 @@ use Magento\Framework\App\State; /** + * Checks visibility status. + * * Defines status of visibility of form elements on Stores > Settings > Configuration page * in Admin Panel in Production mode. * @api diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php index 52061fd5d3882..bdc61d62be5b1 100644 --- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php +++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php @@ -403,7 +403,6 @@ protected function enhanceTotalData( $total->setShippingTaxAmount($shippingTaxAmount); $total->setDiscountTaxCompensationAmount($discountTaxCompensation); // accessed via 'discount_tax_compensation' $total->setSubtotalInclTax($subtotalInclTax); - return; } /** diff --git a/app/code/Magento/Weee/Block/Item/Price/Renderer.php b/app/code/Magento/Weee/Block/Item/Price/Renderer.php index 59e680b6b5706..721df2c83f460 100644 --- a/app/code/Magento/Weee/Block/Item/Price/Renderer.php +++ b/app/code/Magento/Weee/Block/Item/Price/Renderer.php @@ -86,8 +86,9 @@ public function getIncludeWeeeFlag() } /** - * Get display price for unit price including tax. The Weee amount will be added to unit price including tax - * depending on Weee display setting + * Get display price for unit price including tax. + * + * The Weee amount will be added to unit price including tax depending on Weee display setting. * * @return float */ @@ -107,8 +108,9 @@ public function getUnitDisplayPriceInclTax() } /** - * Get base price for unit price including tax. The Weee amount will be added to unit price including tax - * depending on Weee display setting + * Get base price for unit price including tax. + * + * The Weee amount will be added to unit price including tax depending on Weee display setting. * * @return float */ @@ -128,8 +130,9 @@ public function getBaseUnitDisplayPriceInclTax() } /** - * Get display price for row total including tax. The Weee amount will be added to row total including tax - * depending on Weee display setting + * Get display price for row total including tax. + * + * The Weee amount will be added to row total including tax depending on Weee display setting. * * @return float */ @@ -149,8 +152,9 @@ public function getRowDisplayPriceInclTax() } /** - * Get base price for row total including tax. The Weee amount will be added to row total including tax - * depending on Weee display setting + * Get base price for row total including tax. + * + * The Weee amount will be added to row total including tax depending on Weee display setting. * * @return float */ @@ -170,8 +174,9 @@ public function getBaseRowDisplayPriceInclTax() } /** - * Get display price for unit price excluding tax. The Weee amount will be added to unit price - * depending on Weee display setting + * Get display price for unit price excluding tax. + * + * The Weee amount will be added to unit price depending on Weee display setting. * * @return float */ @@ -191,8 +196,9 @@ public function getUnitDisplayPriceExclTax() } /** - * Get base price for unit price excluding tax. The Weee amount will be added to unit price - * depending on Weee display setting + * Get base price for unit price excluding tax. + * + * The Weee amount will be added to unit price depending on Weee display setting. * * @return float */ @@ -218,8 +224,9 @@ public function getBaseUnitDisplayPriceExclTax() } /** - * Get display price for row total excluding tax. The Weee amount will be added to row total - * depending on Weee display setting + * Get display price for row total excluding tax. + * + * The Weee amount will be added to row total depending on Weee display setting. * * @return float */ @@ -239,8 +246,9 @@ public function getRowDisplayPriceExclTax() } /** - * Get base price for row total excluding tax. The Weee amount will be added to row total - * depending on Weee display setting + * Get base price for row total excluding tax. + * + * The Weee amount will be added to row total depending on Weee display setting. * * @return float */ @@ -260,7 +268,9 @@ public function getBaseRowDisplayPriceExclTax() } /** - * Get final unit display price including tax, this will add Weee amount to unit price include tax + * Get final unit display price including tax. + * + * This will add Weee amount to unit price include tax. * * @return float */ @@ -276,7 +286,9 @@ public function getFinalUnitDisplayPriceInclTax() } /** - * Get base final unit display price including tax, this will add Weee amount to unit price include tax + * Get base final unit display price including tax. + * + * This will add Weee amount to unit price include tax. * * @return float */ @@ -292,7 +304,9 @@ public function getBaseFinalUnitDisplayPriceInclTax() } /** - * Get final row display price including tax, this will add weee amount to rowTotalInclTax + * Get final row display price including tax. + * + * This will add weee amount to rowTotalInclTax. * * @return float */ @@ -308,7 +322,9 @@ public function getFinalRowDisplayPriceInclTax() } /** - * Get base final row display price including tax, this will add weee amount to rowTotalInclTax + * Get base final row display price including tax. + * + * This will add weee amount to rowTotalInclTax. * * @return float */ @@ -362,7 +378,9 @@ public function getBaseFinalUnitDisplayPriceExclTax() } /** - * Get final row display price excluding tax, this will add Weee amount to rowTotal + * Get final row display price excluding tax. + * + * This will add Weee amount to rowTotal. * * @return float */ @@ -378,7 +396,9 @@ public function getFinalRowDisplayPriceExclTax() } /** - * Get base final row display price excluding tax, this will add Weee amount to rowTotal + * Get base final row display price excluding tax. + * + * This will add Weee amount to rowTotal. * * @return float */ diff --git a/lib/internal/Magento/Framework/Composer/ComposerInformation.php b/lib/internal/Magento/Framework/Composer/ComposerInformation.php index 5ed5b0892d5d5..9808b8d60ab0e 100644 --- a/lib/internal/Magento/Framework/Composer/ComposerInformation.php +++ b/lib/internal/Magento/Framework/Composer/ComposerInformation.php @@ -150,6 +150,7 @@ public function getRequiredExtensions() /** @var CompletePackageInterface $package */ foreach ($this->getLocker()->getLockedRepository()->getPackages() as $package) { $requires = array_keys($package->getRequires()); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $allPlatformReqs = array_merge($allPlatformReqs, $requires); } } diff --git a/lib/internal/Magento/Framework/Composer/MagentoComponent.php b/lib/internal/Magento/Framework/Composer/MagentoComponent.php index 63b786cd00b85..db1de7fa1819a 100644 --- a/lib/internal/Magento/Framework/Composer/MagentoComponent.php +++ b/lib/internal/Magento/Framework/Composer/MagentoComponent.php @@ -5,6 +5,9 @@ */ namespace Magento\Framework\Composer; +/** + * Magento component. + */ class MagentoComponent { /** diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/CreateEntityRow.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/CreateEntityRow.php index 096d44813e9c4..32611ed10673b 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/CreateEntityRow.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/CreateEntityRow.php @@ -28,6 +28,8 @@ public function __construct( } /** + * Prepare data. + * * @param EntityMetadata $metadata * @param array $data * @return array @@ -36,7 +38,7 @@ protected function prepareData(EntityMetadata $metadata, $data) { $output = []; foreach ($metadata->getEntityConnection()->describeTable($metadata->getEntityTable()) as $column) { - if ($column['DEFAULT'] == 'CURRENT_TIMESTAMP' /*|| $column['IDENTITY']*/) { + if ($column['DEFAULT'] == 'CURRENT_TIMESTAMP') { continue; } if (isset($data[strtolower($column['COLUMN_NAME'])])) { @@ -52,6 +54,8 @@ protected function prepareData(EntityMetadata $metadata, $data) } /** + * Create entity row. + * * @param string $entityType * @param array $data * @return array diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/DeleteEntityRow.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/DeleteEntityRow.php index d7d63232c1191..c6ef305ebf939 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/DeleteEntityRow.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/DeleteEntityRow.php @@ -7,6 +7,9 @@ use Magento\Framework\EntityManager\MetadataPool; +/** + * Delete entity row. + */ class DeleteEntityRow { /** @@ -24,6 +27,8 @@ public function __construct( } /** + * Delete entity row. + * * @param string $entityType * @param array $data * @return bool diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/ProcessEntityRelationInterface.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/ProcessEntityRelationInterface.php index 859e816799b55..987e3f30d2e99 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/ProcessEntityRelationInterface.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/ProcessEntityRelationInterface.php @@ -12,6 +12,8 @@ interface ProcessEntityRelationInterface { /** + * Process entity relation. + * * @param string $entityType * @param object $entity * @return object diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php index 55697f7399bf8..7e2c58ecc886f 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php @@ -29,6 +29,8 @@ public function __construct( } /** + * Prepare data. + * * @param EntityMetadata $metadata * @param array $data * @return array @@ -48,6 +50,8 @@ protected function prepareData(EntityMetadata $metadata, $data) } /** + * Read entity row. + * * @param string $entityType * @param array $data * @return bool diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index 626aebeb94269..b395e95f0baaf 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -74,10 +74,10 @@ class UiComponentFactory extends DataObject * @param ManagerInterface $componentManager * @param InterpreterInterface $argumentInterpreter * @param ContextFactory $contextFactory - * @param DataInterfaceFactory|null $configFactory * @param array $data * @param array $componentChildFactories - * @param DataInterface|null $definitionData + * @param DataInterface $definitionData + * @param DataInterfaceFactory $configFactory */ public function __construct( ObjectManagerInterface $objectManager, @@ -265,10 +265,12 @@ protected function getBundleChildren(array $children = []) foreach ($children as $identifier => $config) { if (!isset($config['componentType'])) { - throw new LocalizedException(new Phrase( - 'The "componentType" configuration parameter is required for the "%1" component.', - $identifier - )); + throw new LocalizedException( + new Phrase( + 'The "componentType" configuration parameter is required for the "%1" component.', + $identifier + ) + ); } if (!isset($componentArguments['context'])) { @@ -386,10 +388,12 @@ protected function mergeMetadataItem(array $bundleComponents, array $metadata, $ if (!$isMerged) { if (!isset($data['arguments']['data']['config']['componentType'])) { - throw new LocalizedException(new Phrase( - 'The "componentType" configuration parameter is required for the "%1" component.', - [$name] - )); + throw new LocalizedException( + new Phrase( + 'The "componentType" configuration parameter is required for the "%1" component.', + [$name] + ) + ); } $rawComponentData = $this->definitionData->get( $data['arguments']['data']['config']['componentType'] diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php index 5cd7591098207..a622006f32a1e 100644 --- a/lib/internal/Magento/Framework/View/Layout.php +++ b/lib/internal/Magento/Framework/View/Layout.php @@ -223,6 +223,8 @@ public function __construct( } /** + * Set generator pool. + * * @param Layout\GeneratorPool $generatorPool * @return $this */ @@ -233,6 +235,8 @@ public function setGeneratorPool(Layout\GeneratorPool $generatorPool) } /** + * Set builder. + * * @param Layout\BuilderInterface $builder * @return $this */ @@ -255,7 +259,10 @@ protected function build() } /** - * TODO Will be eliminated in MAGETWO-28359 + * Public build. + * + * Will be eliminated in MAGETWO-28359 + * * @return void */ public function publicBuild() @@ -992,6 +999,8 @@ public function getBlockSingleton($type) } /** + * Add adjustable renderer. + * * @param string $namespace * @param string $staticType * @param string $dynamicType @@ -1011,6 +1020,8 @@ public function addAdjustableRenderer($namespace, $staticType, $dynamicType, $ty } /** + * Get renderer options. + * * @param string $namespace * @param string $staticType * @param string $dynamicType @@ -1031,6 +1042,8 @@ public function getRendererOptions($namespace, $staticType, $dynamicType) } /** + * Execute renderer. + * * @param string $namespace * @param string $staticType * @param string $dynamicType @@ -1049,6 +1062,7 @@ public function executeRenderer($namespace, $staticType, $dynamicType, $data = [ ->setTemplate($options['template']) ->assign($data); + // phpcs:ignore Magento2.Security.LanguageConstruct echo $this->_renderBlock($block->getNameInLayout()); } } diff --git a/lib/internal/Magento/Framework/View/Layout/Generator/Block.php b/lib/internal/Magento/Framework/View/Layout/Generator/Block.php index 39da65a2d1f3d..27af40f0b169c 100644 --- a/lib/internal/Magento/Framework/View/Layout/Generator/Block.php +++ b/lib/internal/Magento/Framework/View/Layout/Generator/Block.php @@ -222,9 +222,13 @@ protected function generateBlock( // create block $className = isset($attributes['class']) && !empty($attributes['class']) ? $attributes['class'] : $this->defaultClass; - $block = $this->createBlock($className, $elementName, [ - 'data' => $this->evaluateArguments($data['arguments']) - ]); + $block = $this->createBlock( + $className, + $elementName, + [ + 'data' => $this->evaluateArguments($data['arguments']) + ] + ); if (!empty($attributes['template'])) { $block->setTemplate($attributes['template']); } diff --git a/lib/internal/Magento/Framework/View/Layout/Reader/Block.php b/lib/internal/Magento/Framework/View/Layout/Reader/Block.php index ff20eb339c318..b287b517a454c 100644 --- a/lib/internal/Magento/Framework/View/Layout/Reader/Block.php +++ b/lib/internal/Magento/Framework/View/Layout/Reader/Block.php @@ -113,9 +113,7 @@ public function __construct( } /** - * {@inheritdoc} - * - * @return string[] + * @inheritdoc */ public function getSupportedNodes() { @@ -123,12 +121,7 @@ public function getSupportedNodes() } /** - * {@inheritdoc} - * - * @param Context $readerContext - * @param Element $currentElement - * @param Element $parentElement - * @return $this + * @inheritdoc */ public function interpret(Context $readerContext, Element $currentElement) { @@ -251,7 +244,7 @@ protected function scheduleReference( * Update data for scheduled element * * @param Element $currentElement - * @param array &$data + * @param array $data * @return array */ protected function updateScheduledData($currentElement, array &$data) diff --git a/lib/internal/Magento/Framework/View/Layout/Reader/Container.php b/lib/internal/Magento/Framework/View/Layout/Reader/Container.php index 850b340e985e1..e69f081b3d2f4 100644 --- a/lib/internal/Magento/Framework/View/Layout/Reader/Container.php +++ b/lib/internal/Magento/Framework/View/Layout/Reader/Container.php @@ -52,7 +52,7 @@ public function __construct( } /** - * @return string[] + * @inheritdoc */ public function getSupportedNodes() { @@ -60,12 +60,7 @@ public function getSupportedNodes() } /** - * {@inheritdoc} - * - * @param Context $readerContext - * @param Layout\Element $currentElement - * @param Layout\Element $parentElement - * @return $this + * @inheritdoc */ public function interpret(Context $readerContext, Layout\Element $currentElement) { diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php index ac1dd43f4dd01..017f58b814957 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php @@ -114,11 +114,13 @@ public function testProcessBlock( $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([ - 'actions' => [ - ['someMethod', [], 'action_config_path', 'scope'], - ], - ]); + ->willReturn( + [ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ] + ); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( @@ -266,11 +268,13 @@ public function testProcessReference( $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([ - 'actions' => [ - ['someMethod', [], 'action_config_path', 'scope'], - ], - ]); + ->willReturn( + [ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ] + ); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php index f8a8939bbfe36..a11d132b193a0 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/LayoutTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\View\Test\Unit; use Magento\Framework\Serialize\SerializerInterface; @@ -113,6 +114,9 @@ class LayoutTest extends \PHPUnit\Framework\TestCase */ private $serializer; + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function setUp() { $this->structureMock = $this->getMockBuilder(\Magento\Framework\View\Layout\Data\Structure::class) @@ -146,10 +150,12 @@ protected function setUp() $this->generatorPoolMock->expects($this->any()) ->method('getGenerator') ->will( - $this->returnValueMap([ - [\Magento\Framework\View\Layout\Generator\Block::TYPE, $this->generatorBlockMock], - [\Magento\Framework\View\Layout\Generator\Container::TYPE, $this->generatorContainerMock], - ]) + $this->returnValueMap( + [ + [\Magento\Framework\View\Layout\Generator\Block::TYPE, $this->generatorBlockMock], + [\Magento\Framework\View\Layout\Generator\Container::TYPE, $this->generatorContainerMock], + ] + ) ); $this->readerContextFactoryMock = $this->getMockBuilder( @@ -183,13 +189,19 @@ protected function setUp() ->getMock(); $this->serializer = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $this->serializer->expects($this->any())->method('serialize') - ->willReturnCallback(function ($value) { - return json_encode($value); - }); - $this->serializer->expects($this->any())->method('unserialize') - ->willReturnCallback(function ($value) { - return json_decode($value, true); - }); + ->willReturnCallback( + function ($value) { + return json_encode($value); + } + ); + $this->serializer->expects( + $this->any() + )->method('unserialize') + ->willReturnCallback( + function ($value) { + return json_decode($value, true); + } + ); $this->model = new \Magento\Framework\View\Layout( $this->processorFactoryMock, diff --git a/setup/src/Magento/Setup/Console/InputValidationException.php b/setup/src/Magento/Setup/Console/InputValidationException.php index efa8a03bcfe49..d4ed5f1177581 100644 --- a/setup/src/Magento/Setup/Console/InputValidationException.php +++ b/setup/src/Magento/Setup/Console/InputValidationException.php @@ -8,6 +8,9 @@ use Symfony\Component\Console\Exception\RuntimeException; +/** + * Input validation exception. + */ class InputValidationException extends RuntimeException { diff --git a/setup/src/Magento/Setup/Console/Style/MagentoStyle.php b/setup/src/Magento/Setup/Console/Style/MagentoStyle.php index cd2d4a77db65a..60cfcbb67c217 100644 --- a/setup/src/Magento/Setup/Console/Style/MagentoStyle.php +++ b/setup/src/Magento/Setup/Console/Style/MagentoStyle.php @@ -24,6 +24,7 @@ /** * Magento console output decorator. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class MagentoStyle extends OutputStyle implements MagentoStyleInterface @@ -108,49 +109,56 @@ public function block( } /** - * {@inheritdoc} + * @inheritdoc */ public function title($message) { $this->autoPrependBlock(); $bar = str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message)); - $this->writeln([ - sprintf(' %s', OutputFormatter::escapeTrailingBackslash($message)), - sprintf(' %s', $bar), - ]); + $this->writeln( + [ + sprintf(' %s', OutputFormatter::escapeTrailingBackslash($message)), + sprintf(' %s', $bar), + ] + ); $this->newLine(); } /** - * {@inheritdoc} + * @inheritdoc */ public function section($message) { $this->autoPrependBlock(); $bar = str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message)); - $this->writeln([ - sprintf(' %s', OutputFormatter::escapeTrailingBackslash($message)), - sprintf(' %s', $bar), - ]); + $this->writeln( + [ + sprintf(' %s', OutputFormatter::escapeTrailingBackslash($message)), + sprintf(' %s', $bar), + ] + ); $this->newLine(); } /** - * {@inheritdoc} + * @inheritdoc */ public function listing(array $elements) { $this->autoPrependText(); - $elements = array_map(function ($element) { - return sprintf(' * %s', $element); - }, $elements); + $elements = array_map( + function ($element) { + return sprintf(' * %s', $element); + }, + $elements + ); $this->writeln($elements); $this->newLine(); } /** - * {@inheritdoc} + * @inheritdoc */ public function text($message) { @@ -174,7 +182,7 @@ public function comment($message, $padding = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function success($message, $padding = true) { @@ -182,7 +190,7 @@ public function success($message, $padding = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function error($message, $padding = true) { @@ -190,7 +198,7 @@ public function error($message, $padding = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function warning($message, $padding = true) { @@ -198,7 +206,7 @@ public function warning($message, $padding = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function note($message, $padding = false) { @@ -206,7 +214,7 @@ public function note($message, $padding = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function caution($message, $padding = true) { @@ -214,7 +222,7 @@ public function caution($message, $padding = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function table(array $headers, array $rows) { @@ -231,7 +239,7 @@ public function table(array $headers, array $rows) } /** - * {@inheritdoc} + * @inheritdoc * @throws \Symfony\Component\Console\Exception\InvalidArgumentException */ public function ask($question, $default = null, $validator = null, $maxAttempts = null) @@ -244,7 +252,7 @@ public function ask($question, $default = null, $validator = null, $maxAttempts } /** - * {@inheritdoc} + * @inheritdoc * @throws \Symfony\Component\Console\Exception\LogicException */ public function askHidden($question, $validator = null) @@ -258,7 +266,7 @@ public function askHidden($question, $validator = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function confirm($question, $default = true) { @@ -266,7 +274,7 @@ public function confirm($question, $default = true) } /** - * {@inheritdoc} + * @inheritdoc */ public function choice($question, array $choices, $default = null) { @@ -279,7 +287,7 @@ public function choice($question, array $choices, $default = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function progressStart($max = 0) { @@ -288,7 +296,7 @@ public function progressStart($max = 0) } /** - * {@inheritdoc} + * @inheritdoc * @throws \Symfony\Component\Console\Exception\LogicException * @throws \Symfony\Component\Console\Exception\RuntimeException */ @@ -298,7 +306,7 @@ public function progressAdvance($step = 1) } /** - * {@inheritdoc} + * @inheritdoc * @throws \Symfony\Component\Console\Exception\RuntimeException */ public function progressFinish() @@ -309,7 +317,7 @@ public function progressFinish() } /** - * {@inheritdoc} + * @inheritdoc */ public function createProgressBar($max = 0) { @@ -437,7 +445,7 @@ public function askForMissingOption( } /** - * {@inheritdoc} + * @inheritdoc */ public function writeln($messages, $type = self::OUTPUT_NORMAL) { @@ -446,7 +454,7 @@ public function writeln($messages, $type = self::OUTPUT_NORMAL) } /** - * {@inheritdoc} + * @inheritdoc */ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) { @@ -455,7 +463,7 @@ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) } /** - * {@inheritdoc} + * @inheritdoc */ public function newLine($count = 1) { @@ -479,6 +487,8 @@ private function getProgressBar() } /** + * Get terminal width. + * * @return int */ private function getTerminalWidth() @@ -519,6 +529,8 @@ private function autoPrependText() } /** + * Reduce buffer. + * * @param array $messages * @return array */ @@ -526,9 +538,12 @@ private function reduceBuffer($messages) { // We need to know if the two last chars are PHP_EOL // Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer - return array_map(function ($value) { - return substr($value, -4); - }, array_merge([$this->bufferedOutput->fetch()], (array)$messages)); + return array_map( + function ($value) { + return substr($value, -4); + }, + array_merge([$this->bufferedOutput->fetch()], (array)$messages) + ); } /** diff --git a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php index 45634ce0dd53b..2ccde48ebdd7e 100644 --- a/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php +++ b/setup/src/Magento/Setup/Fixtures/CartPriceRulesFixture.php @@ -61,7 +61,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc * @SuppressWarnings(PHPMD) */ public function execute() @@ -115,6 +115,8 @@ public function execute() } /** + * Generate condition. + * * @param int $ruleId * @param array $categoriesArray * @return array @@ -160,6 +162,8 @@ public function generateCondition($ruleId, $categoriesArray) } /** + * Generate rules. + * * @param \Magento\SalesRule\Model\RuleFactory $ruleFactory * @param array $categoriesArray * @return void @@ -245,6 +249,8 @@ public function generateRules($ruleFactory, $categoriesArray) } /** + * Generate advanced condition. + * * @param int $ruleId * @param array $categoriesArray * @return array @@ -345,6 +351,8 @@ public function generateAdvancedCondition($ruleId, $categoriesArray) } /** + * Generate advanced rules. + * * @param \Magento\SalesRule\Model\RuleFactory $ruleFactory * @param array $categoriesArray * @return void @@ -436,7 +444,7 @@ public function generateAdvancedRules($ruleFactory, $categoriesArray) } /** - * {@inheritdoc} + * @inheritdoc */ public function getActionTitle() { @@ -444,7 +452,7 @@ public function getActionTitle() } /** - * {@inheritdoc} + * @inheritdoc */ public function introduceParamLabels() { diff --git a/setup/src/Magento/Setup/Model/SystemPackage.php b/setup/src/Magento/Setup/Model/SystemPackage.php index bc5f55c0b128b..040b80e9aab4f 100644 --- a/setup/src/Magento/Setup/Model/SystemPackage.php +++ b/setup/src/Magento/Setup/Model/SystemPackage.php @@ -196,12 +196,15 @@ public function getInstalledSystemPackages() */ public function sortVersions($enterpriseVersions) { - usort($enterpriseVersions[InfoCommand::AVAILABLE_VERSIONS], function ($versionOne, $versionTwo) { - if (version_compare($versionOne, $versionTwo, '==')) { - return 0; + usort( + $enterpriseVersions[InfoCommand::AVAILABLE_VERSIONS], + function ($versionOne, $versionTwo) { + if (version_compare($versionOne, $versionTwo, '==')) { + return 0; + } + return (version_compare($versionOne, $versionTwo, '<')) ? 1 : -1; } - return (version_compare($versionOne, $versionTwo, '<')) ? 1 : -1; - }); + ); return $enterpriseVersions; } @@ -231,15 +234,18 @@ private function formatPackages($packages) } } - usort($versions, function ($versionOne, $versionTwo) { - if (version_compare($versionOne['id'], $versionTwo['id'], '==')) { - if ($versionOne['package'] === static::EDITION_COMMUNITY) { - return 1; + usort( + $versions, + function ($versionOne, $versionTwo) { + if (version_compare($versionOne['id'], $versionTwo['id'], '==')) { + if ($versionOne['package'] === static::EDITION_COMMUNITY) { + return 1; + } + return 0; } - return 0; + return (version_compare($versionOne['id'], $versionTwo['id'], '<')) ? 1 : -1; } - return (version_compare($versionOne['id'], $versionTwo['id'], '<')) ? 1 : -1; - }); + ); return $versions; } diff --git a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php index 1a8a067d971b0..b071b56d41d2d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Fixtures/CartPriceRulesFixtureTest.php @@ -6,7 +6,7 @@ namespace Magento\Setup\Test\Unit\Fixtures; -use \Magento\Setup\Fixtures\CartPriceRulesFixture; +use Magento\Setup\Fixtures\CartPriceRulesFixture; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -154,17 +154,17 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo $result = $this->model->generateAdvancedCondition($ruleId, $categoriesArray); if ($ruleId < ($ruleCount - 200)) { $firstCondition = [ - 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, + 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class, 'attribute' => 'category_ids', - 'operator' => '==', - 'value' => null, + 'operator' => '==', + 'value' => null, ]; $secondCondition = [ - 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', - 'operator' => '>=', - 'value' => 5, + 'operator' => '>=', + 'value' => 5, ]; $expected = [ 'conditions' => [ @@ -174,7 +174,7 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo 'value' => '1', 'new_child' => '', ], - '1--1'=> [ + '1--1' => [ 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class, 'aggregator' => 'all', 'value' => '1', @@ -195,25 +195,25 @@ public function testGenerateAdvancedCondition($ruleId, $categoriesArray, $ruleCo } else { // Shipping Region $regions = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', - 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', - 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', - 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', - 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', - 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', - 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', - 'Wisconsin', 'Wyoming']; + 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', + 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', + 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', + 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', + 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', + 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', + 'Wisconsin', 'Wyoming']; $firstCondition = [ - 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'region', - 'operator' => '==', - 'value' => $regions[($ruleId / 4) % 50], + 'operator' => '==', + 'value' => $regions[($ruleId / 4) % 50], ]; $secondCondition = [ - 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, + 'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class, 'attribute' => 'base_subtotal', - 'operator' => '>=', - 'value' => 5, + 'operator' => '>=', + 'value' => 5, ]; $expected = [ 'conditions' => [ @@ -257,8 +257,11 @@ public function testGetActionTitle() public function testIntroduceParamLabels() { - $this->assertSame([ - 'cart_price_rules' => 'Cart Price Rules' - ], $this->model->introduceParamLabels()); + $this->assertSame( + [ + 'cart_price_rules' => 'Cart Price Rules' + ], + $this->model->introduceParamLabels() + ); } }