/
Error.php
114 lines (91 loc) · 1.71 KB
/
Error.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php declare(strict_types = 1);
namespace PHPStan\Analyser;
class Error
{
/** @var string */
private $message;
/** @var string */
private $file;
/** @var int|NULL */
private $line;
/** @var bool */
private $canBeIgnored;
/** @var string|null */
private $filePath;
/** @var string|null */
private $traitFilePath;
/** @var string|null */
private $tip;
/** @var bool */
private $warning;
public function __construct(
string $message,
string $file,
?int $line = null,
bool $canBeIgnored = true,
?string $filePath = null,
?string $traitFilePath = null,
?string $tip = null,
bool $warning = false
)
{
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->canBeIgnored = $canBeIgnored;
$this->filePath = $filePath;
$this->traitFilePath = $traitFilePath;
$this->tip = $tip;
$this->warning = $warning;
}
public function getMessage(): string
{
return $this->message;
}
public function getFile(): string
{
return $this->file;
}
public function getFilePath(): string
{
if ($this->filePath === null) {
return $this->file;
}
return $this->filePath;
}
public function getTraitFilePath(): ?string
{
return $this->traitFilePath;
}
public function getLine(): ?int
{
return $this->line;
}
public function canBeIgnored(): bool
{
return $this->canBeIgnored;
}
public function getTip(): ?string
{
return $this->tip;
}
public function withoutTip(): self
{
if ($this->tip === null) {
return $this;
}
return new self(
$this->message,
$this->file,
$this->line,
$this->canBeIgnored,
$this->filePath,
$this->traitFilePath,
null
);
}
public function isWarning(): bool
{
return $this->warning;
}
}