-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathExpressionResult.php
More file actions
105 lines (85 loc) · 2.11 KB
/
ExpressionResult.php
File metadata and controls
105 lines (85 loc) · 2.11 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php declare(strict_types = 1);
namespace PHPStan\Analyser;
final class ExpressionResult
{
/** @var (callable(): MutatingScope)|null */
private $truthyScopeCallback;
private ?MutatingScope $truthyScope = null;
/** @var (callable(): MutatingScope)|null */
private $falseyScopeCallback;
private ?MutatingScope $falseyScope = null;
/**
* @param InternalThrowPoint[] $throwPoints
* @param ImpurePoint[] $impurePoints
* @param (callable(): MutatingScope)|null $truthyScopeCallback
* @param (callable(): MutatingScope)|null $falseyScopeCallback
*/
public function __construct(
private MutatingScope $scope,
private MutatingScope $beforeScope,
private bool $hasYield,
private bool $isAlwaysTerminating,
private array $throwPoints,
private array $impurePoints,
?callable $truthyScopeCallback = null,
?callable $falseyScopeCallback = null,
)
{
$this->truthyScopeCallback = $truthyScopeCallback;
$this->falseyScopeCallback = $falseyScopeCallback;
}
public function getScope(): MutatingScope
{
return $this->scope;
}
public function getBeforeScope(): MutatingScope
{
return $this->beforeScope;
}
public function hasYield(): bool
{
return $this->hasYield;
}
/**
* @return InternalThrowPoint[]
*/
public function getThrowPoints(): array
{
return $this->throwPoints;
}
/**
* @return ImpurePoint[]
*/
public function getImpurePoints(): array
{
return $this->impurePoints;
}
public function getTruthyScope(): MutatingScope
{
if ($this->truthyScopeCallback === null) {
return $this->scope;
}
if ($this->truthyScope !== null) {
return $this->truthyScope;
}
$callback = $this->truthyScopeCallback;
$this->truthyScope = $callback();
return $this->truthyScope;
}
public function getFalseyScope(): MutatingScope
{
if ($this->falseyScopeCallback === null) {
return $this->scope;
}
if ($this->falseyScope !== null) {
return $this->falseyScope;
}
$callback = $this->falseyScopeCallback;
$this->falseyScope = $callback();
return $this->falseyScope;
}
public function isAlwaysTerminating(): bool
{
return $this->isAlwaysTerminating;
}
}