1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00
psalm/docs/issues.md
2017-12-13 11:57:46 -05:00

9.6 KiB

Issue types

AbstractInstantiation

Emitted when an attempt is made to instatiate an abstract class:

abstract class A {}
new A();

AssignmentToVoid

Emitted when assigning from a function that returns void:

function foo() : void {}
$a = foo();

ContinueOutsideLoop

Emitted when encountering a continue statement outside a loop context.

DeprecatedClass

Emitted when creating a new instance of a deprecated class:

/** @deprecated */
class A {}
new A();

DeprecatedMethod

Emitted when calling a deprecated method on a given class:

class A {
    /** @deprecated */
    public function foo() : void {}
}
(new A())->foo();

DeprecatedProperty

Emitted when getting/setting a deprecated property of a given class

class A {
    /**
     * @deprecated
     * @var ?string
     */
    public $foo;
}
(new A())->foo = 5;

DuplicateClass

Emitted when a class is defined twice

class A {}
class A {}

DuplicateParam

Emitted when a class param is defined twice

class A {
    /** @var ?string */
    public $foo;
    /** @var ?string */
    public $foo;
}

EmptyArrayAccess

Emitted when attempting to access a value on an empty array

$a = [];
$b = $a[0];

ForbiddenCode

Emitted when Psalm encounters a var_dump, exec or similar expression that may make your code more vulnerable

var_dump($foo);

ImplementedReturnTypeMismatch

Emitted when a class that inherits another, or implements an interface, has docblock return type that's entirely different to the parent. Subclasses of the parent return type are permitted, in docblocks.

class A {
    /** @return bool */
    public function foo() {
        return true;
    }
}
class B extends A {
    /** @return string */
    public function foo()  {
        return true;
    }
}

ImplicitToStringCast

Emitted when implictly converting an object with a __toString method to a string

class A {
    public function __toString() {
        return "foo";
    }
}

function takesString(string $s) : void {}

takesString(new A);

InaccessibleClassConstant

Emitted when a public/private class constant is not accessible from the calling context

class A {
    protected const FOO = 'FOO';
}
echo A::FOO;

InaccessibleMethod

Emitted when attempting to access a protected/private method from outside its available scope

class A {
    protected function foo() : void {}
}
echo (new A)->foo();

InaccessibleProperty

Emitted when attempting to access a protected/private property from outside its available scope

class A {
    /** @return string */
    protected $foo;
}
echo (new A)->foo;

InvalidArgument

Emitted when a supplied function/method argument is incompatible with the method signature or docblock one.

class A {}
function foo(A $a) : void {}
foo("hello");

InvalidArrayAccess

Emitted when attempting to access an array offset on a value that does not permit it

$arr = 5;
echo $arr[0];

InvalidArrayAssignment

Emitted when attempting to assign a value on a non-array

$arr = 5;
$arr[0] = 3;

InvalidArrayOffset

Emitted when when attempting to access an array using a value that's not a valid offet for that array

$a = [5, 20, 18];
echo $a["hello"];

InvalidCast

Emitted when attempting to cast a value that's not castable

class A {}
$a = new A();
$b = (string)$a;

InvalidClass

Emitted when referencing a class with the wrong casing

class Foo {}
(new foo());

InvalidClone

Emitted when trying to clone a value that's not cloneable

$a = "hello";
$b = clone $a;

InvalidDocblock

Emitted when there's an error in a docblock type

/** @var array() */
$a = [];

InvalidFunctionCall

Emitted when calling a function on a non-callable variable

$a = 5;
$b = $a();

InvalidGlobal

Emitted when


InvalidIterator

Emitted when trying to iterate over a value that's not iterable

$a = 5;
foreach ($a as $b) {}

InvalidMethodCall

Emitted when attempting to call a method on a non-object

$a = 5;
$a->foo();

InvalidOperand

Emitted when


InvalidParamDefault

Emitted when


InvalidPassByReference

Emitted when


InvalidPropertyAssignment

Emitted when


InvalidPropertyFetch

Emitted when


InvalidReturnStatement

Emitted when


InvalidReturnType

Emitted when


InvalidScalarArgument

Emitted when


InvalidScope

