Skip to content

Commit

Permalink
[Validator] fixed CS
Browse files Browse the repository at this point in the history
  • Loading branch information
hason committed Mar 31, 2011
1 parent 134d022 commit 47cb866
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ abstract class Constraint
public function __construct($options = null)
{
$invalidOptions = array();
$missingOptions = array_flip((array)$this->getRequiredOptions());
$missingOptions = array_flip((array) $this->getRequiredOptions());

if (is_array($options) && count($options) == 1 && isset($options['value'])) {
$options = $options['value'];
Expand Down Expand Up @@ -127,7 +127,7 @@ public function __construct($options = null)
);
}

$this->groups = (array)$this->groups;
$this->groups = (array) $this->groups;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Constraints/CountryValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!in_array($value, \Symfony\Component\Locale\Locale::getCountries())) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/DateTimeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!preg_match(self::PATTERN, $value, $matches)) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/DateValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!preg_match(self::PATTERN, $value, $matches)) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/EmailValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
8 changes: 4 additions & 4 deletions Constraints/FileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function isValid($value, Constraint $constraint)
return true;
}

$path = $value instanceof FileObject ? $value->getPath() : (string)$value;
$path = $value instanceof FileObject ? $value->getPath() : (string) $value;

if (!file_exists($path)) {
$this->setMessage($constraint->notFoundMessage, array('{{ file }}' => $path));
Expand All @@ -48,7 +48,7 @@ public function isValid($value, Constraint $constraint)
}

if ($constraint->maxSize) {
if (ctype_digit((string)$constraint->maxSize)) {
if (ctype_digit((string) $constraint->maxSize)) {
$size = filesize($path);
$limit = $constraint->maxSize;
$suffix = ' bytes';
Expand Down Expand Up @@ -80,10 +80,10 @@ public function isValid($value, Constraint $constraint)
$value = new FileObject($value);
}

if (!in_array($value->getMimeType(), (array)$constraint->mimeTypes)) {
if (!in_array($value->getMimeType(), (array) $constraint->mimeTypes)) {
$this->setMessage($constraint->mimeTypesMessage, array(
'{{ type }}' => '"'.$value->getMimeType().'"',
'{{ types }}' => '"'.implode('", "', (array)$constraint->mimeTypes).'"',
'{{ types }}' => '"'.implode('", "', (array) $constraint->mimeTypes).'"',
'{{ file }}' => $path,
));

Expand Down
2 changes: 1 addition & 1 deletion Constraints/IpValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;
$valid = false;

if ($constraint->version == Ip::V4 || $constraint->version == Ip::ALL) {
Expand Down
2 changes: 1 addition & 1 deletion Constraints/LanguageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!in_array($value, \Symfony\Component\Locale\Locale::getLanguages())) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/LocaleValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!in_array($value, \Symfony\Component\Locale\Locale::getLocales())) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/MaxLengthValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

$length = function_exists('mb_strlen') ? mb_strlen($value, $constraint->charset) : strlen($value);

Expand Down
2 changes: 1 addition & 1 deletion Constraints/MinLengthValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

$length = function_exists('mb_strlen') ? mb_strlen($value, $constraint->charset) : strlen($value);

Expand Down
2 changes: 1 addition & 1 deletion Constraints/RegexValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (
($constraint->match && !preg_match($constraint->pattern, $value))
Expand Down
2 changes: 1 addition & 1 deletion Constraints/TimeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

if (!preg_match(self::PATTERN, $value)) {
$this->setMessage($constraint->message, array('{{ value }}' => $value));
Expand Down
2 changes: 1 addition & 1 deletion Constraints/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function isValid($value, Constraint $constraint)
throw new UnexpectedTypeException($value, 'string');
}

$value = (string)$value;
$value = (string) $value;

$pattern = sprintf(self::PATTERN, implode('|', $constraint->protocols));

Expand Down
2 changes: 1 addition & 1 deletion Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getDefaultGroup()
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::CLASS_CONSTRAINT, (array)$constraint->getTargets())) {
if (!in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint %s cannot be put on classes',
get_class($constraint)
Expand Down
2 changes: 1 addition & 1 deletion Mapping/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct($file)
protected function newConstraint($name, $options)
{
if (strpos($name, '\\') !== false && class_exists($name)) {
$className = (string)$name;
$className = (string) $name;
} else if (strpos($name, ':') !== false) {
list($prefix, $className) = explode(':', $name);

Expand Down
14 changes: 7 additions & 7 deletions Mapping/Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function loadClassMetadata(ClassMetadata $metadata)
$xml = $this->parseFile($this->file);

foreach ($xml->namespace as $namespace) {
$this->namespaces[(string)$namespace['prefix']] = trim((string)$namespace);
$this->namespaces[(string) $namespace['prefix']] = trim((string) $namespace);
}

foreach ($xml->class as $class) {
$this->classes[(string)$class['name']] = $class;
$this->classes[(string) $class['name']] = $class;
}
}

Expand All @@ -49,13 +49,13 @@ public function loadClassMetadata(ClassMetadata $metadata)

foreach ($xml->property as $property) {
foreach ($this->parseConstraints($property->constraint) as $constraint) {
$metadata->addPropertyConstraint((string)$property['name'], $constraint);
$metadata->addPropertyConstraint((string) $property['name'], $constraint);
}
}

foreach ($xml->getter as $getter) {
foreach ($this->parseConstraints($getter->constraint) as $constraint) {
$metadata->addGetterConstraint((string)$getter['property'], $constraint);
$metadata->addGetterConstraint((string) $getter['property'], $constraint);
}
}

Expand Down Expand Up @@ -87,7 +87,7 @@ protected function parseConstraints(\SimpleXMLElement $nodes)
} else {
$options = array();
}
} else if (strlen((string)$node) > 0) {
} else if (strlen((string) $node) > 0) {
$options = trim($node);
} else {
$options = null;
Expand Down Expand Up @@ -124,7 +124,7 @@ protected function parseValues(\SimpleXMLElement $nodes)
}

if (isset($node['key'])) {
$values[(string)$node['key']] = $value;
$values[(string) $node['key']] = $value;
} else {
$values[] = $value;
}
Expand Down Expand Up @@ -157,7 +157,7 @@ protected function parseOptions(\SimpleXMLElement $nodes)
$value = trim($node);
}

$options[(string)$node['name']] = $value;
$options[(string) $node['name']] = $value;
}

return $options;
Expand Down
2 changes: 1 addition & 1 deletion Mapping/MemberMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($class, $name, $property)
*/
public function addConstraint(Constraint $constraint)
{
if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array)$constraint->getTargets())) {
if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) {
throw new ConstraintDefinitionException(sprintf(
'The constraint %s cannot be put on properties or getters',
get_class($constraint)
Expand Down
2 changes: 1 addition & 1 deletion Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function validateValue($value, Constraint $constraint, $groups = null)
protected function validateGraph($root, \Closure $walk, $groups = null)
{
$walker = new GraphWalker($root, $this->metadataFactory, $this->validatorFactory);
$groups = $groups ? (array)$groups : array(Constraint::DEFAULT_GROUP);
$groups = $groups ? (array) $groups : array(Constraint::DEFAULT_GROUP);

foreach ($groups as $group) {
$walk($walker, $group);
Expand Down

0 comments on commit 47cb866

Please sign in to comment.