@@ 266-279 (lines=14) @@ | ||
263 | ||
264 | $first_appearance = $statements_analyzer->getFirstAppearance($use_var_id); |
|
265 | ||
266 | if ($first_appearance) { |
|
267 | if (IssueBuffer::accepts( |
|
268 | new PossiblyUndefinedVariable( |
|
269 | 'Possibly undefined variable ' . $use_var_id . ', first seen on line ' . |
|
270 | $first_appearance->getLineNumber(), |
|
271 | new CodeLocation($statements_analyzer->getSource(), $use->var) |
|
272 | ), |
|
273 | $statements_analyzer->getSuppressedIssues() |
|
274 | )) { |
|
275 | return false; |
|
276 | } |
|
277 | ||
278 | continue; |
|
279 | } |
|
280 | ||
281 | if ($context->check_variables) { |
|
282 | if (IssueBuffer::accepts( |
@@ 101-114 (lines=14) @@ | ||
98 | ||
99 | $property_id = $fq_class_name . '::$' . $prop_name; |
|
100 | ||
101 | if (!$codebase->properties->propertyExists($property_id, false, $statements_analyzer, $context)) { |
|
102 | if (IssueBuffer::accepts( |
|
103 | new UndefinedPropertyAssignment( |
|
104 | 'Static property ' . $property_id . ' is not defined', |
|
105 | new CodeLocation($statements_analyzer->getSource(), $stmt), |
|
106 | $property_id |
|
107 | ), |
|
108 | $statements_analyzer->getSuppressedIssues() |
|
109 | )) { |
|
110 | // fall through |
|
111 | } |
|
112 | ||
113 | return; |
|
114 | } |
|
115 | ||
116 | if (ClassLikeAnalyzer::checkPropertyVisibility( |
|
117 | $property_id, |
|
@@ 293-307 (lines=15) @@ | ||
290 | ||
291 | if (!$type_match_found && !$union_comparison_results->type_coerced) { |
|
292 | if (TypeAnalyzer::canBeContainedBy($codebase, $assignment_value_type, $class_property_type)) { |
|
293 | if (IssueBuffer::accepts( |
|
294 | new PossiblyInvalidPropertyAssignmentValue( |
|
295 | $var_id . ' with declared type \'' |
|
296 | . $class_property_type->getId() . '\' cannot be assigned type \'' |
|
297 | . $assignment_value_type->getId() . '\'', |
|
298 | new CodeLocation( |
|
299 | $statements_analyzer->getSource(), |
|
300 | $assignment_value ?: $stmt |
|
301 | ), |
|
302 | $property_id |
|
303 | ), |
|
304 | $statements_analyzer->getSuppressedIssues() |
|
305 | )) { |
|
306 | return false; |
|
307 | } |
|
308 | } else { |
|
309 | if (IssueBuffer::accepts( |
|
310 | new InvalidPropertyAssignmentValue( |
|
@@ 308-324 (lines=17) @@ | ||
305 | )) { |
|
306 | return false; |
|
307 | } |
|
308 | } else { |
|
309 | if (IssueBuffer::accepts( |
|
310 | new InvalidPropertyAssignmentValue( |
|
311 | $var_id . ' with declared type \'' . $class_property_type->getId() |
|
312 | . '\' cannot be assigned type \'' |
|
313 | . $assignment_value_type->getId() . '\'', |
|
314 | new CodeLocation( |
|
315 | $statements_analyzer->getSource(), |
|
316 | $assignment_value ?: $stmt |
|
317 | ), |
|
318 | $property_id |
|
319 | ), |
|
320 | $statements_analyzer->getSuppressedIssues() |
|
321 | )) { |
|
322 | return false; |
|
323 | } |
|
324 | } |
|
325 | } |
|
326 | ||
327 | if ($var_id) { |
@@ 355-366 (lines=12) @@ | ||
352 | return true; |
|
353 | } |
|
354 | ||
355 | if ($codebase->interfaceExists($fq_class_name)) { |
|
356 | if (IssueBuffer::accepts( |
|
357 | new InterfaceInstantiation( |
|
358 | 'Interface ' . $fq_class_name . ' cannot be instantiated', |
|
359 | new CodeLocation($statements_analyzer->getSource(), $stmt->class) |
|
360 | ), |
|
361 | $statements_analyzer->getSuppressedIssues() |
|
362 | )) { |
|
363 | } |
|
364 | ||
365 | return true; |
|
366 | } |
|
367 | } |
|
368 | ||
369 | if ($stmt->class instanceof PhpParser\Node\Stmt\Class_) { |
@@ 243-254 (lines=12) @@ | ||
240 | return true; |
|
241 | } |
|
242 | ||
243 | if (IssueBuffer::accepts( |
|
244 | new PossiblyUndefinedGlobalVariable( |
|
245 | 'Possibly undefined global variable ' . $var_name . ', first seen on line ' . |
|
246 | $first_appearance->getLineNumber(), |
|
247 | new CodeLocation($statements_analyzer->getSource(), $stmt), |
|
248 | $var_name |
|
249 | ), |
|
250 | $statements_analyzer->getSuppressedIssues(), |
|
251 | (bool) $statements_analyzer->getBranchPoint($var_name) |
|
252 | )) { |
|
253 | return true; |
|
254 | } |
|
255 | } else { |
|
256 | if ($codebase->alter_code) { |
|
257 | if (!isset($project_analyzer->getIssuesToFix()['PossiblyUndefinedVariable'])) { |
|
@@ 270-280 (lines=11) @@ | ||
267 | return true; |
|
268 | } |
|
269 | ||
270 | if (IssueBuffer::accepts( |
|
271 | new PossiblyUndefinedVariable( |
|
272 | 'Possibly undefined variable ' . $var_name . ', first seen on line ' . |
|
273 | $first_appearance->getLineNumber(), |
|
274 | new CodeLocation($statements_analyzer->getSource(), $stmt) |
|
275 | ), |
|
276 | $statements_analyzer->getSuppressedIssues(), |
|
277 | (bool) $statements_analyzer->getBranchPoint($var_name) |
|
278 | )) { |
|
279 | return false; |
|
280 | } |
|
281 | } |
|
282 | ||
283 | if ($codebase->store_node_types |