Emitted when


InvalidStaticInvocation

Emitted when


InvalidStaticVariable

Emitted when


InvalidToString

Emitted when


LessSpecificReturnStatement

Emitted when


LessSpecificReturnType

Emitted when


MethodSignatureMismatch

Emitted when


MisplacedRequiredParam

Emitted when


MissingClosureReturnType

Emitted when


MissingConstructor

Emitted when


MissingDocblockType

Emitted when


MissingFile

Emitted when


MissingPropertyType

Emitted when


MissingReturnType

Emitted when


MixedArgument

Emitted when


MixedArrayAccess

Emitted when


MixedArrayAssignment

Emitted when


MixedArrayOffset

Emitted when


MixedAssignment

Emitted when


MixedInferredReturnType

Emitted when


MixedMethodCall

Emitted when


MixedOperand

Emitted when


MixedPropertyAssignment

Emitted when


MixedPropertyFetch

Emitted when


MixedStringOffsetAssignment

Emitted when


MixedTypeCoercion

Emitted when


MoreSpecificImplementedReturnType

Emitted when


MoreSpecificReturnType

Emitted when


NoInterfaceProperties

Emitted when


NonStaticSelfCall

Emitted when


NullArgument

Emitted when


NullArrayAccess

Emitted when


NullArrayOffset

Emitted when


NullFunctionCall

Emitted when


NullIterator

Emitted when


NullOperand

Emitted when


NullPropertyAssignment

Emitted when


NullPropertyFetch

Emitted when


NullReference

Emitted when


OverriddenMethodAccess

Emitted when


ParadoxicalCondition

Emitted when


ParentNotFound

Emitted when


PossiblyFalseArgument

Emitted when


PossiblyFalseReference

Emitted when


PossiblyInvalidArgument

Emitted when


PossiblyInvalidArrayAccess

Emitted when


PossiblyInvalidArrayAssignment

Emitted when


PossiblyInvalidArrayOffset

Emitted when


PossiblyInvalidMethodCall

Emitted when


PossiblyInvalidPropertyAssignment

Emitted when


PossiblyInvalidPropertyFetch

Emitted when


PossiblyNullArgument

Emitted when


PossiblyNullArrayAccess

Emitted when


PossiblyNullArrayAssignment

Emitted when


PossiblyNullArrayOffset

Emitted when


PossiblyNullFunctionCall

Emitted when


PossiblyNullIterator

Emitted when


PossiblyNullOperand

Emitted when


PossiblyNullPropertyAssignment

Emitted when


PossiblyNullPropertyFetch

Emitted when


PossiblyNullReference

Emitted when


PossiblyUndefinedGlobalVariable

Emitted when


PossiblyUndefinedMethod

Emitted when


PossiblyUndefinedVariable

Emitted when


PossiblyUnusedMethod

Emitted when


PossiblyUnusedVariable

Emitted when


PropertyNotSetInConstructor

Emitted when


RawObjectIteration

Emitted when


RedundantCondition

Emitted when


ReferenceConstraintViolation

Emitted when


ReservedWord

Emitted when


TooFewArguments

Emitted when


TooManyArguments

Emitted when


TypeCoercion

Emitted when


TypeDoesNotContainNull

Emitted when


TypeDoesNotContainType

Emitted when


UndefinedClass

Emitted when


UndefinedConstant

Emitted when


UndefinedFunction

Emitted when


UndefinedGlobalVariable

Emitted when


UndefinedMethod

Emitted when


UndefinedPropertyAssignment

Emitted when


UndefinedPropertyFetch

Emitted when


UndefinedThisPropertyAssignment

Emitted when


UndefinedThisPropertyFetch

Emitted when


UndefinedTrait

Emitted when


UndefinedVariable

Emitted when


UnevaluatedCode

Emitted when


UnimplementedAbstractMethod

Emitted when


UnimplementedInterfaceMethod

Emitted when


UnrecognizedExpression

Emitted when


UnrecognizedStatement

Emitted when


UnresolvableInclude

Emitted when


UntypedParam

Emitted when


UnusedClass

Emitted when


UnusedMethod

Emitted when


UnusedVariable

Emitted when