From 1f0b8f267c257b676035208361b22f810497f72c Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Fri, 14 Apr 2017 22:18:48 +0200 Subject: [PATCH 1/4] Fixed coding standard violations in the Framework\Validator namespace: - Removed @codingStandardsIgnoreFile - Fixed indentation - Fixed number of chars per line --- .../Magento/Framework/Validator/Builder.php | 21 ++++++++----- .../Validator/Constraint/Property.php | 8 ++--- .../Framework/Validator/ConstraintFactory.php | 10 +++---- .../Magento/Framework/Validator/Factory.php | 30 +++++++++++-------- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/lib/internal/Magento/Framework/Validator/Builder.php b/lib/internal/Magento/Framework/Validator/Builder.php index b50c729c3973e..7340be51948a5 100644 --- a/lib/internal/Magento/Framework/Validator/Builder.php +++ b/lib/internal/Magento/Framework/Validator/Builder.php @@ -6,8 +6,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Framework\Validator; use Magento\Framework\Validator\Constraint\OptionInterface; @@ -257,7 +255,11 @@ protected function _createConstraint(array $data) } if (\Magento\Framework\Validator\Config::CONSTRAINT_TYPE_PROPERTY == $data['type']) { - $result = new \Magento\Framework\Validator\Constraint\Property($validator, $data['property'], $data['alias']); + $result = new \Magento\Framework\Validator\Constraint\Property( + $validator, + $data['property'], + ['alias'] + ); } else { $result = $this->_constraintFactory->create(['validator' => $validator, 'alias' => $data['alias']]); } @@ -286,7 +288,10 @@ protected function _createConstraintValidator(array $data) // Check validator type if (!$validator instanceof \Magento\Framework\Validator\ValidatorInterface) { throw new \InvalidArgumentException( - sprintf('Constraint class "%s" must implement \Magento\Framework\Validator\ValidatorInterface', $data['class']) + sprintf( + 'Constraint class "%s" must implement \Magento\Framework\Validator\ValidatorInterface', + $data['class'] + ) ); } @@ -300,8 +305,10 @@ protected function _createConstraintValidator(array $data) * @param array $options * @return void */ - protected function _configureConstraintValidator(\Magento\Framework\Validator\ValidatorInterface $validator, array $options) - { + protected function _configureConstraintValidator( + \Magento\Framework\Validator\ValidatorInterface $validator, + array $options + ) { // Call all validator methods according to configuration if (isset($options['methods'])) { foreach ($options['methods'] as $methodData) { @@ -344,4 +351,4 @@ protected function _applyArgumentsCallback(array $arguments) } return $arguments; } -} +} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Validator/Constraint/Property.php b/lib/internal/Magento/Framework/Validator/Constraint/Property.php index a209e00f738e8..04f0c95450b05 100644 --- a/lib/internal/Magento/Framework/Validator/Constraint/Property.php +++ b/lib/internal/Magento/Framework/Validator/Constraint/Property.php @@ -6,8 +6,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Framework\Validator\Constraint; class Property extends \Magento\Framework\Validator\Constraint @@ -33,8 +31,8 @@ public function __construct(\Magento\Framework\Validator\ValidatorInterface $val } /** - * Get value that should be validated. Tries to extract value's property if \Magento\Framework\DataObject or \ArrayAccess or array - * is passed + * Get value that should be validated. Tries to extract value's property if \Magento\Framework\DataObject or + * \ArrayAccess or array is passed * * @param mixed $value * @return mixed @@ -62,4 +60,4 @@ protected function _addMessages(array $messages) { $this->_messages[$this->_property] = $messages; } -} +} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php index 43d3ef3d9cb35..170d067e76e84 100644 --- a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php +++ b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php @@ -4,8 +4,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - /** * Factory class for \Magento\Framework\Validator\Constraint */ @@ -33,8 +31,10 @@ class ConstraintFactory * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param string $instanceName */ - public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = \Magento\Framework\Validator\Constraint::class) - { + public function __construct( + \Magento\Framework\ObjectManagerInterface $objectManager, + $instanceName = \Magento\Framework\Validator\Constraint::class + ) { $this->_objectManager = $objectManager; $this->_instanceName = $instanceName; } @@ -50,4 +50,4 @@ public function create(array $data = []) { return $this->_objectManager->create($this->_instanceName, $data); } -} +} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php index a1b1752d5ded1..b2d34ff4cbcae 100644 --- a/lib/internal/Magento/Framework/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -3,18 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\Validator; use Magento\Framework\Cache\FrontendInterface; -/** - * @codingStandardsIgnoreFile - */ class Factory { - /** - * Cache key - */ + /** cache key */ const CACHE_KEY = __CLASS__; /** @@ -73,6 +69,8 @@ public function __construct( /** * Init cached list of validation files + * + * @return void */ protected function _initializeConfigList() { @@ -80,7 +78,10 @@ protected function _initializeConfigList() $this->_configFiles = $this->cache->load(self::CACHE_KEY); if (!$this->_configFiles) { $this->_configFiles = $this->moduleReader->getConfigurationFiles('validation.xml'); - $this->cache->save($this->getSerializer()->serialize($this->_configFiles->toArray()), self::CACHE_KEY); + $this->cache->save($this->getSerializer()->serialize( + $this->_configFiles->toArray()), + self::CACHE_KEY + ); } else { $filesArray = $this->getSerializer()->unserialize($this->_configFiles); $this->_configFiles = $this->getFileIteratorFactory()->create(array_keys($filesArray)); @@ -121,7 +122,9 @@ public function getValidatorConfig() $this->_initializeConfigList(); $this->_initializeDefaultTranslator(); return $this->_objectManager->create( - \Magento\Framework\Validator\Config::class, ['configFiles' => $this->_configFiles]); + \Magento\Framework\Validator\Config::class, + ['configFiles' => $this->_configFiles] + ); } /** @@ -161,7 +164,9 @@ public function createValidator($entityName, $groupName, array $builderConfig = private function getSerializer() { if ($this->serializer === null) { - $this->serializer = $this->_objectManager->get(\Magento\Framework\Serialize\SerializerInterface::class); + $this->serializer = $this->_objectManager->get( + \Magento\Framework\Serialize\SerializerInterface::class + ); } return $this->serializer; } @@ -175,9 +180,10 @@ private function getSerializer() private function getFileIteratorFactory() { if ($this->fileIteratorFactory === null) { - $this->fileIteratorFactory = $this->_objectManager - ->get(\Magento\Framework\Config\FileIteratorFactory::class); + $this->fileIteratorFactory = $this->_objectManager->get( + \Magento\Framework\Config\FileIteratorFactory::class + ); } return $this->fileIteratorFactory; } -} +} \ No newline at end of file From bfef638cc2d487914ebc7bf7e5dacee843ed7119 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Fri, 14 Apr 2017 22:27:45 +0200 Subject: [PATCH 2/4] Added new lines to the end of the changed files. --- lib/internal/Magento/Framework/Validator/Builder.php | 2 +- .../Magento/Framework/Validator/Constraint/Property.php | 2 +- lib/internal/Magento/Framework/Validator/ConstraintFactory.php | 2 +- lib/internal/Magento/Framework/Validator/Factory.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/Validator/Builder.php b/lib/internal/Magento/Framework/Validator/Builder.php index 7340be51948a5..1bca50385bb45 100644 --- a/lib/internal/Magento/Framework/Validator/Builder.php +++ b/lib/internal/Magento/Framework/Validator/Builder.php @@ -351,4 +351,4 @@ protected function _applyArgumentsCallback(array $arguments) } return $arguments; } -} \ No newline at end of file +} diff --git a/lib/internal/Magento/Framework/Validator/Constraint/Property.php b/lib/internal/Magento/Framework/Validator/Constraint/Property.php index 04f0c95450b05..f4842e15ea32e 100644 --- a/lib/internal/Magento/Framework/Validator/Constraint/Property.php +++ b/lib/internal/Magento/Framework/Validator/Constraint/Property.php @@ -60,4 +60,4 @@ protected function _addMessages(array $messages) { $this->_messages[$this->_property] = $messages; } -} \ No newline at end of file +} diff --git a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php index 170d067e76e84..d90c4ee47338a 100644 --- a/lib/internal/Magento/Framework/Validator/ConstraintFactory.php +++ b/lib/internal/Magento/Framework/Validator/ConstraintFactory.php @@ -50,4 +50,4 @@ public function create(array $data = []) { return $this->_objectManager->create($this->_instanceName, $data); } -} \ No newline at end of file +} diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php index b2d34ff4cbcae..cc00a54250338 100644 --- a/lib/internal/Magento/Framework/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -186,4 +186,4 @@ private function getFileIteratorFactory() } return $this->fileIteratorFactory; } -} \ No newline at end of file +} From 62b3a287fc83cd46088721d34860e3efd0b59b45 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Mon, 17 Apr 2017 20:41:56 +0200 Subject: [PATCH 3/4] Fixed opening & closoing parenthesis coding violation --- lib/internal/Magento/Framework/Validator/Factory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Validator/Factory.php b/lib/internal/Magento/Framework/Validator/Factory.php index cc00a54250338..c7df8547fb4b3 100644 --- a/lib/internal/Magento/Framework/Validator/Factory.php +++ b/lib/internal/Magento/Framework/Validator/Factory.php @@ -78,8 +78,8 @@ protected function _initializeConfigList() $this->_configFiles = $this->cache->load(self::CACHE_KEY); if (!$this->_configFiles) { $this->_configFiles = $this->moduleReader->getConfigurationFiles('validation.xml'); - $this->cache->save($this->getSerializer()->serialize( - $this->_configFiles->toArray()), + $this->cache->save( + $this->getSerializer()->serialize($this->_configFiles->toArray()), self::CACHE_KEY ); } else { From 7d4ee3eaa226885717edd05006e9394e0150f262 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Mon, 17 Apr 2017 21:21:23 +0200 Subject: [PATCH 4/4] Fixed the broken build. Restored the $data string instead of pushing a fixed array into the constructor of the Property class. --- lib/internal/Magento/Framework/Validator/Builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Validator/Builder.php b/lib/internal/Magento/Framework/Validator/Builder.php index 1bca50385bb45..41be9346251ce 100644 --- a/lib/internal/Magento/Framework/Validator/Builder.php +++ b/lib/internal/Magento/Framework/Validator/Builder.php @@ -258,7 +258,7 @@ protected function _createConstraint(array $data) $result = new \Magento\Framework\Validator\Constraint\Property( $validator, $data['property'], - ['alias'] + $data['alias'] ); } else { $result = $this->_constraintFactory->create(['validator' => $validator, 'alias' => $data['alias']]);