1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add separate undefined this property to demarcate those errors

This commit is contained in:
Matthew Brown 2016-08-08 16:06:28 -04:00
parent 902c05d3a7
commit daf49bdf0b
2 changed files with 31 additions and 9 deletions

View File

@ -0,0 +1,7 @@
<?php
namespace Psalm\Issue;
class UndefinedThisProperty extends UndefinedProperty
{
}

View File

@ -27,6 +27,7 @@ use Psalm\Issue\UndefinedClass;
use Psalm\Issue\UndefinedConstant;
use Psalm\Issue\UndefinedFunction;
use Psalm\Issue\UndefinedProperty;
use Psalm\Issue\UndefinedThisProperty;
use Psalm\Issue\UndefinedVariable;
use Psalm\Issue\TooFewArguments;
use Psalm\Issue\TooManyArguments;
@ -1152,15 +1153,29 @@ class StatementsChecker
);
if (!$class_properties || !isset($class_properties[$stmt->name])) {
if (IssueBuffer::accepts(
new UndefinedProperty(
'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined',
$this->_file_name,
$stmt->getLine()
),
$this->_suppressed_issues
)) {
return false;
if ($stmt->var->name === 'this') {
if (IssueBuffer::accepts(
new UndefinedThisProperty(
'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined',
$this->_file_name,
$stmt->getLine()
),
$this->_suppressed_issues
)) {
return false;
}
}
else {
if (IssueBuffer::accepts(
new UndefinedProperty(
'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined',
$this->_file_name,
$stmt->getLine()
),
$this->_suppressed_issues
)) {
return false;
}
}
return;