From fe2cdc1c21b880c9b9de59869296eed7a9350147 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Thu, 20 Apr 2017 16:55:43 +0200 Subject: [PATCH 1/2] Fixed coding standard violations in the Framework\Config namespace, so that it will be checked bij PHP CS and no longer be ignored while doing CI checks. Made the following changes: - Removed @codingStandardsIgnoreFile at the head of the files - Fixed indentation - Changed is_null call to the === null compare --- lib/internal/Magento/Framework/Config/Dom.php | 24 +++++++++---------- .../Config/Test/Unit/Composer/PackageTest.php | 2 -- .../Framework/Config/Test/Unit/DataTest.php | 2 -- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php index 9c4dde0710c02..eeb11b49371e6 100644 --- a/lib/internal/Magento/Framework/Config/Dom.php +++ b/lib/internal/Magento/Framework/Config/Dom.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Magento configuration XML DOM utility */ @@ -120,7 +118,7 @@ public function __construct( /** * Retrieve array of xml errors * - * @param $errorFormat + * @param string $errorFormat * @return string[] */ private static function getXmlErrors($errorFormat) @@ -172,14 +170,14 @@ protected function _mergeNode(\DOMElement $node, $parentPath) if ($matchedNode) { //different node type if ($this->typeAttributeName && $node->hasAttribute( - $this->typeAttributeName - ) && $matchedNode->hasAttribute( - $this->typeAttributeName - ) && $node->getAttribute( - $this->typeAttributeName - ) !== $matchedNode->getAttribute( - $this->typeAttributeName - ) + $this->typeAttributeName + ) && $matchedNode->hasAttribute( + $this->typeAttributeName + ) && $node->getAttribute( + $this->typeAttributeName + ) !== $matchedNode->getAttribute( + $this->typeAttributeName + ) ) { $parentMatchedNode = $this->_getMatchedNode($parentPath); $newNode = $this->dom->importNode($node, true); @@ -247,7 +245,7 @@ protected function _mergeAttributes($baseNode, $mergeNode) */ protected function _getNodePathByParent(\DOMElement $node, $parentPath) { - $prefix = is_null($this->rootNamespace) ? '' : self::ROOT_NAMESPACE_PREFIX . ':'; + $prefix = $this->rootNamespace === null ? '' : self::ROOT_NAMESPACE_PREFIX . ':'; $path = $parentPath . '/' . $prefix . $node->tagName; $idAttribute = $this->nodeMergingConfig->getIdAttribute($path); if (is_array($idAttribute)) { @@ -441,7 +439,7 @@ public function setSchemaFile($schemaFile) */ private function _getAttributeName($attribute) { - if (!is_null($attribute->prefix) && !empty($attribute->prefix)) { + if ($attribute->prefix !== null && !empty($attribute->prefix)) { $attributeName = $attribute->prefix . ':' . $attribute->name; } else { $attributeName = $attribute->name; diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php index 7a2e44462c590..7dccef0cc2aa3 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Composer/PackageTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Framework\Config\Test\Unit\Composer; use \Magento\Framework\Config\Composer\Package; diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php index 648dd723d8a9f..fa881bb330160 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Framework\Config\Test\Unit; class DataTest extends \PHPUnit_Framework_TestCase From 776efe6c1778f8a6d0045c32440ad2064b06bcfc Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Thu, 20 Apr 2017 17:19:22 +0200 Subject: [PATCH 2/2] - Fixed multiline if statement - Fixed wrong identation --- lib/internal/Magento/Framework/Config/Dom.php | 13 ++++--------- .../Magento/Framework/Config/Test/Unit/DataTest.php | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php index eeb11b49371e6..6e611e722e41b 100644 --- a/lib/internal/Magento/Framework/Config/Dom.php +++ b/lib/internal/Magento/Framework/Config/Dom.php @@ -169,15 +169,10 @@ protected function _mergeNode(\DOMElement $node, $parentPath) /* Update matched node attributes and value */ if ($matchedNode) { //different node type - if ($this->typeAttributeName && $node->hasAttribute( - $this->typeAttributeName - ) && $matchedNode->hasAttribute( - $this->typeAttributeName - ) && $node->getAttribute( - $this->typeAttributeName - ) !== $matchedNode->getAttribute( - $this->typeAttributeName - ) + if ($this->typeAttributeName && + $node->hasAttribute($this->typeAttributeName) && + $matchedNode->hasAttribute($this->typeAttributeName) && + $node->getAttribute($this->typeAttributeName) !== $matchedNode->getAttribute($this->typeAttributeName) ) { $parentMatchedNode = $this->_getMatchedNode($parentPath); $newNode = $this->dom->importNode($node, true); diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php index fa881bb330160..1d7e685ac771a 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/DataTest.php @@ -8,7 +8,7 @@ class DataTest extends \PHPUnit_Framework_TestCase { - /** + /** * @var \Magento\Framework\Config\ReaderInterface|\PHPUnit_Framework_MockObject_MockObject */ private $readerMock;