Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] add exception when intl component not found#28513

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:masterfromronfroy:add-exception-on-the-validator-component
Sep 21, 2018
Merged

[Validator] add exception when intl component not found#28513

nicolas-grekas merged 1 commit intosymfony:masterfromronfroy:add-exception-on-the-validator-component
Sep 21, 2018

Conversation

@ronfroy
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT

@ronfroyronfroy changed the titleadd exception when intl component not found[Validator] add exception when intl component not foundSep 19, 2018
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good idea. Here are some comments.

*/
publicfunctionvalidate($value,Constraint$constraint)
{
if (!class_exists('Intl')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be Intl::class instead.

publicfunctionvalidate($value,Constraint$constraint)
{
if (!class_exists('Intl')) {
thrownewRuntimeException('symfony/intl is required to use the Country constraint');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

missing dot at end of message, also I'd suggest to be a little bit more explicit (same in other messages below):
The "symfony/intl" component is required to use the Country constraint.

@ronfroy
Copy link
ContributorAuthor

ronfroy commentedSep 19, 2018
edited
Loading

@nicolas-grekas fixed

@nicolas-grekasnicolas-grekas added this to thenext milestoneSep 19, 2018
}

if (!class_exists(Intl::class)) {
thrownewRuntimeException('The "symfony/intl" component is required to use the Country constraint.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

hmm, shouldn't it be aLogicException instead?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i think not, this is not a logic issue.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

looking at the code, we use LogicException quite often in similar situations, so could be worth for consistency at least (there are a few similar cases using RuntimeException, but they're not the majority and could be worth fixing)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would have usedRuntimeException too ... but if we useLogicException in similar situations, it's better to keep consistency.@ronfroy can you please update this? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

how can we useLogicException elsewhere if this PR introduces it as a new class?

For this case we use theRuntimeException already 👍

if (null ===$this->expressionLanguage) {
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
thrownewRuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
}
$this->expressionLanguage =newExpressionLanguage();
}
return$this->expressionLanguage;

}

if (!class_exists(Intl::class)) {
thrownewRuntimeException('The "symfony/intl" component is required to use the Country constraint.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would have usedRuntimeException too ... but if we useLogicException in similar situations, it's better to keep consistency.@ronfroy can you please update this? Thanks!

@ronfroy
Copy link
ContributorAuthor

done

@nicolas-grekas
Copy link
Member

can you update src/Symfony/Component/Validator/Constraints/BicValidator.php and src/Symfony/Component/Validator/Mapping/Factory/BlackHoleMetadataFactory.php to use the new exception also please?

@ronfroy
Copy link
ContributorAuthor

@nicolas-grekas done

@nicolas-grekas
Copy link
Member

and src/Symfony/Component/Validator/ValidatorBuilder.php

@ro0NL
Copy link
Contributor

for consitency we should change Runtime to Logic inEmailValidator, ExpressionValidator & ImageValidator too :)

{
/**
* @expectedException \LogicException
* @expectedException \Symfony\Component\Validator\Exception\LogicException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not sure about the trailing;

if (null ===$annotationReader) {
if (!class_exists('Doctrine\Common\Annotations\AnnotationReader') || !class_exists('Doctrine\Common\Cache\ArrayCache')) {
thrownew\RuntimeException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and doctrine/cache to be installed.');
if (!class_exists(Doctrine\Common\Annotations\AnnotationReader::class) || !class_exists(Doctrine\Common\Cache\ArrayCache::class)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be moved as "use" statements.

@nicolas-grekas
Copy link
Member

for consitency we should change Runtime to Logic in EmailValidator, ExpressionValidator & ImageValidator too :)

in another PR :)

@nicolas-grekas
Copy link
Member

Thank you@ronfroy.

@nicolas-grekasnicolas-grekas merged commitb6f29f4 intosymfony:masterSep 21, 2018
nicolas-grekas added a commit that referenced this pull requestSep 21, 2018
…(ronfroy)This PR was squashed before being merged into the 4.2-dev branch (closes#28513).Discussion----------[Validator] add exception when intl component not found| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| License       | MIT<!--Add some exception when the Intl component is not found but required on some constraints-->Commits-------b6f29f4 [Validator] add exception when intl component not found
@ronfroyronfroy deleted the add-exception-on-the-validator-component branchSeptember 21, 2018 11:38
nicolas-grekas added a commit that referenced this pull requestSep 24, 2018
…ro0NL)This PR was merged into the 4.2-dev branch.Discussion----------Favor LogicException for missing classes & functions| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes-ish| BC breaks?    | no-ish     <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets |#28513 (comment)| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features --><!--Write a short README entry for your feature/bugfix here (replace this comment block.)This will help people understand your PR and can be used as a start of the Doc PR.Additionally: - Bug fixes must be submitted against the lowest branch where they apply   (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch.-->Commits-------c762735 Favor LogicException for missing classes & functions
fabpot added a commit that referenced this pull requestSep 29, 2018
This PR was merged into the 4.2-dev branch.Discussion----------[Form] Check for Intl availibility| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no     <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->Same as#28513 for the form componentCommits-------73c688c [Form] Check for Intl availibility
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

+1 more reviewer

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

7 participants

@ronfroy@nicolas-grekas@ro0NL@javiereguiluz@chalasr@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp