Skip to content

Commit

Permalink
Fix quotes in exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 16, 2020
1 parent dab46f5 commit 0a91b41
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Constraints/CallbackValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function validate($object, Constraint $constraint)
\call_user_func($method, $object, $this->context, $constraint->payload);
} elseif (null !== $object) {
if (!method_exists($object, $method)) {
throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s.', $method, \get_class($object)));
throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class "%s".', $method, \get_class($object)));
}

$reflMethod = new \ReflectionMethod($object, $method);
Expand Down
2 changes: 1 addition & 1 deletion Constraints/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function initializeNestedConstraints()
parent::initializeNestedConstraints();

if (!\is_array($this->fields)) {
throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s.', __CLASS__));
throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint "%s".', __CLASS__));
}

foreach ($this->fields as $fieldName => $field) {
Expand Down
6 changes: 3 additions & 3 deletions Constraints/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public function __construct($options = null)
$constraint = \get_class($constraint);
}

throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s.', $constraint, static::class));
throw new ConstraintDefinitionException(sprintf('The value "%s" is not an instance of Constraint in constraint "%s".', $constraint, static::class));
}

if ($constraint instanceof Valid) {
throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', static::class));
throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint "%s". You can only declare the Valid constraint directly on a field or method.', static::class));
}
}

Expand All @@ -99,7 +99,7 @@ public function __construct($options = null)
$excessGroups = array_diff($constraint->groups, $this->groups);

if (\count($excessGroups) > 0) {
throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint %s should also be passed to its containing constraint %s.', implode('", "', $excessGroups), \get_class($constraint), static::class));
throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint "%s" should also be passed to its containing constraint "%s".', implode('", "', $excessGroups), \get_class($constraint), static::class));
}
} else {
$constraint->groups = $this->groups;
Expand Down
2 changes: 1 addition & 1 deletion Constraints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct($options = null)
parent::__construct($options);

if (null === $this->min && null === $this->max) {
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s.', __CLASS__), ['min', 'max']);
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint "%s".', __CLASS__), ['min', 'max']);
}
}
}
2 changes: 1 addition & 1 deletion Constraints/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($options = null)
parent::__construct($options);

if (null === $this->min && null === $this->max) {
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s.', __CLASS__), ['min', 'max']);
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint "%s".', __CLASS__), ['min', 'max']);
}
}
}
2 changes: 1 addition & 1 deletion Constraints/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($options = null)
parent::__construct($options);

if (null === $this->min && null === $this->max) {
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s.', __CLASS__), ['min', 'max']);
throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint "%s".', __CLASS__), ['min', 'max']);
}
}
}
2 changes: 1 addition & 1 deletion Constraints/Traverse.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Traverse extends Constraint
public function __construct($options = null)
{
if (\is_array($options) && \array_key_exists('groups', $options)) {
throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint %s.', __CLASS__));
throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint "%s".', __CLASS__));
}

parent::__construct($options);
Expand Down
2 changes: 1 addition & 1 deletion Constraints/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function validate($value, Constraint $constraint)
Url::CHECK_DNS_TYPE_SRV,
Url::CHECK_DNS_TYPE_TXT,
], true)) {
throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint %s.', \get_class($constraint)), ['checkDNS']);
throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint "%s".', \get_class($constraint)), ['checkDNS']);
}

$host = parse_url($value, PHP_URL_HOST);
Expand Down
2 changes: 1 addition & 1 deletion Mapping/Factory/LazyLoadingMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(LoaderInterface $loader = null, CacheInterface $cach
public function getMetadataFor($value)
{
if (!\is_object($value) && !\is_string($value)) {
throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s.', \gettype($value)));
throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: "%s".', \gettype($value)));
}

$class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\');
Expand Down
4 changes: 2 additions & 2 deletions Mapping/GetterMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function __construct($class, $property, $method = null)
} elseif (method_exists($class, $hasMethod)) {
$method = $hasMethod;
} else {
throw new ValidatorException(sprintf('Neither of these methods exist in class %s: %s, %s, %s.', $class, $getMethod, $isMethod, $hasMethod));
throw new ValidatorException(sprintf('Neither of these methods exist in class "%s": "%s", "%s", "%s".', $class, $getMethod, $isMethod, $hasMethod));
}
} elseif (!method_exists($class, $method)) {
throw new ValidatorException(sprintf('The %s() method does not exist in class %s.', $method, $class));
throw new ValidatorException(sprintf('The "%s()" method does not exist in class "%s".', $method, $class));
}

parent::__construct($class, $method, $property);
Expand Down
2 changes: 1 addition & 1 deletion Mapping/Loader/LoaderChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(array $loaders)
{
foreach ($loaders as $loader) {
if (!$loader instanceof LoaderInterface) {
throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface.', \get_class($loader)));
throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mapping/Loader/StaticMethodLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function loadClassMetadata(ClassMetadata $metadata)
}

if (!$reflMethod->isStatic()) {
throw new MappingException(sprintf('The method %s::%s should be static.', $reflClass->name, $this->methodName));
throw new MappingException(sprintf('The method "%s::%s()" should be static.', $reflClass->name, $this->methodName));
}

if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
Expand Down
2 changes: 1 addition & 1 deletion Mapping/MemberMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct($class, $name, $property)
public function addConstraint(Constraint $constraint)
{
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)));
throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on properties or getters.', \get_class($constraint)));
}

parent::addConstraint($constraint);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/FakeMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getMetadataFor($class)
}

if (!\is_string($class)) {
throw new NoSuchMetadataException(sprintf('No metadata for type %s', \gettype($class)));
throw new NoSuchMetadataException(sprintf('No metadata for type "%s".', \gettype($class)));
}

if (!isset($this->metadatas[$class])) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Mapping/GetterMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testGetPropertyValueFromHasser()
public function testUndefinedMethodNameThrowsException()
{
$this->expectException('Symfony\Component\Validator\Exception\ValidatorException');
$this->expectExceptionMessage('The hasLastName() method does not exist in class Symfony\Component\Validator\Tests\Fixtures\Entity.');
$this->expectExceptionMessage('The "hasLastName()" method does not exist in class "Symfony\Component\Validator\Tests\Fixtures\Entity".');
new GetterMetadata(self::CLASSNAME, 'lastName', 'hasLastName');
}
}

0 comments on commit 0a91b41

Please sign in to comment.