1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Allow closures to contain templated @var docblocks

Fixes #1865
This commit is contained in:
Matthew Brown 2019-07-06 00:18:53 -04:00
parent d29c7b42d9
commit e6bd30cc0b
2 changed files with 25 additions and 0 deletions

View File

@ -19,4 +19,9 @@ class ClosureAnalyzer extends FunctionLikeAnalyzer
parent::__construct($function, $source, $storage);
}
public function getTemplateTypeMap()
{
return $this->source->getTemplateTypeMap();
}
}

View File

@ -1618,6 +1618,26 @@ class ClassTemplateTest extends TestCase
}
}',
],
'insideClosureVarTemplate' => [
'<?php
/**
* @template T of object
*/
class Foo {
/**
* @psalm-return callable(): ?T
*/
public function bar() {
return
/** @psalm-return ?T */
function() {
/** @psalm-var ?T */
$data = null;
return $data;
};
}
}',
]
];
}