Skip to content

Commit 96be53f

Browse files
Add test
1 parent 315cbb8 commit 96be53f

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Comparison;
4+
5+
use PHPStan\Analyser\RicherScopeGetTypeHelper;
6+
use PHPStan\Rules\Rule;
7+
use PHPStan\Testing\RuleTestCase;
8+
use function array_merge;
9+
10+
/**
11+
* @extends RuleTestCase<StrictComparisonOfDifferentTypesRule>
12+
*/
13+
class Bug14534Test extends RuleTestCase
14+
{
15+
16+
protected function getRule(): Rule
17+
{
18+
return new StrictComparisonOfDifferentTypesRule(
19+
self::getContainer()->getByType(RicherScopeGetTypeHelper::class),
20+
new PossiblyImpureTipHelper(true),
21+
true,
22+
true,
23+
true,
24+
);
25+
}
26+
27+
public function testRule(): void
28+
{
29+
$this->analyse([__DIR__ . '/data/bug-14534.php'], []);
30+
}
31+
32+
public static function getAdditionalConfigFiles(): array
33+
{
34+
return array_merge(
35+
parent::getAdditionalConfigFiles(),
36+
[__DIR__ . '/bug-14534.neon'],
37+
);
38+
}
39+
40+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
stubFiles:
3+
- data/bug-14534.stub
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Bug14534;
4+
5+
function test(\SplFileObject $spl): bool
6+
{
7+
if ($spl->key() === 1) {
8+
return $spl->key() === 1;
9+
}
10+
11+
return false;
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
/**
4+
* @phpstan-all-methods-impure
5+
*/
6+
class SplFileObject {}

0 commit comments

Comments
 (0)