Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public function testBug13001(): void
]);
}

public function testBug9386(): void
{
$this->analyse([__DIR__ . '/data/bug-9386.php'], []);
}

public function testBug7280Comment(): void
{
$this->analyse([__DIR__ . '/data/bug-7280-comment.php'], []);
Expand Down
29 changes: 29 additions & 0 deletions tests/PHPStan/Rules/Operators/data/bug-9386.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php // lint >= 8.0

declare(strict_types = 1);

namespace Bug9386;

trait BaseTrait {
protected false|int $_pos;

public function myMethod():bool {
$pos = $this->_pos;
if ($pos === false)
return false;
if (($this instanceof BaseClass) && $this->length !== null)
return $pos >= $this->offset + $this->length;
return false;
}
}

class BaseClass
{
use BaseTrait;
protected ?int $length = null;
protected int $offset = 0;
}
class SecondClass
{
use BaseTrait;
}
Loading