Skip to content

Commit

Permalink
TemplateType - fix description for subtracted mixed bound
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 5, 2022
1 parent 7d4fa3d commit 6525d68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Type/Generic/TemplateTypeTrait.php
Expand Up @@ -48,7 +48,8 @@ public function getBound(): Type
public function describe(VerbosityLevel $level): string
{
$basicDescription = function () use ($level): string {
if ($this->bound instanceof MixedType) { // @phpstan-ignore-line
// @phpstan-ignore-next-line
if ($this->bound instanceof MixedType && $this->bound->getSubtractedType() === null && !$this->bound instanceof TemplateMixedType) {
$boundDescription = '';
} else { // @phpstan-ignore-line
$boundDescription = sprintf(' of %s', $this->bound->describe($level));
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Methods/data/bug-6635.php
Expand Up @@ -23,10 +23,10 @@ protected function sayHelloBug(mixed $block): mixed {
assertType('Bug6635\A&T (method Bug6635\HelloWorld::sayHelloBug(), argument)', $block);
echo 1;
} else {
assertType('T (method Bug6635\HelloWorld::sayHelloBug(), argument)', $block);
assertType('T of mixed~Bug6635\A (method Bug6635\HelloWorld::sayHelloBug(), argument)', $block);
}

assertType('(Bug6635\A&T (method Bug6635\HelloWorld::sayHelloBug(), argument))|T (method Bug6635\HelloWorld::sayHelloBug(), argument)', $block);
assertType('(Bug6635\A&T (method Bug6635\HelloWorld::sayHelloBug(), argument))|T of mixed~Bug6635\A (method Bug6635\HelloWorld::sayHelloBug(), argument)', $block);

return $block;
}
Expand Down

0 comments on commit 6525d68

Please sign in to comment.