Skip to content
Permalink
Browse files

Use more specific error magic properties

  • Loading branch information
muglug committed Jan 6, 2020
1 parent f48ecda commit 867511d7fd10dad48b0b6d5a1a5e4b16d3363281
@@ -1305,6 +1305,14 @@ public static function getParentIssueType($issue_type)
return 'UndefinedMethod';
}

if ($issue_type === 'UndefinedMagicPropertyFetch') {
return 'UndefinedPropertyFetch';
}

if ($issue_type === 'UndefinedMagicPropertyAssignment') {
return 'UndefinedPropertyAssignment';
}

if ($issue_type === 'PossibleRawObjectIteration') {
return 'RawObjectIteration';
}
@@ -32,6 +32,7 @@
use Psalm\Issue\PropertyTypeCoercion;
use Psalm\Issue\UndefinedClass;
use Psalm\Issue\UndefinedPropertyAssignment;
use Psalm\Issue\UndefinedMagicPropertyAssignment;
use Psalm\Issue\UndefinedThisPropertyAssignment;
use Psalm\IssueBuffer;
use Psalm\Type;
@@ -432,8 +433,8 @@ public static function analyzeInstance(

if (!$class_exists) {
if (IssueBuffer::accepts(
new UndefinedPropertyAssignment(
'Instance property ' . $property_id . ' is not defined',
new UndefinedMagicPropertyAssignment(
'Magic nstance property ' . $property_id . ' is not defined',

This comment has been minimized.

Copy link
@orklah

orklah Jan 6, 2020

Contributor

Probable Typo here

new CodeLocation($statements_analyzer->getSource(), $stmt),
$property_id
),
@@ -22,6 +22,7 @@
use Psalm\Issue\PossiblyNullPropertyFetch;
use Psalm\Issue\UndefinedClass;
use Psalm\Issue\UndefinedDocblockClass;
use Psalm\Issue\UndefinedMagicPropertyFetch;
use Psalm\Issue\UndefinedPropertyFetch;
use Psalm\Issue\UndefinedThisPropertyFetch;
use Psalm\Issue\UninitializedProperty;
@@ -572,8 +573,8 @@ public static function analyzeInstance(

if (!$class_exists) {
if (IssueBuffer::accepts(
new UndefinedPropertyFetch(
'Instance property ' . $property_id . ' is not defined',
new UndefinedMagicPropertyFetch(
'Magic instance property ' . $property_id . ' is not defined',
new CodeLocation($statements_analyzer->getSource(), $stmt),
$property_id
),
@@ -0,0 +1,6 @@
<?php
namespace Psalm\Issue;

class UndefinedMagicPropertyAssignment extends PropertyIssue
{
}
@@ -0,0 +1,6 @@
<?php
namespace Psalm\Issue;

class UndefinedMagicPropertyFetch extends PropertyIssue
{
}
@@ -849,7 +849,7 @@ public function __set(string $key, $value) : void;
function getBar(GetterSetter $o) : string {
return $o->bar;
}',
'error_message' => 'UndefinedPropertyFetch',
'error_message' => 'UndefinedMagicPropertyFetch',
],
'magicInterfaceWrongPropertyWrite' => [
'<?php
@@ -868,7 +868,7 @@ public function __set(string $key, $value) : void;
function getFoo(GetterSetter $o) : void {
$o->bar = "hello";
}',
'error_message' => 'UndefinedPropertyAssignment',
'error_message' => 'UndefinedMagicPropertyAssignment',
],
];
}

0 comments on commit 867511d

Please sign in to comment.
You can’t perform that action at this time.