Skip to content

Commit cd2b8eb

Browse files
Add non regression test
1 parent 6338a0d commit cd2b8eb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,11 @@ public function testBug11019(): void
10091009
$this->analyse([__DIR__ . '/data/bug-11019.php'], []);
10101010
}
10111011

1012+
public function testBug11485(): void
1013+
{
1014+
$this->analyse([__DIR__ . '/data/bug-11485.php'], []);
1015+
}
1016+
10121017
public function testBug12946(): void
10131018
{
10141019
$this->analyse([__DIR__ . '/data/bug-12946.php'], []);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug11485;
4+
5+
class Foo {
6+
7+
public function bar(string $value, bool $strict = true): bool {
8+
9+
$flags = $strict ? FILTER_NULL_ON_FAILURE : 0;
10+
$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, $flags);
11+
if ($result === null) throw new \Exception("not a boolean");
12+
13+
$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
14+
if ($result === null) throw new \Exception("not a boolean");
15+
16+
return $result;
17+
}
18+
}

0 commit comments

Comments
 (0)