Skip to content

Commit d604418

Browse files
Add non regression test for 9386
1 parent 8996d39 commit d604418

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/PHPStan/Rules/Operators/InvalidComparisonOperationRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ public function testBug13001(): void
205205
]);
206206
}
207207

208+
public function testBug9386(): void
209+
{
210+
$this->analyse([__DIR__ . '/data/bug-9386.php'], []);
211+
}
212+
208213
public function testBug7280Comment(): void
209214
{
210215
$this->analyse([__DIR__ . '/data/bug-7280-comment.php'], []);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug9386;
4+
5+
trait BaseTrait {
6+
protected false|int $_pos;
7+
8+
public function myMethod():bool {
9+
$pos = $this->_pos;
10+
if ($pos === false)
11+
return false;
12+
if (($this instanceof BaseClass) && $this->length !== null)
13+
return $pos >= $this->offset + $this->length;
14+
return false;
15+
}
16+
}
17+
18+
class BaseClass
19+
{
20+
use BaseTrait;
21+
protected ?int $length = null;
22+
protected int $offset = 0;
23+
}
24+
class SecondClass
25+
{
26+
use BaseTrait;
27+
}

0 commit comments

Comments
 (0)