Skip to content

Commit

Permalink
attempt fixing issue #6973
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomulik committed Nov 22, 2021
1 parent a7b9a24 commit 4b8cadb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
28 changes: 12 additions & 16 deletions src/Psalm/Internal/Analyzer/MethodComparator.php
Expand Up @@ -980,23 +980,19 @@ private static function compareMethodDocblockReturnTypes(
$implementer_called_class_name
);

if (isset(
$implementer_called_class_storage->template_extended_params[$implementer_classlike_storage->name]
)) {
self::transformTemplates(
$implementer_called_class_storage->template_extended_params,
$implementer_classlike_storage->name,
$implementer_method_storage_return_type,
$codebase
);
self::transformTemplates(
$implementer_called_class_storage->template_extended_params,
$implementer_classlike_storage->name,
$implementer_method_storage_return_type,
$codebase
);

self::transformTemplates(
$implementer_called_class_storage->template_extended_params,
$guide_class_name,
$guide_method_storage_return_type,
$codebase
);
}
self::transformTemplates(
$implementer_called_class_storage->template_extended_params,
$guide_class_name,
$guide_method_storage_return_type,
$codebase
);
}

// treat void as null when comparing against docblock implementer
Expand Down
30 changes: 29 additions & 1 deletion tests/ReturnTypeTest.php
Expand Up @@ -1032,7 +1032,35 @@ public function __construct() {
$this->value = 123;
}
}'
]
],
'returnTypeOfAbstractMethodFromTemplatedTraitAndImplementationFromNonTemplatedTrait' => [
'<?php
trait ImplementorTrait {
/** @var int */
private $value;
public function getValue(): int {
return $this->value;
}
}
/** @psalm-template T */
trait GuideTrait {
/** @psalm-return T */
abstract public function getValue();
}
class Test {
use ImplementorTrait;
/** @template-use GuideTrait<int> */
use GuideTrait;
public function __construct() {
$this->value = 123;
}
}'
],
];
}

Expand Down

0 comments on commit 4b8cadb

Please sign in to comment.