You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor symfony#59995 [Config] Make ifFalse() consistent between value and closure based checks (arjenm)
This PR was squashed before being merged into the 7.3 branch.
Discussion
----------
[Config] Make ifFalse() consistent between value and closure based checks
| Q | A
| ------------- | ---
| Branch? | 7.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fixsymfony#59325
| License | MIT
I noticed the Config/ExpBuilder got a nice new ifFalse in Symfony 7.3.
But I think its implementation is confusing.
The behavior for `ifTrue()` was:
- If no closure is provided: if the actual value is `true` execute the then part
- If a closure is provided: if it returns `true` execute the then part
The behavior for `ifFalse()` is prior to this PR is:
- If no closure is provided: if the actual value is `false` execute the then part
- If a closure is provided: if it returns **`true`** execute the then part
With this PR it becomes:
- If no closure is provided: if the actual value is `false` execute the then part
- If a closure is provided: if it returns **`false`** execute the then part
Rationale, I think people (me included) would not expect these to be both be valid or invalid with the same input:
`$expr->ifTrue(self::valueIsNotValid(...))->thenInvalid()`
`$expr->ifFalse(self::valueIsNotValid(...))->thenInvalid()`
They/I expect to have to change it to a test for valid values (rather than invalid ones):
`$expr->ifFalse(self::valueIsValid(...))->thenInvalid()`
Commits
-------
335bdbe [Config] Make ifFalse() consistent between value and closure based checks
0 commit comments