From b3a454cf5b31760f645d678cb509fc2e376f8a05 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sat, 8 Apr 2017 09:20:32 -0400 Subject: [PATCH] Create new InvalidMethodCall issue for calling methods on non-objects --- config.xsd | 1 + src/Psalm/Checker/Statements/Expression/CallChecker.php | 3 ++- src/Psalm/Issue/InvalidMethodCall.php | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/Psalm/Issue/InvalidMethodCall.php diff --git a/config.xsd b/config.xsd index 3739c9ab0..d87a36de4 100644 --- a/config.xsd +++ b/config.xsd @@ -104,6 +104,7 @@ + diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index df8523de2..cc0ecb6e8 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -21,6 +21,7 @@ use Psalm\Issue\ForbiddenCode; use Psalm\Issue\ImplicitToStringCast; use Psalm\Issue\InvalidArgument; use Psalm\Issue\InvalidFunctionCall; +use Psalm\Issue\InvalidMethodCall; use Psalm\Issue\InvalidScalarArgument; use Psalm\Issue\InvalidScope; use Psalm\Issue\MixedArgument; @@ -674,7 +675,7 @@ class CallChecker case 'Psalm\\Type\\Atomic\\TString': case 'Psalm\\Type\\Atomic\\TNumericString': if (IssueBuffer::accepts( - new InvalidArgument( + new InvalidMethodCall( 'Cannot call method ' . $stmt->name . ' on ' . $class_type . ' variable ' . $var_id, new CodeLocation($statements_checker->getSource(), $stmt) ), diff --git a/src/Psalm/Issue/InvalidMethodCall.php b/src/Psalm/Issue/InvalidMethodCall.php new file mode 100644 index 000000000..fe696147c --- /dev/null +++ b/src/Psalm/Issue/InvalidMethodCall.php @@ -0,0 +1,6 @@ +