Skip to content

Conversation

fancyweb
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

The goal is to improve the DX (a little) with constraint violation lists.

I always find myself doing : if ($constraintViolationList->count() > 0) or if (0 === $constraintViolationList->count())

It would be nice if we could do : if (!$constraintViolationList->isEmpty()) or if ($constraintViolationList->isEmpty())

hasViolations() could be an alternative name but isEmpty() is a common name used in many places in Sf code, so it seems more logical to me.

@carsonbot carsonbot added Status: Needs Review Validator DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature Deprecation labels Jul 25, 2019
@nicolas-grekas nicolas-grekas added this to the next milestone Jul 25, 2019
@fancyweb fancyweb force-pushed the is-empty-constraint-violation-list branch from 785ca88 to 2e004f7 Compare July 30, 2019 21:00
@fancyweb fancyweb force-pushed the is-empty-constraint-violation-list branch from 2e004f7 to 7fec655 Compare July 31, 2019 12:13
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 31, 2019

I'm challenging this: this is the same as if ([!]$constraintViolationList->count()).
Usually, we try to have one way to do something. Why not here?

@fancyweb
Copy link
Contributor Author

Let's close. If we add it here, we will have to add it on every collection that have a count() method. I'm 👍 for this but I recognize it's kinda useless.
Looks like I have to accept to simply use non strict comparisons on booleans.

@fancyweb fancyweb closed this Jul 31, 2019
@fancyweb fancyweb deleted the is-empty-constraint-violation-list branch July 31, 2019 13:50
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecation DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature Status: Reviewed Validator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants