forked from vimeo/psalm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionReturnTypeProviderEvent.php
90 lines (80 loc) · 2 KB
/
FunctionReturnTypeProviderEvent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace Psalm\Plugin\EventHandler\Event;
use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\StatementsSource;
final class FunctionReturnTypeProviderEvent
{
/**
* @var StatementsSource
*/
private $statements_source;
/**
* @var non-empty-string
*/
private $function_id;
/**
* @var PhpParser\Node\Expr\FuncCall
*/
private $stmt;
/**
* @var Context
*/
private $context;
/**
* @var CodeLocation
*/
private $code_location;
/**
* Use this hook for providing custom return type logic. If this plugin does not know what a function should
* return but another plugin may be able to determine the type, return null. Otherwise return a mixed union type
* if something should be returned, but can't be more specific.
*
* @param non-empty-string $function_id
* @internal
*/
public function __construct(
StatementsSource $statements_source,
string $function_id,
PhpParser\Node\Expr\FuncCall $stmt,
Context $context,
CodeLocation $code_location
) {
$this->statements_source = $statements_source;
$this->function_id = $function_id;
$this->stmt = $stmt;
$this->context = $context;
$this->code_location = $code_location;
}
public function getStatementsSource(): StatementsSource
{
return $this->statements_source;
}
/**
* @return non-empty-string
*/
public function getFunctionId(): string
{
return $this->function_id;
}
/**
* @return list<PhpParser\Node\Arg>
*/
public function getCallArgs(): array
{
return $this->stmt->getArgs();
}
public function getContext(): Context
{
return $this->context;
}
public function getCodeLocation(): CodeLocation
{
return $this->code_location;
}
public function getStmt(): PhpParser\Node\Expr\FuncCall
{
return $this->stmt;
}
}