Skip to content

Commit ad4d9c0

Browse files
Apply suggestions from code review
Revert strictness tests for default ifTrue and ifFalse Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
1 parent e7789e1 commit ad4d9c0

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function always(?\Closure $then = null): static
6161
*/
6262
public function ifTrue(?\Closure $closure = null): static
6363
{
64-
$this->ifPart = $closure ?? static fn ($v) => (bool) $v;
64+
$this->ifPart = $closure ?? static fn ($v) => true === $v;
6565
$this->allowedTypes = self::TYPE_ANY;
6666

6767
return $this;
@@ -76,7 +76,7 @@ public function ifTrue(?\Closure $closure = null): static
7676
*/
7777
public function ifFalse(?\Closure $closure = null): static
7878
{
79-
$this->ifPart = $closure ? static fn ($v) => ! $closure($v) : static fn ($v) => ! $v;
79+
$this->ifPart = $closure ? static fn ($v) => !$closure($v) : static fn ($v) => false === $v;
8080
$this->allowedTypes = self::TYPE_ANY;
8181

8282
return $this;

src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public function testIfTrueExpression()
3636
->end();
3737
$this->assertFinalizedValueIs('new_value', $test, ['key' => true]);
3838

39-
$test = $this->getTestBuilder()
40-
->ifTrue()
41-
->then($this->returnClosure('new_value'))
42-
->end();
43-
$this->assertFinalizedValueIs('new_value', $test, ['key' => 1]);
44-
4539
$test = $this->getTestBuilder()
4640
->ifTrue(fn () => true)
4741
->then($this->returnClosure('new_value'))
@@ -75,12 +69,6 @@ public function testIfFalseExpression()
7569
->end();
7670
$this->assertFinalizedValueIs('new_value', $test, ['key' => false]);
7771

78-
$test = $this->getTestBuilder()
79-
->ifFalse()
80-
->then($this->returnClosure('new_value'))
81-
->end();
82-
$this->assertFinalizedValueIs('new_value', $test, ['key' => 0]);
83-
8472
$test = $this->getTestBuilder()
8573
->ifFalse(fn ($v) => 'value' === $v)
8674
->then($this->returnClosure('new_value'))

0 commit comments

Comments
 (0)