2018-11-06 03:57:36 +01:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Internal\Analyzer;
|
|
|
|
|
2019-09-01 06:56:46 +02:00
|
|
|
use PhpParser;
|
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2018-11-06 03:57:36 +01:00
|
|
|
class ClosureAnalyzer extends FunctionLikeAnalyzer
|
|
|
|
{
|
2019-09-01 06:56:46 +02:00
|
|
|
/**
|
|
|
|
* @param PhpParser\Node\Expr\Closure|PhpParser\Node\Expr\ArrowFunction $function
|
|
|
|
* @param SourceAnalyzer $source [description]
|
|
|
|
*/
|
|
|
|
public function __construct(PhpParser\Node\FunctionLike $function, SourceAnalyzer $source)
|
2018-12-18 05:29:27 +01:00
|
|
|
{
|
|
|
|
$codebase = $source->getCodebase();
|
|
|
|
|
2019-11-04 21:14:07 +01:00
|
|
|
$function_id = \strtolower($source->getFilePath())
|
2018-12-18 05:29:27 +01:00
|
|
|
. ':' . $function->getLine()
|
|
|
|
. ':' . (int)$function->getAttribute('startFilePos')
|
|
|
|
. ':-:closure';
|
|
|
|
|
|
|
|
$storage = $codebase->getClosureStorage($source->getFilePath(), $function_id);
|
|
|
|
|
|
|
|
parent::__construct($function, $source, $storage);
|
|
|
|
}
|
2019-07-06 06:18:53 +02:00
|
|
|
|
|
|
|
public function getTemplateTypeMap()
|
|
|
|
{
|
|
|
|
return $this->source->getTemplateTypeMap();
|
|
|
|
}
|
2018-11-06 03:57:36 +01:00
|
|
|
}
|