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
9 changes: 9 additions & 0 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4560,6 +4560,15 @@ public function testBug15251(): void
$this->analyse([__DIR__ . '/data/bug-15251.php'], []);
}

#[RequiresPhp('>= 8.0.0')]
public function testBug12820(): void
{
$this->checkThisOnly = false;
$this->checkNullables = true;
$this->checkUnionTypes = true;
$this->analyse([__DIR__ . '/data/bug-12820.php'], []);
}

#[RequiresPhp('>= 8.1.0')]
public function testClassConstantWildcardArguments(): void
{
Expand Down
49 changes: 49 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-12820.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php // lint >= 8.0

declare(strict_types = 1);

namespace Bug12820;

class A
{

public function a(): void
{
}

}

class B
{

}

/** @template-covariant T of A|B = A|B */
interface FooInterface
{

/**
* @phpstan-assert-if-true static<A> $this
*/
public function isA(): bool;

/** @return T */
public function get(): A|B;

}

/**
* @template-covariant T of A|B = A|B
* @implements FooInterface<T>
*/
abstract class Foo implements FooInterface
{

public function other(): void
{
if ($this->isA()) {
$this->get()->a();
}
}

}
Loading