Skip to content
Permalink
Browse files

Allow closures to contain templated @var docblocks

Fixes #1865
  • Loading branch information...
muglug committed Jul 6, 2019
1 parent d29c7b4 commit e6bd30cc0b85afb224abb24ae02af119122f02d5
Showing with 25 additions and 0 deletions.
  1. +5 −0 src/Psalm/Internal/Analyzer/ClosureAnalyzer.php
  2. +20 −0 tests/Template/ClassTemplateTest.php
@@ -19,4 +19,9 @@ public function __construct(\PhpParser\Node\Expr\Closure $function, SourceAnalyz
parent::__construct($function, $source, $storage);
}
public function getTemplateTypeMap()
{
return $this->source->getTemplateTypeMap();
}
}
@@ -1618,6 +1618,26 @@ public function __construct() {
}
}',
],
'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;
};
}
}',
]
];
}

0 comments on commit e6bd30c

Please sign in to comment.
You can’t perform that action at this time.