Skip to content

Commit cbfaca2

Browse files
artyuumfabpot
authored andcommitted
Add "composer require..." in all exception messages when needed
1 parent 1893c77 commit cbfaca2

File tree

8 files changed

+7
-19
lines changed

8 files changed

+7
-19
lines changed

Constraints/AbstractComparison.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(mixed $value = null, string $propertyPath = null, st
5050
}
5151

5252
if (null !== $this->propertyPath && !class_exists(PropertyAccess::class)) {
53-
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option.', static::class));
53+
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "propertyPath" option. Try running "composer require symfony/property-access".', static::class));
5454
}
5555
}
5656

Constraints/Bic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct(array $options = null, string $message = null, strin
6969
}
7070

7171
if (null !== $this->ibanPropertyPath && !class_exists(PropertyAccess::class)) {
72-
throw new LogicException(sprintf('The "symfony/property-access" component is required to use the "%s" constraint with the "ibanPropertyPath" option.', self::class));
72+
throw new LogicException(sprintf('The "symfony/property-access" component is required to use the "%s" constraint with the "ibanPropertyPath" option. Try running "composer require symfony/property-access".', self::class));
7373
}
7474
}
7575
}

Constraints/BicValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private function getPropertyAccessor(): PropertyAccessor
159159
{
160160
if (null === $this->propertyAccessor) {
161161
if (!class_exists(PropertyAccess::class)) {
162-
throw new LogicException('Unable to use property path as the Symfony PropertyAccess component is not installed.');
162+
throw new LogicException('Unable to use property path as the Symfony PropertyAccess component is not installed. Try running "composer require symfony/property-access".');
163163
}
164164
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
165165
}

Constraints/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(
7878
}
7979

8080
if (self::VALIDATION_MODE_STRICT === $this->mode && !class_exists(StrictEmailValidator::class)) {
81-
throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__));
81+
throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode. Try running "composer require egulias/email-validator".', __CLASS__));
8282
}
8383

8484
if (null !== $this->normalizer && !\is_callable($this->normalizer)) {

Constraints/EmailValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function validate(mixed $value, Constraint $constraint)
7979

8080
if (null === $constraint->mode) {
8181
if (Email::VALIDATION_MODE_STRICT === $this->defaultMode && !class_exists(EguliasEmailValidator::class)) {
82-
throw new LogicException(sprintf('The "egulias/email-validator" component is required to make the "%s" constraint default to strict mode.', Email::class));
82+
throw new LogicException(sprintf('The "egulias/email-validator" component is required to make the "%s" constraint default to strict mode. Try running "composer require egulias/email-validator".', Email::class));
8383
}
8484

8585
$constraint->mode = $this->defaultMode;

Constraints/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(
5252
bool $negate = null,
5353
) {
5454
if (!class_exists(ExpressionLanguage::class)) {
55-
throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__));
55+
throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint. Try running "composer require symfony/expression-language".', __CLASS__));
5656
}
5757

5858
if (\is_array($expression)) {

Constraints/Range.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function __construct(
9292
}
9393

9494
if ((null !== $this->minPropertyPath || null !== $this->maxPropertyPath) && !class_exists(PropertyAccess::class)) {
95-
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option.', static::class));
95+
throw new LogicException(sprintf('The "%s" constraint requires the Symfony PropertyAccess component to use the "minPropertyPath" or "maxPropertyPath" option. Try running "composer require symfony/property-access".', static::class));
9696
}
9797

9898
if (null !== $this->min && null !== $this->max && ($minMessage || $maxMessage)) {

composer.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@
5454
"symfony/translation": "<5.4",
5555
"symfony/yaml": "<5.4"
5656
},
57-
"suggest": {
58-
"psr/cache-implementation": "For using the mapping cache.",
59-
"symfony/http-foundation": "",
60-
"symfony/intl": "",
61-
"symfony/translation": "For translating validation errors.",
62-
"symfony/yaml": "",
63-
"symfony/config": "",
64-
"egulias/email-validator": "Strict (RFC compliant) email validation",
65-
"symfony/property-access": "For accessing properties within comparison constraints",
66-
"symfony/property-info": "To automatically add NotNull and Type constraints",
67-
"symfony/expression-language": "For using the Expression validator and the ExpressionLanguageSyntax constraints"
68-
},
6957
"autoload": {
7058
"psr-4": { "Symfony\\Component\\Validator\\": "" },
7159
"exclude-from-classmap": [

0 commit comments

Comments
 (0)