1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00

Make UndefinedProperty issues more specific

This commit is contained in:
Matthew Brown 2016-10-10 19:29:38 -04:00
parent a30c82e5d7
commit 64b4adfb22
7 changed files with 37 additions and 21 deletions

View File

@ -38,8 +38,10 @@ use Psalm\Issue\TypeCoercion;
use Psalm\Issue\UndefinedClass; use Psalm\Issue\UndefinedClass;
use Psalm\Issue\UndefinedConstant; use Psalm\Issue\UndefinedConstant;
use Psalm\Issue\UndefinedFunction; use Psalm\Issue\UndefinedFunction;
use Psalm\Issue\UndefinedProperty; use Psalm\Issue\UndefinedPropertyAssignment;
use Psalm\Issue\UndefinedThisProperty; use Psalm\Issue\UndefinedPropertyFetch;
use Psalm\Issue\UndefinedThisPropertyAssignment;
use Psalm\Issue\UndefinedThisPropertyFetch;
use Psalm\Issue\UndefinedVariable; use Psalm\Issue\UndefinedVariable;
use Psalm\Type; use Psalm\Type;
@ -1505,7 +1507,7 @@ class StatementsChecker
if (!$class_properties || !isset($class_properties[$stmt->name])) { if (!$class_properties || !isset($class_properties[$stmt->name])) {
if ($stmt_var_id === 'this') { if ($stmt_var_id === 'this') {
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new UndefinedThisProperty( new UndefinedThisPropertyFetch(
'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined', 'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined',
$this->checked_file_name, $this->checked_file_name,
$stmt->getLine() $stmt->getLine()
@ -1517,7 +1519,7 @@ class StatementsChecker
} }
else { else {
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new UndefinedProperty( new UndefinedPropertyFetch(
'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined', 'Property ' . $lhs_type_part->value .'::$' . $stmt->name . ' is not defined',
$this->checked_file_name, $this->checked_file_name,
$stmt->getLine() $stmt->getLine()
@ -1724,7 +1726,7 @@ class StatementsChecker
if (!isset($class_properties[$prop_name])) { if (!isset($class_properties[$prop_name])) {
if ($stmt->var->name === 'this') { if ($stmt->var->name === 'this') {
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new UndefinedThisProperty( new UndefinedThisPropertyAssignment(
'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined', 'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined',
$this->checked_file_name, $this->checked_file_name,
$stmt->getLine() $stmt->getLine()
@ -1736,7 +1738,7 @@ class StatementsChecker
} }
else { else {
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new UndefinedProperty( new UndefinedPropertyAssignment(
'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined', 'Instance property ' . $lhs_type_part->value . '::' . $prop_name . ' is not defined',
$this->checked_file_name, $this->checked_file_name,
$stmt->getLine() $stmt->getLine()
@ -3558,7 +3560,7 @@ class StatementsChecker
} }
else { else {
IssueBuffer::add( IssueBuffer::add(
new UndefinedProperty('Static property ' . $var_id . ' does not exist', $this->checked_file_name, $stmt->getLine()) new UndefinedPropertyFetch('Static property ' . $var_id . ' does not exist', $this->checked_file_name, $stmt->getLine())
); );
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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