Skip to content

Commit

Permalink
Use better replacement when analysing potentially-inherited templated…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
muglug committed Jul 3, 2020
1 parent 44d7f51 commit 5da2995
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,8 @@ public static function analyzeClassMethodReturnType(
$codebase,
null,
null,
null
null,
$original_fq_classlike_name
);
}

Expand Down
35 changes: 35 additions & 0 deletions tests/Template/ClassTemplateExtendsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,9 @@ public function __construct(array $elements = [])
$this->elements = $elements;
}
/**
* @psalm-suppress InvalidReturnType
*/
public function getIterator()
{
/**
Expand Down Expand Up @@ -4181,6 +4184,38 @@ public function foo($crudNew): void {
}
}'
],
'extendTemplateTypeInParamAsType' => [
'<?php
/**
* @template TKey as object
* @template-implements Operation<TKey>
*/
final class Apply implements Operation
{
/**
* @return \Closure(array<TKey>): void
*/
public function i(): Closure
{
return
/**
* @psalm-param array<TKey> $collection
*/
static function (array $collection): void{};
}
}
/**
* @template TKey as object
*/
interface Operation
{
/**
* @psalm-return \Closure(array<TKey>): void
*/
public function i(): Closure;
}'
],
];
}

Expand Down

0 comments on commit 5da2995

Please sign in to comment.