Skip to content

Commit

Permalink
MAGETWO-67508: Fixed coding standard violations in the Framework\Vali…
Browse files Browse the repository at this point in the history
…dator namespace #9251
  • Loading branch information
Oleksii Korshenko authored Jun 13, 2017
2 parents 8a702c8 + b5aceb5 commit 7e6f8ae
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
19 changes: 13 additions & 6 deletions lib/internal/Magento/Framework/Validator/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Validator;

use Magento\Framework\Validator\Constraint\OptionInterface;
Expand Down Expand Up @@ -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'],
$data['alias']
);
} else {
$result = $this->_constraintFactory->create(['validator' => $validator, 'alias' => $data['alias']]);
}
Expand Down Expand Up @@ -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']
)
);
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Validator\Constraint;

class Property extends \Magento\Framework\Validator\Constraint
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/**
* Factory class for \Magento\Framework\Validator\Constraint
*/
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 17 additions & 11 deletions lib/internal/Magento/Framework/Validator/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__;

/**
Expand Down Expand Up @@ -73,14 +69,19 @@ public function __construct(

/**
* Init cached list of validation files
*
* @return void
*/
protected function _initializeConfigList()
{
if (!$this->_configFiles) {
$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));
Expand Down Expand Up @@ -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]
);
}

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -175,8 +180,9 @@ 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;
}
Expand Down

0 comments on commit 7e6f8ae

Please sign in to comment.