1 | <?php |
||
28 | class RuntimeException extends \RuntimeException implements ExceptionInterface |
||
29 | { |
||
30 | /** |
||
31 | * Path to the parsed file. |
||
32 | * |
||
33 | * @var string $parsedFile |
||
34 | * |
||
35 | * @since 0.2.8 |
||
36 | */ |
||
37 | private $parsedFile = null; |
||
38 | |||
39 | /** |
||
40 | * Parsed line number. |
||
41 | * |
||
42 | * @var int $parsedLine |
||
43 | * |
||
44 | * @since 0.2.8 |
||
45 | */ |
||
46 | private $parsedLine = 0; |
||
47 | |||
48 | /** |
||
49 | * Snippet. |
||
50 | * |
||
51 | * @var string|null $snippet |
||
52 | * |
||
53 | * @since 0.2.8 |
||
54 | */ |
||
55 | private $snippet = null; |
||
56 | |||
57 | /** |
||
58 | * Raw error message. |
||
59 | * |
||
60 | * @var string $rawMessage |
||
61 | * |
||
62 | * @since 0.2.8 |
||
63 | */ |
||
64 | private $rawMessage = null; |
||
65 | |||
66 | /** |
||
67 | * Constructor. |
||
68 | * |
||
69 | * @param string $message Error message |
||
70 | * @param int $parsed_line Line where the error occurred |
||
71 | * @param string|int|null $snippet Snippet of code near the problem |
||
72 | * @param string $parsed_file File name where the error occurred |
||
73 | * @param Exception $previous The previous exception |
||
74 | * |
||
75 | * @codeCoverageIgnore |
||
76 | */ |
||
77 | public function __construct( |
||
93 | |||
94 | /** |
||
95 | * Gets the snippet of code near the error. |
||
96 | * |
||
97 | * @return string The snippet of code |
||
98 | * @codeCoverageIgnore |
||
99 | */ |
||
100 | public function getSnippet() |
||
104 | |||
105 | /** |
||
106 | * Sets the snippet of code near the error. |
||
107 | * |
||
108 | * @param string $snippet The code snippet |
||
109 | * |
||
110 | * @return void Void |
||
111 | * @codeCoverageIgnore |
||
112 | */ |
||
113 | public function setSnippet($snippet) |
||
119 | |||
120 | /** |
||
121 | * Gets the filename where the error occurred. |
||
122 | * |
||
123 | * This method returns null if a string is parsed. |
||
124 | * |
||
125 | * @return string The filename |
||
126 | * @codeCoverageIgnore |
||
127 | */ |
||
128 | public function getParsedFile() |
||
132 | |||
133 | /** |
||
134 | * Sets the filename where the error occurred. |
||
135 | * |
||
136 | * @param string $parsed_file The filename |
||
137 | * |
||
138 | * @return void Void |
||
139 | * @codeCoverageIgnore |
||
140 | */ |
||
141 | public function setParsedFile($parsed_file = null) |
||
147 | |||
148 | /** |
||
149 | * Gets the line where the error occurred. |
||
150 | * |
||
151 | * @return int The file line |
||
152 | * |
||
153 | * @codeCoverageIgnore |
||
154 | */ |
||
155 | public function getParsedLine() |
||
159 | |||
160 | /** |
||
161 | * Sets the line where the error occurred. |
||
162 | * |
||
163 | * @param int $parsed_line The file line |
||
164 | * |
||
165 | * @return void Void |
||
166 | * @codeCoverageIgnore |
||
167 | */ |
||
168 | public function setParsedLine($parsed_line = 0) |
||
174 | |||
175 | /** |
||
176 | * Update message. |
||
177 | * |
||
178 | * @return void Void |
||
179 | * @codeCoverageIgnore |
||
180 | */ |
||
181 | private function updateRepr() |
||
214 | } |
||
215 | |||
217 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.