Skip to content

Fixed coding standard violations in the Framework\Validator namespace #9251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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