Repository navigation
Expand file tree
/
Copy pathCatchTypeNode.php
More file actions
79 lines (67 loc) · 1.59 KB
/
Copy pathCatchTypeNode.php
File metadata and controls
79 lines (67 loc) · 1.59 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
<?php declare(strict_types = 1);
namespace PHPStan\Node;
use Override;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Catch_;
use PhpParser\NodeAbstract;
use PHPStan\Turbo\ReferencedByTurboExtension;
use PHPStan\Type\Type;
/**
* Virtual node emitted once for each type in a `catch` clause, whether or not
* the try block can throw it - unlike CatchWithUnthrownExceptionNode, which is
* emitted only for the dead ones. Rules analysing a trait need both outcomes
* to tell whether a catch is dead in every class using it.
*
* @api
*/
#[ReferencedByTurboExtension(key: 'catchTypeNode')]
final class CatchTypeNode extends NodeAbstract implements VirtualNode
{
public function __construct(
private Catch_ $originalNode,
private Name $typeNode,
private Type $caughtType,
private Type $originalCaughtType,
private bool $thrown,
)
{
parent::__construct($originalNode->getAttributes());
}
public function getOriginalNode(): Catch_
{
return $this->originalNode;
}
public function getTypeNode(): Name
{
return $this->typeNode;
}
/**
* The caught type without the types caught by the preceding catch clauses;
* NeverType when they already catch all of it.
*/
public function getCaughtType(): Type
{
return $this->caughtType;
}
public function getOriginalCaughtType(): Type
{
return $this->originalCaughtType;
}
public function isThrown(): bool
{
return $this->thrown;
}
#[Override]
public function getType(): string
{
return 'PHPStan_Node_CatchTypeNode';
}
/**
* @return string[]
*/
#[Override]
public function getSubNodeNames(): array
{
return [];
}
}