1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Create new InvalidMethodCall issue for calling methods on non-objects

This commit is contained in:
Matthew Brown 2017-04-08 09:20:32 -04:00
parent 7d17a07cd2
commit b3a454cf5b
3 changed files with 9 additions and 1 deletions

View File

@ -104,6 +104,7 @@
<xs:element name="InvalidFunctionCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidGlobal" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidIterator" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidMethodCall" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidOperand" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidPropertyAssignment" type="IssueHandlerType" minOccurs="0" />
<xs:element name="InvalidPropertyFetch" type="IssueHandlerType" minOccurs="0" />

View File

@ -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)
),

View File

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