Skip to content

Commit c82e555

Browse files
Add non regression test for issue #9386
1 parent 40f22c1 commit c82e555

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php // lint >= 8.0
2+
3+
declare(strict_types = 1);
4+
5+
namespace Bug9386;
6+
7+
trait BaseTrait {
8+
protected false|int $_pos;
9+
10+
public function myMethod():bool {
11+
$pos = $this->_pos;
12+
if ($pos === false)
13+
return false;
14+
if (($this instanceof BaseClass) && $this->length !== null)
15+
return $pos >= $this->offset + $this->length;
16+
return false;
17+
}
18+
}
19+
20+
class BaseClass
21+
{
22+
use BaseTrait;
23+
protected ?int $length = null;
24+
protected int $offset = 0;
25+
}
26+
class SecondClass
27+
{
28+
use BaseTrait;
29+
}

0 commit comments

Comments
 (0)