Back to Phan

AccessError

internal/Issue-Types-Caught-by-Phan.md

6.0.5230.6 KB
Original Source
<!-- This is mirrored at https://github.com/phan/phan/wiki/Issue-Types-Caught-by-Phan --> <!-- The copy distributed with Phan is in the internal folder because it may be removed or moved elsewhere -->

See \Phan\Issue for the most up to date list of error types that are emitted. Below is a listing of all issue types, which is periodically updated. The test case 0101_one_of_each.php was originally intended to cover all examples in this document.

A concise summary of issue categories found by Phan can be seen in Phan's README.

Please add example code, fix outdated info and add any remedies to the issues below.

In addition to the below issue types, there are additional issue types that can be detected by Phan's plugins.

AccessError

This category of issue is emitted when you're trying to access things that you can't access. Note: in this document, "@internal" refers to user-defined elements with /** @internal */ in their PHPDoc, while "internal" refers to classes, functions, methods, etc. that are built into PHP and PHP modules (e.g. is_string, stdClass, etc)

PhanAccessClassConstantOfTraitDirectly

Cannot directly access class constant {CONST} of trait {TRAIT} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessClassConstantPrivate

This issue comes up when there is an attempt to access a private class constant outside of the scope in which it's defined.

Cannot access private class constant {CONST} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessClassConstantProtected

This issue comes up when there is an attempt to access a protected class constant outside of the scope in which it's defined.

Cannot access protected class constant {CONST} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessExtendsFinalClass

This issue comes up when there is an attempt to extend a user-defined final class.

Attempting to extend from final class {CLASS} defined at {FILE}:{LINE}

This will be emitted for the following code.

php
final class FinalClass
class A extends FinalClass {}

PhanAccessExtendsFinalClassInternal

This issue comes up when there is an attempt to extend an internal final class.

Attempting to extend from final internal class {CLASS}

This will be emitted for the following code.

php
class A extends Closure {}

PhanAccessMethodPrivate

This issue comes up when there is an attempt to invoke a private method outside of the scope in which it's defined.

Cannot access private method {METHOD} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessMethodPrivateWithCallMagicMethod

This issue comes up when there is an attempt to invoke a private method outside of the scope in which it's defined, but the attempt would end up calling __call or __callStatic instead.

Cannot access private method {METHOD} defined at {FILE}:{LINE} (if this call should be handled by __call, consider adding a @method tag to the class)

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessMethodProtected

This issue comes up when there is an attempt to invoke a protected method outside of the scope in which it's defined or an implementing child class.

Cannot access protected method {METHOD} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessMethodProtectedWithCallMagicMethod

This issue comes up when there is an attempt to invoke a protected method outside of the scope in which it's defined or an implementing child class, but the attempt would end up calling __call or __callStatic instead.

Cannot access protected method {METHOD} defined at {FILE}:{LINE} (if this call should be handled by __call, consider adding a @method tag to the class)

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessNonPublicAttribute

Attempting to access attribute {CLASS} with non-public constructor {METHOD} defined at {FILE}:{LINE}. This will throw if ReflectionAttribute->newInstance() is called.

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessNonStaticToStatic

This issue is emitted when a class redeclares an inherited instance method as a static method.

Cannot make non static method {METHOD}() static

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessNonStaticToStaticProperty

Cannot make non static property {PROPERTY} into the static property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOverridesFinalConstant

Declaration of class constant {CONST} overrides final constant {CONST} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOverridesFinalMethod

This issue is emitted when a class attempts to override an inherited final method.

Declaration of method {METHOD} overrides final method {METHOD} defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOverridesFinalMethodInTrait

Declaration of method {METHOD} overrides final method {METHOD} defined in trait in {FILE}:{LINE}. This is actually allowed in case of traits, even for final methods, but may lead to unexpected behavior

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOverridesFinalMethodInternal

This issue is emitted when a class attempts to override an inherited final method of an internal class.

Declaration of method {METHOD} overrides final internal method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOverridesFinalMethodPHPDoc

This issue is emitted when a class declares a PHPDoc @method tag, despite having already inherited a final method from a base class.

Declaration of phpdoc method {METHOD} is an unnecessary override of final method {METHOD} defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessOwnConstructor

Accessing own constructor directly via {CLASS}::__construct

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessPropertyNonStaticAsStatic

This issue comes up when there is an attempt to access a non-static(instance) property as if it were a static property.

Accessing non static property {PROPERTY} as static

This will be emitted for the following code.

php
class A { public $prop = 'value'; }
$x = A::$prop;

PhanAccessPropertyPrivate

This issue comes up when there is an attempt to access a private property outside of the scope in which it's defined.

Cannot access private property {PROPERTY} defined at {FILE}:{LINE}

This will be emitted for the following code.

php
class C1 { private static $p = 42; }
print C1::$p;

PhanAccessPropertyProtected

This issue comes up when there is an attempt to access a protected property outside of the scope in which it's defined or an implementing child class.

Cannot access protected property {PROPERTY} defined at {FILE}:{LINE}

This will be emitted for the following code.

php
class C1 { protected static $p = 42; }
print C1::$p;

PhanAccessPropertyStaticAsNonStatic

This issue comes up when there is an attempt to access a static property as if it were a non static(instance) property.

Accessing static property {PROPERTY} as non static

This will be emitted for the following code.

php
class A { public static $prop = 'value'; }
$x = (new A())->prop;

PhanAccessReadOnlyMagicProperty

This is emitted when attempting to assign to magic properties declared with @property-read. This does not attempt to catch all possible operations that modify magic properties.

Cannot modify read-only magic property {PROPERTY} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessReadOnlyProperty

This is emitted when attempting to read from real properties with a doc comment containing @phan-write-only. This does not attempt to catch all possible operations that read magic properties. This does not warn when the assignment is directly inside of the object's constructor.

Cannot modify read-only property {PROPERTY} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessReadOnlyPropertyMultipleTimes

Cannot modify readonly property {PROPERTY} after initialization

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessSetPropertyWrongContext

Cannot modify {TYPE} property {PROPERTY} defined at {FILE}:{LINE} from {FILE}:{LINE}

PhanAccessSignatureMismatch

Access level to {METHOD} must be compatible with {METHOD} defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessSignatureMismatchInternal

Access level to {METHOD} must be compatible with internal {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessStaticToNonStatic

This issue is emitted when a class redeclares an inherited static method as an instance method.

Cannot make static method {METHOD}() defined in {FILE}:{LINE} non static

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessStaticToNonStaticInternal

This issue is emitted when a class redeclares an inherited static method from an internal PHP class as an instance method.

Cannot make static method {METHOD}() non static

PhanAccessStaticToNonStaticProperty

Cannot make static property {PROPERTY} into the non static property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessWriteOnlyMagicProperty

This is emitted when attempting to write to magic properties declared with @property-read. This does not attempt to catch all possible operations that modify properties (e.g. references, assignment operations).

Cannot read write-only magic property {PROPERTY} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessWriteOnlyProperty

This is emitted when attempting to write to real properties with a doc comment containing @phan-read-only. This does not attempt to catch all possible operations that modify properties (e.g. references, assignment operations).

Cannot read write-only property {PROPERTY} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessWrongInheritanceCategory

Attempting to inherit {CLASSLIKE} defined at {FILE}:{LINE} as if it were a {CLASSLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessWrongInheritanceCategoryInternal

Attempting to inherit internal {CLASSLIKE} as if it were a {CLASSLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanConstantAccessSignatureMismatch

Access level to {CONST} must be compatible with {CONST} defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanConstantAccessSignatureMismatchInternal

Access level to {CONST} must be compatible with internal {CONST}

PhanPropertyAccessSignatureMismatch

Access level to {PROPERTY} must be compatible with {PROPERTY} defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPropertyAccessSignatureMismatchInternal

Access level to {PROPERTY} must be compatible with internal {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

Analysis

This category will be emitted when Phan doesn't know how to analyze something.

Please do file an issue or otherwise get in touch if you get one of these (or an uncaught exception, or anything else that's shitty).

PhanInvalidConstantFQSEN

'{CONST}' is an invalid FQSEN for a constant

e.g. this issue is emitted when analyzing this PHP file.

PhanReservedConstantName

'{CONST}' has a reserved keyword in the constant name

e.g. this issue is emitted when analyzing this PHP file.

PhanUnanalyzable

This issue will be emitted when we hit a structure that Phan doesn't know how to parse. More commonly this will be expressed by Phan having an uncaught exception or behaving poorly.

Expression is unanalyzable or feature is unimplemented. Please create an issue at https://github.com/phan/phan/issues/new.

PhanUnanalyzableInheritance

Unable to determine the method(s) which {METHOD} overrides, but Phan inferred that it did override something earlier. Please create an issue at https://github.com/phan/phan/issues/new with a test case.

CompatError

This category of issue is emitted when there are compatibility issues.

PhanCompatibleAccessMethodOnTraitDefinition

Calling static method {METHOD} on a trait is deprecated, it should only be called on a class using the trait (in {CODE})

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleAccessPropertyOnTraitDefinition

Accessing static property {PROPERTY} on a trait is deprecated, it should only be accessed on a class using the trait

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleAssertDeclaration

Declaring a custom assert() function is a fatal error because the function has special semantics.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleAutoload

Declaring an autoloader with function __autoload() is a fatal error. Use spl_autoload_register() instead.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleDefaultEqualsNull

Using a default ({CODE}) that resolves to null does not cause the parameter ({PARAMETER}) to be nullable

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleDimAlternativeSyntax

Array and string offset access syntax with curly braces is no longer supported. Use square brackets instead. Seen for {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleEnumPropertyInConstExpression

Fetching properties of enums in constant expressions (e.g. {CODE}) is only supported in PHP 8.2+.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleImplodeOrder

Passing glue string after the array is deprecated for {FUNCTION}. Should this swap the parameters of type {TYPE} and {TYPE}?

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleOverrideAttribute

Attribute #[Override] on {CLASS} is only supported in PHP {DETAILS}.

e.g. this issue is emitted when analyzing #[Override] while targeting versions that don't support it.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleReadonlyClass

Readonly class {CLASS} is only supported in PHP 8.2+.

e.g. this issue is emitted when analyzing a readonly class while targeting PHP 8.1.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleSerializeInterfaceDeprecated

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleStandaloneType

Cannot use {TYPE} as a standalone type before php 8.2.

e.g. this issue is emitted when analyzing this PHP file

PhanCompatibleSyntaxNotice

This is used for notices that are emitted while Phan is parsing with the native parser. Currently unused.

Saw a parse notice: {DETAILS}

PhanCompatibleTraitConstant

Trait {TRAIT} declares constant {CONST} which is only allowed in 8.2+

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleTrueType

Cannot use {TYPE} as a type before php 8.2.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleTypedClassConstant

Typed class constant {CONST} is only supported in PHP 8.3+.

e.g. this issue is emitted when analyzing a typed class constant while targeting PHP 8.2 or older.

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleUnparenthesizedTernary

Unparenthesized '{CODE}' is deprecated. Use either '{CODE}' or '{CODE}'

e.g. this issue is emitted when analyzing this PHP file.

PhanCompatibleUnsetCast

The unset cast (in {CODE}) is a fatal error.

e.g. this issue is emitted when analyzing this PHP file.

PhanNonEnumPropertyInConstExpression

Only properties of enums can be fetched in constant expressions, {TYPE} given

Context

This category of issue is for when you're doing stuff out of the context in which you're allowed to do it, e.g. referencing self or parent when not in a class, interface or trait.

PhanContextNotObject

This issue comes up when you attempt to use things like $this that only exist when you're inside of a class, trait or interface, but are not.

Cannot access {CLASS} when not in object context

This will be emitted for the following code.

php
new parent;

PhanContextNotObjectInCallable

Cannot access {CLASS} when not in object context, but code is using callable {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanContextNotObjectUsingSelf

Cannot use {CLASS} as type when not in object context in {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousMagicConstant

Suspicious reference to magic constant {CODE}: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

DeprecatedError

This category of issue comes up when you're accessing deprecated elements (as marked by the @deprecated comment).

Note! Only classes, traits, interfaces, methods, functions, properties, and traits may be marked as deprecated. You can't deprecate a variable or any other expression.

PhanDeprecatedCaseInsensitiveDefine

Creating case-insensitive constants with define() is deprecated

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedClass

Using a deprecated class {CLASS} defined at {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedClassConstant

Reference to deprecated class constant {CONST} defined at {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedConstructorObjectParamInternal

Argument {INDEX} (${PARAMETER}) of type {TYPE} may be an object but passing objects to {FUNCTIONLIKE} has been deprecated in PHP 8.5

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedEncapsVar

Saw deprecated encapsulated string variable syntax for {CODE}: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedFunction

If a class, method, function, property or constant is marked in its comment as @deprecated, any references to them will emit a deprecated error.

Call to deprecated function {FUNCTIONLIKE} defined at {FILE}:{LINE}{DETAILS}

This will be emitted for the following code.

php
/** @deprecated  */
function f1() {}
f1();

PhanDeprecatedFunctionArgument

Deprecated argument usage for function {FUNCTIONLIKE}: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedFunctionInternal

Call to deprecated function {FUNCTIONLIKE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedGlobalConstant

Reference to deprecated constant {CONST}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedImplicitNullableParam

Implicit nullable parameters ({TYPE} {PARAMETER} = null) have been deprecated in PHP 8.4

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedInterface

Using a deprecated interface {INTERFACE} defined at {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedPartiallySupportedCallable

Saw deprecated partially supported callable {METHOD}. This was deprecated in PHP 8.2 and behaves inconsistently and can be called with call_user_func but not $callable() and the referenced class depends on context at call time. In some cases, [{CLASS}::class, {METHOD}] can be used instead.

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedPartiallySupportedCallableAlternateScope

Saw partially supported callable [{CODE}, {METHOD}]. This was deprecated in PHP 8.2. Invoking methods with alternative scopes can be done with ReflectionMethod::invoke or Closure::bindTo instead.

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedProperty

Reference to deprecated property {PROPERTY} defined at {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanDeprecatedTrait

Using a deprecated trait {TRAIT} defined at {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

NOOPError

Issues in this category are emitted when you have reasonable code but it isn't doing anything. They're all low severity.

PhanEmptyClosure

These PhanEmpty* issues warn about empty statement lists of functions, and are emitted by EmptyMethodAndFunctionPlugin.

Note that this is not emitted for empty statement lists in functions or methods that are overrides, are overridden, or are deprecated.

Empty closure {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyForeach

Saw a foreach statement with empty iterable type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyForeachBody

Saw a foreach statement with empty body over array of type {TYPE} (iterating has no side effects)

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyFunction

Empty function {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyPrivateMethod

Empty private method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyProtectedMethod

Empty protected method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyPublicMethod

Empty public method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyYieldFrom

Saw a yield from statement with empty iterable type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoDiscardReturnValueIgnored

Return value of {FUNCTION} with #[\NoDiscard] attribute is discarded - use (void) cast to suppress this warning

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopArray

Emitted when you have an array that is not used in any way.

Unused array

This will be emitted for the following code.

php
[1,2,3];

PhanNoopArrayAccess

Unused array offset fetch

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopBinaryOperator

Unused result of a binary '{OPERATOR}' operator

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopCast

Unused result of a ({TYPE})({CODE}) cast

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopClosure

Emitted when you have a closure that is unused.

Unused closure

This will be emitted for the following code.

php
function () {};

PhanNoopConstant

Emitted when you have a reference to a constant that is unused.

Unused constant

This will be emitted for the following code.

php
const C = 42;
C;

PhanNoopEmpty

Unused result of an empty({CODE}) check

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopEncapsulatedStringLiteral

Unused result of an encapsulated string literal

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopIsset

Unused result of an isset({CODE}) check

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopMatchArms

This match expression only has the default arm in {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopMatchExpression

The result of this match expression is not used and the arms have no side effects (except for possibly throwing UnhandledMatchError) in {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopNew

NOTE: by adding @phan-constructor-used-for-side-effects to the doc comment of the class-like being used, PhanNoopNew can be suppressed on uses of that class.

Unused result of new object creation expression in {CODE} (this may be called for the side effects of the non-empty constructor or destructor)

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopNewNoSideEffects

Unused result of new object creation expression in {CODE} (this is likely free of side effects - there is no known non-empty constructor or destructor)

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopNumericLiteral

Unused result of a numeric literal {SCALAR} near this line

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopProperty

Emitted when you have a reference to a property that is unused.

Unused property

This will be emitted for the following code.

php
class C {
    public $p;
    function f() {
        $this->p;
    }
}

PhanNoopRepeatedSilenceOperator

Saw a repeated silence operator in {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopStringLiteral

Unused result of a string literal {STRING_LITERAL} near this line

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopSwitchCases

This switch statement only has the default case

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopTernary

Unused result of a ternary expression where the true/false results don't seem to have side effects

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopUnaryOperator

Unused result of a unary '{OPERATOR}' operator

e.g. this issue is emitted when analyzing this PHP file.

PhanNoopVariable

Emitted when you have a reference to a variable that is unused.

Unused variable

This will be emitted for the following code.

php
$a = 42;
$a;

PhanProvidingUnusedParameter

or the naming of $unused... or $_ is not used to indicate unused parameters in your project.

This can also be suppressed on the functionlike's declaration.

Providing an unused optional parameter ${PARAMETER} to {FUNCTIONLIKE} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanProvidingUnusedParameterOfClosure

Providing an unused optional parameter ${PARAMETER} to {FUNCTIONLIKE} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanReadOnlyPHPDocProperty

Possibly zero write references to PHPDoc @property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanReadOnlyPrivateProperty

These issues are emitted when the analyzed file list contains at least one read operation for a given declared property, but no write operations on that property.

There may be false positives if dynamic property accesses are performed, or if the code is a library that is used elsewhere.

Possibly zero write references to private property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanReadOnlyProtectedProperty

Possibly zero write references to protected property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanReadOnlyPublicProperty

Possibly zero write references to public property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantArrayValuesCall

Attempting to convert {TYPE} to a list using {FUNCTION} (it is already a list)

e.g. this issue is emitted when analyzing this PHP file.

PhanShadowedVariableInArrowFunc

Short arrow function shadows variable ${VARIABLE} from the outer scope

e.g. this issue is emitted when analyzing this PHP file.

PhanSideEffectFreeDoWhileBody

Note that PhanSideEffectFree... issue types rely on --unused-variable-detection, and will not run in the global scope as a result. Also note that the plugin UseReturnValuePlugin and its plugin_config setting infer_pure_methods should be enabled, for this to warn about loops containing function and method calls.

Saw a do-while loop which probably has no side effects

e.g. this issue is emitted when analyzing this PHP file.

PhanSideEffectFreeForBody

Saw a for loop which probably has no side effects

e.g. this issue is emitted when analyzing this PHP file.

PhanSideEffectFreeForeachBody

Saw a foreach loop which probably has no side effects

e.g. this issue is emitted when analyzing this PHP file.

PhanSideEffectFreeWhileBody

Saw a while loop which probably has no side effects

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousBinaryAddLists

Addition of {TYPE} + {TYPE} {CODE} is a suspicious way to add two lists. Some of the array fields from the left hand side will be part of the result, replacing the fields with the same key from the right hand side (this operator does not concatenate the lists)

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreachableCatch

Catch statement for {CLASSLIKE} is unreachable. An earlier catch statement at line {LINE} caught the ancestor class/interface {CLASSLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedClass

Similar issues exist for PhanUnreferencedProperty, PhanUnreferencedConstant, PhanUnreferencedMethod, and PhanUnreferencedFunction

This issue is disabled by default, but can be enabled by setting dead_code_detection to enabled. It indicates that the given element is (possibly) unused.

Possibly zero references to {TYPE} {CLASS}

This will be emitted for the following code so long as dead_code_detection is enabled.

php
class C {}

Keep in mind that for the following code we'd still emit the issue.

php
class C2 {}
$v = 'C2';
new $v;

$v2 = 'C' . (1 + 1);
new $v2;

YMMV.

PhanUnreferencedClosure

Possibly zero references to {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedConstant

Possibly zero references to global constant {CONST}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedFunction

Possibly zero references to function {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPHPDocProperty

Possibly zero references to PHPDoc @property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPrivateClassConstant

Possibly zero references to private class constant {CONST}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPrivateMethod

Possibly zero references to private method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPrivateProperty

Possibly zero references to private property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedProtectedClassConstant

Possibly zero references to protected class constant {CONST}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedProtectedMethod

Possibly zero references to protected method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedProtectedProperty

Possibly zero references to protected property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPublicClassConstant

Possibly zero references to public class constant {CONST}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPublicMethod

Possibly zero references to public method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedPublicProperty

Possibly zero references to public property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedUseConstant

Possibly zero references to use statement for constant {CONST} ({CONST})

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedUseFunction

Possibly zero references to use statement for function {FUNCTION} ({FUNCTION})

e.g. this issue is emitted when analyzing this PHP file.

PhanUnreferencedUseNormal

Possibly zero references to use statement for classlike/namespace {CLASSLIKE} ({CLASSLIKE})

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedClosureParameter

Phan has various checks (See the unused_variable_detection config) to detect if a variable or parameter is unused.

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedClosureUseVariable

Closure use variable ${VARIABLE} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedGlobalFunctionParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedGotoLabel

Note: Phan does not understand the effects of "goto" on control flow.

Phan also does not check for missing "goto" labels - This can be done with InvokePHPNativeSyntaxCheckPlugin

Unused goto label {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedPrivateFinalMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedPrivateMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedProtectedFinalMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedProtectedMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedProtectedNoOverrideMethodParameter

Parameter ${PARAMETER} is never used

PhanUnusedPublicFinalMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedPublicMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedPublicNoOverrideMethodParameter

Parameter ${PARAMETER} is never used

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedReturnBranchWithoutSideEffects

Possibly useless branch in a function where the return value must be used - all branches return values equivalent to {CODE} (previous return is at line {LINE})

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariable

Phan has various checks (See the unused_variable_detection config) to detect if a variable or parameter is unused.

Unused definition of variable ${VARIABLE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableCaughtException

Unused definition of variable ${VARIABLE} as a caught exception

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableDeclarationCaughtException

Variable ${VARIABLE} for caught exception is declared as unused. Omit the variable instead.

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableGlobal

Unreferenced definition of variable ${VARIABLE} as a global variable

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableReference

Unused definition of variable ${VARIABLE} as a reference

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableStatic

Unreferenced definition of variable ${VARIABLE} as a static variable

e.g. this issue is emitted when analyzing this PHP file.

PhanUnusedVariableValueOfForeachWithKey

Unused definition of variable ${VARIABLE} as the value of a foreach loop that included keys

e.g. this issue is emitted when analyzing this PHP file.

PhanUseConstantNoEffect

NOTE: this deliberately warns only about use statements in the global namespace, and not for namespace MyNs; use function MyNs\PHP_VERSION_ID;, which does have an effect of preventing the fallback to the global constant.

The use statement for constant {CONST} has no effect

e.g. this issue is emitted when analyzing this PHP file.

PhanUseFunctionNoEffect

NOTE: this deliberately warns only about use statements in the global namespace, and not for namespace MyNs; use function MyNs\is_string;, which does have an effect of preventing the fallback to the global function.

The use statement for function {FUNCTION} has no effect

e.g. this issue is emitted when analyzing this PHP file.

PhanUseNormalNamespacedNoEffect

Note: warn_about_redundant_use_namespaced_class must be enabled for this to be detected.

The use statement for class/namespace {CLASS} in a namespace has no effect

e.g. this issue is emitted when analyzing this PHP file.

PhanUseNormalNoEffect

The use statement for class/namespace {CLASS} in the global namespace has no effect

e.g. this issue is emitted when analyzing this PHP file.

PhanUselessBinaryAddRight

Addition of {TYPE} + {TYPE} {CODE} is probably unnecessary. Array fields from the left hand side will be used instead of each of the fields from the right hand side

e.g. this issue is emitted when analyzing this PHP file.

PhanVariableDefinitionCouldBeConstant

The PhanVariableDefinitionCouldBe* issues are detected by --constant-variable-detection. They are almost entirely false positives in most coding styles, but may pick up some code that can be cleaned up.

Uses of ${VARIABLE} could probably be replaced with a literal or constant

PhanVariableDefinitionCouldBeConstantEmptyArray

Uses of ${VARIABLE} could probably be replaced with an empty array

PhanVariableDefinitionCouldBeConstantFalse

Uses of ${VARIABLE} could probably be replaced with false or a named constant

PhanVariableDefinitionCouldBeConstantFloat

Uses of ${VARIABLE} could probably be replaced with a literal or constant float

PhanVariableDefinitionCouldBeConstantInt

Uses of ${VARIABLE} could probably be replaced with literal integer or a named constant

PhanVariableDefinitionCouldBeConstantNull

Uses of ${VARIABLE} could probably be replaced with null or a named constant

PhanVariableDefinitionCouldBeConstantString

Uses of ${VARIABLE} could probably be replaced with a literal or constant string

PhanVariableDefinitionCouldBeConstantTrue

Uses of ${VARIABLE} could probably be replaced with true or a named constant

PhanWriteOnlyPHPDocProperty

Possibly zero read references to PHPDoc @property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanWriteOnlyPrivateProperty

Possibly zero read references to private property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanWriteOnlyProtectedProperty

Possibly zero read references to protected property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

PhanWriteOnlyPublicProperty

Possibly zero read references to public property {PROPERTY}

e.g. this issue is emitted when analyzing this PHP file.

ParamError

This category of error comes up when you're messing up your method or function parameters in some way.

PhanArgumentUnpackingUsedWithNamedArgument

Cannot mix named arguments and argument unpacking in {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanDefinitelyDuplicateNamedArgument

Cannot repeat the same name for named arguments ({CODE}) and ({CODE})

e.g. this issue is emitted when analyzing this PHP file.

PhanDuplicateNamedArgument

Saw a call with arguments ({CODE}) and ({CODE}) passed to the same parameter of {FUNCTIONLIKE} defined at {FILE}:{LINE}

PhanDuplicateNamedArgumentInternal

Saw a call with arguments ({CODE}) and ({CODE}) passed to the same parameter of {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanMissingNamedArgument

Missing named argument for {PARAMETER} in call to {METHOD} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanMissingNamedArgumentInternal

Missing named argument for {PARAMETER} in call to {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoNamedArgument

Saw named argument for {PARAMETER} in call to {METHOD} declared with {COMMENT} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNoNamedArgumentVariadic

Saw likely use of named argument for unpacking {PARAMETER} of type {TYPE} in call to {METHOD} declared with {COMMENT} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamMustBeUserDefinedClassname

First argument of class_alias() must be a name of user defined class ('{CLASS}' attempted)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamNameIndicatingUnused

Note that this it may be appropriate to suppress this under the following circumstances:

  1. The parameter's name in the public API is actually meant to be $unused* or $_
  2. The project documents that it does not guarantee that parameter names won't change or that named arguments shouldn't be used with the functions it provides.
  3. The functionality is marked as @internal
Saw a parameter named ${PARAMETER}. If this was used to indicate that a parameter is unused to Phan, consider using @unused-param after a param comment, or suppressing unused parameter warnings, or renaming the parameter if backwards-compatibility for named parameters is not needed.

e.g. this issue is emitted when analyzing this PHP file.

PhanParamNameIndicatingUnusedInClosure

Saw a parameter named ${PARAMETER}. If this was used to indicate that a parameter is unused to Phan, consider using @unused-param after a param comment, or suppressing unused parameter warnings, or renaming the parameter if backwards-compatibility for named parameters is not needed.

e.g. this issue is emitted when analyzing this PHP file.

PhanParamRedefined

Redefinition of parameter {PARAMETER}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamReqAfterOpt

Required parameter {PARAMETER} follows optional {PARAMETER}

This will be emitted for the following code

php
function f2($p1 = null, $p2) {}

PhanParamSignatureMismatch

This compares the param and return types inferred from phpdoc and real types, and warns if an overriding method's signature is incompatible with the overridden method. For a check with much lower false positives and clearer issue messages, use the PhanParamSignatureRealMismatch... issue types instead.

Declaration of {METHOD} should be compatible with {METHOD} defined in {FILE}:{LINE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureMismatchInternal

This compares the param and return types inferred from phpdoc and real types (as well as documentation of internal methods), and warns if an overriding method's signature is incompatible with the overridden internal method. For a check with much lower false positives and clearer issue messages, use the PhanParamSignatureRealMismatchInternal... issue types.

Declaration of {METHOD} should be compatible with internal {METHOD}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchHasParamType

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} has type '{TYPE}' which cannot replace original parameter with no type) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchParamIsNotReference

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} is a non-reference parameter overriding a reference parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchParamIsReference

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} is a reference parameter overriding a non-reference parameter) defined in {FILE}:{LINE}

PhanParamSignaturePHPDocMismatchParamNotVariadic

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} is a non-variadic parameter replacing a variadic parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchParamType

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} of type '{TYPE}' cannot replace original parameter of type '{TYPE}') defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchParamVariadic

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (parameter #{INDEX} is a variadic parameter replacing a non-variadic parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchReturnType

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (method returning '{TYPE}' cannot override method returning '{TYPE}') defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchTooFewParameters

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (the method override accepts {COUNT} parameter(s), but the overridden method can accept {COUNT}) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignaturePHPDocMismatchTooManyRequiredParameters

Declaration of real/@method {METHOD} should be compatible with real/@method {METHOD} (the method override requires {COUNT} parameter(s), but the overridden method requires only {COUNT}) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchHasParamType

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} has type '{TYPE}' in the real signature which cannot replace original parameter with no type in the real signature) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchHasParamTypeInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} has type '{TYPE}' in the real signature which cannot replace original parameter with no type in the real signature)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamIsNotReference

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} is a non-reference parameter overriding a reference parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamIsNotReferenceInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a non-reference parameter overriding a reference parameter)

PhanParamSignatureRealMismatchParamIsReference

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} is a reference parameter overriding a non-reference parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamIsReferenceInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a reference parameter overriding a non-reference parameter)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamNotVariadic

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} is a non-variadic parameter replacing a variadic parameter) defined in {FILE}:{LINE}

PhanParamSignatureRealMismatchParamNotVariadicInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a non-variadic parameter replacing a variadic parameter)

PhanParamSignatureRealMismatchParamType

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} of real signature type '{TYPE}' cannot replace original parameter of real signature type '{TYPE}') defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamTypeInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} of type '{TYPE}' cannot replace original parameter of type '{TYPE}')

PhanParamSignatureRealMismatchParamVariadic

Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} is a variadic parameter replacing a non-variadic parameter) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchParamVariadicInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a variadic parameter replacing a non-variadic parameter)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchReturnType

Declaration of {METHOD} should be compatible with {METHOD} (method where the return type in the real signature is '{TYPE}' cannot override method where the return type in the real signature is '{TYPE}') defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchReturnTypeInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (method where the return type in the real signature is '{TYPE}' cannot override method where the return type in the real signature is '{TYPE}')

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchTooFewParameters

Declaration of {METHOD} should be compatible with {METHOD} (the method override accepts {COUNT} parameter(s), but the overridden method can accept {COUNT}) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchTooFewParametersInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (the method override accepts {COUNT} parameter(s), but the overridden method can accept {COUNT})

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchTooManyRequiredParameters

Declaration of {METHOD} should be compatible with {METHOD} (the method override requires {COUNT} parameter(s), but the overridden method requires only {COUNT}) defined in {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSignatureRealMismatchTooManyRequiredParametersInternal

Declaration of {METHOD} should be compatible with internal {METHOD} (the method override requires {COUNT} parameter(s), but the overridden method requires only {COUNT})

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSpecial1

Argument {INDEX} (${PARAMETER}) is {TYPE} but {FUNCTIONLIKE} takes {TYPE} when argument {INDEX} is {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSpecial2

Argument {INDEX} (${PARAMETER}) is {TYPE} but {FUNCTIONLIKE} takes {TYPE} when passed only one argument

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSpecial3

The last argument to {FUNCTIONLIKE} must be of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSpecial4

The second to last argument to {FUNCTIONLIKE} must be of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamSuspiciousOrder

Argument #{INDEX} of this call to {FUNCTIONLIKE} is typically a literal or constant but isn't, but argument #{INDEX} (which is typically a variable) is a literal or constant. The arguments may be in the wrong order.

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooFew

This issue indicates that you're not passing in at least the number of required parameters to a function or method.

Call with {COUNT} arg(s) to {FUNCTIONLIKE} which requires {COUNT} arg(s) defined at {FILE}:{LINE}

This will be emitted for the code

php
function f6($i) {}
f6();

PhanParamTooFewCallable

Call with {COUNT} arg(s) to {FUNCTIONLIKE} (as a provided callable) which requires {COUNT} arg(s) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooFewInPHPDoc

Call with {COUNT} arg(s) to {FUNCTIONLIKE} which has phpdoc indicating it requires {COUNT} arg(s) (${PARAMETER} is mandatory) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooFewInternal

This issue indicates that you're not passing in at least the number of required parameters to an internal function or method.

Call with {COUNT} arg(s) to {FUNCTIONLIKE} which requires {COUNT} arg(s)

This will be emitted for the code

php
strlen();

PhanParamTooFewInternalUnpack

Call with {COUNT} or more arg(s) to {FUNCTIONLIKE} which requires {COUNT} arg(s). This may throw an ArgumentCountError if there are too few args at runtime.

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooFewUnpack

Call with {COUNT} or more arg(s) to {FUNCTIONLIKE} which requires {COUNT} arg(s) defined at {FILE}:{LINE}. This may throw an ArgumentCountError if there are too few args at runtime.

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooMany

This issue is emitted when you're passing more than the number of required and optional parameters than are defined for a method or function.

Call with {COUNT} arg(s) to {FUNCTIONLIKE} which only takes {COUNT} arg(s) defined at {FILE}:{LINE}

This will be emitted for the code

php
function f7($i) {}
f7(1, 2);

PhanParamTooManyCallable

Call with {COUNT} arg(s) to {FUNCTIONLIKE} (As a provided callable) which only takes {COUNT} arg(s) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooManyInternal

This issue is emitted when you're passing more than the number of required and optional parameters than are defined for an internal method or function.

Call with {COUNT} arg(s) to {FUNCTIONLIKE} which only takes {COUNT} arg(s). This would throw an ArgumentCountError.

This will be emitted for the code

php
strlen('str', 42);

PhanParamTooManyUnpack

Call with {COUNT} or more args to {FUNCTIONLIKE} which only takes {COUNT} arg(s) defined at {FILE}:{LINE} (argument unpacking was used)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTooManyUnpackInternal

Call with {COUNT} or more args to {FUNCTIONLIKE} which only takes {COUNT} arg(s) (argument unpacking was used)

e.g. this issue is emitted when analyzing this PHP file.

PhanParamTypeMismatch

Argument {INDEX} is {TYPE} but {FUNCTIONLIKE} takes {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPositionalArgumentAfterNamedArgument

Saw positional argument ({CODE}) after a named argument {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousNamedArgumentForVariadic

Passing named argument to a variadic parameter ${PARAMETER} of the same name in a call to {METHOD}. This will set the array offset "{PARAMETER}" of the resulting variadic parameter, not the parameter itself (suppress this if this is deliberate).

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousNamedArgumentVariadicInternal

Passing named argument {CODE} to the variadic parameter of the internal function {METHOD}. Except for a few internal methods that call methods/constructors dynamically, this is usually not supported by internal functions.

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousNamedArgumentVariadicInternalUnpack

Saw likely use of named arguments in argument unpacking for {PARAMETER} of type {TYPE} passed to an internal function {FUNCTION}. Except for a few internal methods that call methods/constructors dynamically, this is usually not supported by internal functions.

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredNamedArgument

Saw a call with undeclared named argument ({CODE}) to {FUNCTIONLIKE} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredNamedArgumentInternal

Saw a call with undeclared named argument ({CODE}) to {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

RedefineError

This category of issue comes up when more than one thing of whatever type have the same name and namespace.

PhanDuplicateStaticVariable

Duplicate declaration of static variable ${VARIABLE} in {FUNCTIONLIKE} - previously declared at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanIncompatibleCompositionConstant

This issue is emitted when a class uses traits that define the same constant with incompatible visibility or values, or when a class redefines a trait constant incompatibly. PHP 8.2+ allows constants in traits, and the definitions must be compatible.

{CLASS} and {CLASS} define the same constant ({CONST}) in the composition of {CLASS}. However, the definition differs and is considered incompatible. Class was composed in {FILE} on line {LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanIncompatibleCompositionMethod

Declaration of {METHOD} must be compatible with {METHOD} in {FILE} on line {LINE}

PhanIncompatibleCompositionProp

{TRAIT} and {TRAIT} define the same property ({PROPERTY}) in the composition of {CLASS}, as the types {TYPE} and {TYPE} respectively. However, the definition differs and is considered incompatible. Class was composed in {FILE} on line {LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefineClass

{CLASS} defined at {FILE}:{LINE} was previously defined as {CLASS} at {FILE}:{LINE}

This issue will be emitted for code like

php
class C15 {}
class C15 {}

PhanRedefineClassAlias

This issue is emitted when class_alias creates ambiguity in what the intended definition of a class is. If possible, exclude one of the files containing the conflicting definitions.

{CLASS} aliased at {FILE}:{LINE} was previously defined as {CLASS} at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefineClassConstant

Class constant {CONST} defined at {FILE}:{LINE} was previously defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefineClassInternal

{CLASS} defined at {FILE}:{LINE} was previously defined as {CLASS} internally

This issue will be emitted for code like

php
class DateTime {}

PhanRedefineFunction

This issue comes up when you have two functions (or methods) with the same name and namespace.

Function {FUNCTION} defined at {FILE}:{LINE} was previously defined at {FILE}:{LINE}

It'll come up with code like

php
function f9() {}
function f9() {}

PhanRedefineFunctionInternal

This issue comes up if you define a function or method that has the same name and namespace as an internal function or method.

Function {FUNCTION} defined at {FILE}:{LINE} was previously defined internally
php
function strlen() {}

PhanRedefineProperty

Property ${PROPERTY} defined at {FILE}:{LINE} was previously defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefinedClassReference

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefinedExtendedClass

{CLASS} extends {CLASS} declared at {FILE}:{LINE} which is also declared at {FILE}:{LINE}. This may lead to confusing errors. It may be possible to exclude the class that isn't used with exclude_file_list.

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefinedInheritedInterface

{CLASS} inherits {INTERFACE} declared at {FILE}:{LINE} which is also declared at {FILE}:{LINE}. This may lead to confusing errors.

e.g. this issue is emitted when analyzing this PHP file.

PhanRedefinedUsedTrait

{CLASS} uses {TRAIT} declared at {FILE}:{LINE} which is also declared at {FILE}:{LINE}. This may lead to confusing errors.

e.g. this issue is emitted when analyzing this PHP file.

PhanReusedEnumCaseValue

Enum case {CONST} has the same value({SCALAR}) as a previous declared enum case {CONST} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

StaticCallError

PhanAbstractStaticMethodCall

Potentially calling an abstract static method {METHOD} in {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAbstractStaticMethodCallInStatic

Potentially calling an abstract static method {METHOD} with static:: in {CODE} (the calling static method's class scope may be an abstract class)

e.g. this issue is emitted when analyzing this PHP file.

PhanAbstractStaticMethodCallInTrait

Potentially calling an abstract static method {METHOD} on a trait in {CODE}, if the caller's method is called on the trait instead of a concrete class using the trait

e.g. this issue is emitted when analyzing this PHP file.

PhanStaticCallToNonStatic

Static call to non-static method {METHOD} defined at {FILE}:{LINE}. This would throw an Error.
php
class C19 { function f() {} }
C19::f();

PhanStaticClassAccessWithStaticVariable

Saw access to potentially inherited class element with {CODE} in a function that also uses static variables. PHP consistently uses one set of static variables per method declaration and the same method may end up write different values to static variables or do different things after reading static variables in different inherited classes. (This is a simple heuristic, suppress the issue if this is a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanStaticPropIsStaticType

Static property {PROPERTY} is declared to have type {TYPE}, but the only instance is shared among all subclasses (Did you mean {TYPE})

e.g. this issue is emitted when analyzing this PHP file.

TypeError

This category of issue come from using incorrect types or types that cannot cast to the expected types.

PhanAttributeNonAttribute

Saw attribute {TYPE} which was declared without {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAttributeNonClass

Saw attribute with fqsen {TYPE} which was a {CODE} instead of a class

e.g. this issue is emitted when analyzing this PHP file.

PhanAttributeNonRepeatable

Saw attribute {CLASS} which was not declared as \Attribute::IS_REPEATABLE in the class definition at {FILE}:{LINE} but had a repeat declaration on line {LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAttributeWrongTarget

Saw use of attribute {CLASS} declared at {FILE}:{LINE} which supports being declared on {DETAILS} but it was declared on {CODE} which requires an attribute declared to support {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanAttributeWrongTargetPromotedProperty

Attribute {CLASS} declared at {FILE}:{LINE} supports {DETAILS} but was used on constructor promoted property {CODE}. Promoted properties require attributes to support both \Attribute::TARGET_PARAMETER and \Attribute::TARGET_PROPERTY for full compatibility

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingAlwaysNull

Using {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The left hand side may be unnecessary.

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingAlwaysNullInGlobalScope

Using {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The left hand side may be unnecessary. (in the global scope - this is likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingAlwaysNullInLoop

Using {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The left hand side may be unnecessary. (in a loop body - this is likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingNeverNull

Using non-null {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The right hand side may be unnecessary.

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingNeverNullInGlobalScope

Using non-null {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The right hand side may be unnecessary. (in the global scope - this is likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingNeverNullInLoop

Using non-null {CODE} of type {TYPE} as the left hand side of a null coalescing (??) operation. The right hand side may be unnecessary. (in a loop body - this is likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanCoalescingNeverUndefined

Using {CODE} ?? null seems unnecessary - the expression appears to always be defined

e.g. this issue is emitted when analyzing this PHP file.

PhanConstantTypeMismatchInheritance

Class constant {CONST} is declared with type {TYPE} which is not covariant with type {TYPE} inherited from {CLASSLIKE} (constant types must be invariant or covariant)

e.g. this issue is emitted when analyzing this PHP file.

PhanDivisionByZero

Saw {CODE} with a divisor of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanEnumCannotHaveProperties

Enum {ENUM} is not allowed to declare instance or static properties but it contains property ${PROPERTY} declared at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanEnumCannotImplement

Classlike {CLASSLIKE} cannot implement {INTERFACE}

e.g. this issue is emitted when analyzing this PHP file.

PhanEnumForbiddenMagicMethod

Enum {ENUM} is not allowed to have the magic method {METHOD} declared at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleCondition

Impossible attempt to cast {CODE} of type {TYPE} to {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleConditionInGlobalScope

Impossible attempt to cast {CODE} of type {TYPE} to {TYPE} in the global scope (may be a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleConditionInLoop

Impossible attempt to cast {CODE} of type {TYPE} to {TYPE} in a loop body (may be a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleIntersectionType

Intersection type {TYPE} contains part {TYPE} which cannot cast to the declared type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleTypeComparison

Impossible attempt to check if {CODE} of type {TYPE} is identical to {CODE} of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleTypeComparisonInGlobalScope

Impossible attempt to check if {CODE} of type {TYPE} is identical to {CODE} of type {TYPE} in the global scope (likely a false positive)

PhanImpossibleTypeComparisonInLoop

Impossible attempt to check if {CODE} of type {TYPE} is identical to {CODE} of type {TYPE} in a loop body (likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleValueComparison

Impossible comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' (the comparison is always false)

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleValueComparisonInGlobalScope

Impossible comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in the global scope (the comparison is always false, likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanImpossibleValueComparisonInLoop

Impossible comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in a loop (the comparison is always false, likely a false positive)

PhanIncompatibleRealPropertyType

Declaration of {PROPERTY} of real type {TYPE} is incompatible with inherited property {PROPERTY} of real type {TYPE} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanInfiniteLoop

The loop condition {CODE} of type {TYPE} is always {TYPE} and nothing seems to exit the loop

e.g. this issue is emitted when analyzing this PHP file.

PhanInfiniteRecursion

NOTE: This is based on very simple heuristics. It has known false positives and false negatives. This checks for a functionlike directly calling itself in a way that seems to be unconditionally (e.g. doesn't detect a() calling b() calling a())

{FUNCTIONLIKE} is calling itself in a way that may cause infinite recursion.

e.g. this issue is emitted when analyzing this PHP file.

PhanInstanceMethodWithNoEnumCases

Saw enum {ENUM} that declares no enum cases but contains instance method {METHOD} declared at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidMixin

Attempting to use a mixin of invalid or missing type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanMismatchVariadicComment

{PARAMETER} is variadic in comment, but not variadic in param ({PARAMETER})

e.g. this issue is emitted when analyzing this PHP file.

PhanMismatchVariadicParam

{PARAMETER} is not variadic in comment, but variadic in param ({PARAMETER})

e.g. this issue is emitted when analyzing this PHP file.

PhanModuloByZero

Saw {CODE} with modulus of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanNonClassMethodCall

Call to method {METHOD} on non-class type {TYPE}

An example would come from

php
$v8 = null;
$v8->f();

PhanPartialTypeMismatchArgument

This issue (and similar issues) may be emitted when strict_param_checking is true, when analyzing a user-defined function. (when some types of the argument's union type match, but not others.)

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPartialTypeMismatchArgumentInternal

This issue may be emitted when strict_param_checking is true, when analyzing an internal function.

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPartialTypeMismatchProperty

This issue (and similar issues) may be emitted when strict_property_checking is true

Assigning {CODE} of type {TYPE} to property but {PROPERTY} is {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPartialTypeMismatchReturn

This issue (and similar issues) may be emitted when strict_return_checking is true (when some types of the return statement's union type match, but not others.)

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyFalseTypeArgument

This issue may be emitted when strict_param_checking is true

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyFalseTypeArgumentInternal

This issue may be emitted when strict_param_checking is true

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyFalseTypeMismatchProperty

Assigning {CODE} of type {TYPE} to property but {PROPERTY} is {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyFalseTypeReturn

This issue may be emitted when strict_return_checking is true

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyInfiniteLoop

This check uses heuristics and is prone to various false positives. False positives should be suppressed with a comment explaining why the loop condition changes or why the loop will terminate.

This is only checked for inside of function bodies.

The loop condition {CODE} does not seem to change within the loop and nothing seems to exit the loop

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyInfiniteRecursionSameParams

Note that when there are 1 or more parameters, this is only emitted when unused variable detection is enabled (needed to check for reassignments)

{FUNCTIONLIKE} is calling itself with the same parameters it was called with. This may cause infinite recursion (Phan does not check for changes to global or shared state).

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyNonClassMethodCall

Call to method {METHOD} on type {TYPE} that could be a non-object

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyNullTypeArgument

This issue may be emitted when strict_param_checking is true

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible) defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyNullTypeArgumentInternal

This issue may be emitted when strict_param_checking is true

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyNullTypeMismatchProperty

Assigning {CODE} of type {TYPE} to property but {PROPERTY} is {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyNullTypeReturn

This issue may be emitted when strict_return_checking is true

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE} ({TYPE} is incompatible)

e.g. this issue is emitted when analyzing this PHP file.

PhanPowerOfZero

Saw {CODE} exponentiating to a power of type {TYPE} (the result will always be 1)

e.g. this issue is emitted when analyzing this PHP file.

PhanPropertyHookFinalOverride

Cannot override final property hook {PROPERTY}::{METHOD} defined at {FILE}:{LINE}

PhanPropertyHookIncompatibleParamType

Property hook {PROPERTY}::{METHOD} parameter {PARAMETER} has type {TYPE} which is incompatible with property type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanPropertyHookIncompatibleReturnType

Property hook {PROPERTY}::{METHOD} returns {CODE} of type {TYPE} but property is declared as {TYPE}

PhanRedundantCondition

Redundant attempt to cast {CODE} of type {TYPE} to {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantConditionInGlobalScope

Redundant attempt to cast {CODE} of type {TYPE} to {TYPE} in the global scope (likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantConditionInLoop

Redundant attempt to cast {CODE} of type {TYPE} to {TYPE} in a loop body (likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantValueComparison

Redundant comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' (the comparison is always true)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantValueComparisonInGlobalScope

Redundant comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in the global scope (the comparison is always true, likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantValueComparisonInLoop

Redundant comparison of {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in a loop (the comparison is always true, likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanRelativePathUsed

Relative paths are harder to reason about, and opcache may have issues with relative paths in edge cases.

{FUNCTION}() statement was passed a relative path {STRING_LITERAL} instead of an absolute path

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousLoopDirection

Suspicious loop appears to {DETAILS} after each iteration in {CODE}, but the loop condition is {CODE}

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousTruthyCondition

Suspicious attempt to check if {CODE} of type {TYPE} is truthy/falsey. This contains both objects/arrays and scalars

PhanSuspiciousTruthyString

Suspicious attempt to check if {CODE} of type {TYPE} is truthy/falsey. This is false both for '' and '0'

PhanSuspiciousValueComparison

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}'

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousValueComparisonInGlobalScope

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in the global scope (likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousValueComparisonInLoop

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} with operator '{OPERATOR}' in a loop (likely a false positive)

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousWeakTypeComparison

Some of these issues may be valid, but these are often confusing ways of checking for empty/null/false. Phan does not support all types of comparisons (e.g. extensions may define comparisons on data types)

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanSuspiciousWeakTypeComparisonInGlobalScope

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} in the global scope (likely a false positive)

PhanSuspiciousWeakTypeComparisonInLoop

Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} in a loop body (likely a false positive)

PhanTypeArrayOperator

Invalid array operand provided to operator '{OPERATOR}' between types {TYPE} and {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeArraySuspicious

Suspicious array access to {CODE} of type {TYPE}

This issue will be emitted for the following code

php
$a = false; if($a[1]) {}

PhanTypeArraySuspiciousNull

Suspicious array access to {CODE} of type null

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeArraySuspiciousNullable

Suspicious array access to {CODE} of nullable type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeArrayUnsetSuspicious

Suspicious attempt to unset an offset of a value {CODE} of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeComparisonFromArray

array to {TYPE} comparison

An example would be

php
if ([1, 2] == 'string') {}

PhanTypeComparisonObjectOrdering

Using ordering comparison operator with an object of type {TYPE} and a non-object of type {TYPE} will throw a TypeError in PHP 8.0+

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeComparisonToArray

{TYPE} to array comparison

An example would be

php
if (42 == [1, 2]) {}

PhanTypeComparisonToInvalidClass

Saw code asserting that an expression has a class, but that class is an invalid/impossible FQSEN {STRING_LITERAL}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeComparisonToInvalidClassType

Saw code asserting that an expression has a class, but saw an invalid/impossible union type {TYPE} (expected {TYPE})

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeConversionFromArray

array to {TYPE} conversion

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeErrorInInternalCall

NOTE: This is only emitted for the functions that enable_extended_internal_return_type_plugins would try to infer literal return values of.

Saw a call to an internal function {FUNCTION}() with what would be invalid arguments in strict mode, when trying to infer the return value literal type: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeErrorInOperation

Saw an error when attempting to infer the type of expression {CODE}: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeExpectedObject

Expected an object instance but saw expression {CODE} with type {TYPE}

PhanTypeExpectedObjectOrClassName

Expected an object instance or the name of a class but saw expression {CODE} with type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeExpectedObjectPropAccess

Expected an object instance when accessing an instance property, but saw an expression {CODE} with type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeExpectedObjectPropAccessButGotNull

Expected an object instance when accessing an instance property, but saw an expression {CODE} with type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeExpectedObjectStaticPropAccess

Expected an object instance or a class name when accessing a static property, but saw an expression {CODE} with type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInstantiateAbstract

Instantiation of abstract class {CLASS}

This issue will be emitted for the following code

php
abstract class D {} (new D);

PhanTypeInstantiateAbstractStatic

Potential instantiation of abstract class {CLASS} (not an issue if this method is only called from a non-abstract subclass)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInstantiateEnum

Saw instantiation of enum {ENUM}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInstantiateInterface

Instantiation of interface {INTERFACE}

This issue will be emitted for the following code

php
interface E {} (new E);

PhanTypeInstantiateTrait

Instantiation of trait {TRAIT}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInstantiateTraitStaticOrSelf

Potential instantiation of trait {TRAIT} (not an issue if this method is only called from a non-abstract class using the trait)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidArrayKey

Saw array key {CODE} with key type {TYPE} but expected a value that could cast to int|string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidArrayKeyLiteral

Saw array key {CODE} with key value {SCALAR} but expected a value that could cast to int|string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidBitwiseBinaryOperator

Invalid non-int/non-string operand provided to operator '{OPERATOR}' between types {TYPE} and {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallExpressionAssignment

Probably unused assignment to function result {CODE} for function returning {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallable

Saw type {TYPE} which cannot be a callable

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallableArrayKey

In a place where phan was expecting a callable, saw an array with an unexpected key for element #{INDEX} (expected [$class_or_expr, $method_name])

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallableArraySize

In a place where phan was expecting a callable, saw an array of size {COUNT}, but callable arrays must be of size 2

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallableMethodName

Method name of callable must be a string, got {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCallableObjectOfMethod

In a place where phan was expecting a callable, saw a two-element array with a class or expression with an unexpected type {TYPE} (expected a class type or string). Method name was {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidCloneNotObject

Expected an object to be passed to clone() but got {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidClosureScope

Invalid @phan-closure-scope: expected a class name, got {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidConstantName

Saw a class constant fetch with a name of type {TYPE} but expected the name to be a string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidDimOffset

Invalid offset {SCALAR} of {CODE} of array type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidDimOffsetArrayDestructuring

Invalid offset {SCALAR} of {CODE} of array type {TYPE} in an array destructuring assignment

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidEval

Eval statement was passed an invalid expression of type {TYPE} (expected a string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidExpressionArrayDestructuring

Invalid value {CODE} of type {TYPE} in an array destructuring assignment, expected {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidInstanceof

Found an instanceof class name {CODE} of type {TYPE}, but class name must be a valid object or a string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidLeftOperand

Invalid operator: right operand is array and left is not

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidLeftOperandOfAdd

Invalid operator: left operand of {OPERATOR} is {TYPE} (expected array or number)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidLeftOperandOfBitwiseOp

Invalid operator: left operand of {OPERATOR} is {TYPE} (expected int|string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidLeftOperandOfIntegerOp

Invalid operator: left operand of {OPERATOR} is {TYPE} (expected int)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidLeftOperandOfNumericOp

Invalid operator: left operand of {OPERATOR} is {TYPE} (expected number)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidMethodName

Instance method name must be a string, got {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidModuloOperand

Operand {CODE} of type {TYPE} to modulo (%%) operator is implicitly converted to int (deprecated in PHP 8.1)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidPropertyName

Saw a dynamic usage of an instance property with a name of type {TYPE} but expected the name to be a string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRequire

Require statement was passed an invalid expression of type {TYPE} (expected a string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRightOperand

Invalid operator: left operand is array and right is not

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRightOperandOfAdd

Invalid operator: right operand of {OPERATOR} is {TYPE} (expected array or number)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRightOperandOfBitwiseOp

Invalid operator: right operand of {OPERATOR} is {TYPE} (expected int|string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRightOperandOfIntegerOp

Invalid operator: right operand of {OPERATOR} is {TYPE} (expected int)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidRightOperandOfNumericOp

Invalid operator: right operand of {OPERATOR} is {TYPE} (expected number)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidStaticMethodName

Static method name must be a string, got {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidStaticPropertyName

Saw a dynamic usage of a static property with a name of type {TYPE} but expected the name to be a string

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidThrowStatementNonThrowable

{FUNCTIONLIKE} can throw {CODE} of type {TYPE} here which can't cast to {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidThrowsIsInterface

@throws annotation of {FUNCTIONLIKE} has suspicious interface type {TYPE} for an @throws annotation, expected class (PHP allows interfaces to be caught, so this might be intentional)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidThrowsIsTrait

@throws annotation of {FUNCTIONLIKE} has invalid trait type {TYPE}, expected a class

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidThrowsNonObject

@throws annotation of {FUNCTIONLIKE} has invalid non-object type {TYPE}, expected a class

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidThrowsNonThrowable

@throws annotation of {FUNCTIONLIKE} has suspicious class type {TYPE}, which does not extend Error/Exception

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidTraitParam

{FUNCTIONLIKE} is declared to have a parameter ${PARAMETER} with a real type of trait {TYPE} (expected a class or interface or built-in type)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidTraitReturn

Expected a class or interface (or built-in type) to be the real return type of {FUNCTIONLIKE} but got trait {TRAIT}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidUnaryOperandBitwiseNot

Invalid operator: unary operand of {STRING_LITERAL} is {TYPE} (expected number that can fit in an int, or string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidUnaryOperandIncOrDec

Invalid operator: unary operand of {STRING_LITERAL} is {TYPE} (expected int or string or float)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidUnaryOperandNumeric

Invalid operator: unary operand of {STRING_LITERAL} is {TYPE} (expected number)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeInvalidYieldFrom

Yield from statement was passed an invalid expression {CODE} of type {TYPE} (expected Traversable/array)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMagicVoidWithReturn

Found a return statement with a value in the implementation of the magic method {METHOD}, expected void return type

This will be emitted for the code

php
// (PHP ignores the return value of some magic methods, such as __set)
class A { public function __set() { return true; } }

PhanTypeMismatchArgument

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} defined at {FILE}:{LINE}

This will be emitted for the code

php
function f8(int $i) {}
f8('string');

PhanTypeMismatchArgumentInternal

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE}

This will be emitted for the code

php
strlen(42);

PhanTypeMismatchArgumentInternalProbablyReal

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} takes {TYPE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentInternalReal

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} takes {TYPE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentNullable

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} defined at {FILE}:{LINE} (expected type to be non-nullable)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentNullableInternal

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} (expected type to be non-nullable)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentProbablyReal

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} takes {TYPE}{DETAILS} defined at {FILE}:{LINE} (the inferred real argument type has nothing in common with the parameter's phpdoc type)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentPropertyReference

Argument {INDEX} is property {PROPERTY} with type {TYPE} but {FUNCTIONLIKE} takes a reference of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentPropertyReferenceReal

Argument {INDEX} is property {PROPERTY} with type {TYPE}{DETAILS} but {FUNCTIONLIKE} takes a reference of type {TYPE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentReal

This is a more severe version of PhanTypeMismatchArgument for code that Phan infers is likely to throw an Error at runtime. This ignores some configuration settings allowing nulls to cast to other types, etc. It is emitted instead of PhanTypeMismatchArgument under the following conditions:

  • Phan infers real types for both the argument expression and the parameter's real signature.
  • The union type of the argument doesn't have any types that are partially compatible with the return type from the signature.
  • If strict_types isn't enabled in the caller, it won't be emitted if the returned expression could be a non-null scalar and the declared return type has any scalars.

This does not attempt to account for the possibility of overriding methods being more permissive about what argument types are accepted.

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} takes {TYPE}{DETAILS} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArgumentSuperType

Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} defined at {FILE}:{LINE} (expected type to be the same or a subtype, but saw a supertype instead)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchArrayDestructuringKey

Attempting an array destructing assignment with a key of type {TYPE} but the only key types of the right-hand side are of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchBitwiseBinaryOperands

Unexpected mix of int and string operands provided to operator '{OPERATOR}' between types {TYPE} and {TYPE} (expected one type but not both)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredConstant

Constant {CONST} is declared with type {TYPE} but has value {CODE} of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredConstantNever

Constant {CONST} is declared with type never which always results in a compile error

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredParam

Doc-block of ${PARAMETER} in {METHOD} contains phpdoc param type {TYPE} which is incompatible with the param type {TYPE} declared in the signature

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredParamNullable

Doc-block of ${PARAMETER} in {METHOD} is phpdoc param type {TYPE} which is not a permitted replacement of the nullable param type {TYPE} declared in the signature ('?T' should be documented as 'T|null' or '?T')

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredReturn

Doc-block of {METHOD} contains declared return type {TYPE} which is incompatible with the return type {TYPE} declared in the signature

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDeclaredReturnNullable

Doc-block of {METHOD} has declared return type {TYPE} which is not a permitted replacement of the nullable return type {TYPE} declared in the signature ('?T' should be documented as 'T|null' or '?T')

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDefault

Default value for {TYPE} ${PARAMETER} can't be {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDefaultIntersection

Default value for {TYPE} ${PARAMETER} can't be {TYPE} because the parameter contains intersection types

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDimAssignment

When appending to a value of type {TYPE}, found an array access index of type {TYPE}, but expected the index to be of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDimEmpty

Assigning to an empty array index of a value of type {TYPE}, but expected the index to exist and be of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDimFetch

When fetching an array index from a value of type {TYPE}, found an array index of type {TYPE}, but expected the index to be of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchDimFetchNullable

When fetching an array index from a value of type {TYPE}, found an array index of type {TYPE}, but expected the index to be of the non-nullable type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchForeach

This issue will be emitted when something that can't be an array is passed as the array_expression.

{TYPE} passed to foreach instead of array

This will be emitted for the code

php
foreach (null as $i) {}

PhanTypeMismatchGeneratorYieldKey

Yield statement has a key {CODE} with type {TYPE} but {FUNCTIONLIKE} is declared to yield keys of type {TYPE} in {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchGeneratorYieldValue

Yield statement has a value {CODE} with type {TYPE} but {FUNCTIONLIKE} is declared to yield values of type {TYPE} in {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchProperty

Assigning {CODE} of type {TYPE} to property but {PROPERTY} is {TYPE}

This issue is emitted from the following code

php
function f(int $p = false) {}

PhanTypeMismatchPropertyByRef

{CODE} of type {TYPE} may end up assigned to property {PROPERTY} of type {TYPE} by reference at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchPropertyDefault

Default value for {TYPE} ${PROPERTY} can't be {CODE} of type {TYPE} based on phpdoc types

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchPropertyDefaultReal

Default value for {TYPE} ${PROPERTY} can't be {CODE} of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchPropertyProbablyReal

Assigning {CODE} of type {TYPE}{DETAILS} to property but {PROPERTY} is {TYPE}{DETAILS} (the inferred real assigned type has nothing in common with the declared phpdoc property type)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchPropertyReal

Assigning {CODE} of type {TYPE}{DETAILS} to property but {PROPERTY} is {TYPE}{DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchPropertyRealByRef

{CODE} of type {TYPE} may end up assigned to property {PROPERTY} of type {TYPE} by reference at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchReturn

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE}

This issue is emitted from the following code

php
class G { /** @param string $s */ function f($s) : int { return $s; } }

PhanTypeMismatchReturnNullable

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE} (expected returned value to be non-nullable)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchReturnProbablyReal

Returning {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} is declared to return {TYPE}{DETAILS} (the inferred real return type has nothing in common with the declared phpdoc return type)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchReturnReal

This is a more severe version of PhanTypeMismatchReturn for code that Phan infers is likely to throw an Error at runtime. This ignores some configuration settings allowing nulls to cast to other types, etc. It is emitted instead of PhanTypeMismatchReturn under the following conditions:

  • Phan infers real types for both the returned expression and the function's signature
  • The union type of the returned expression doesn't have any types that are partially compatible with the return type from the signature.
  • If strict_types isn't enabled, it won't be emitted if the returned expression could be a non-null scalar and the declared return type has any scalars.
Returning {CODE} of type {TYPE}{DETAILS} but {FUNCTIONLIKE} is declared to return {TYPE}{DETAILS}

This issue is emitted from the following code

php
class G { function f() : int { return 'string'; } }

PhanTypeMismatchReturnSuperType

Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE} (saw a supertype instead of a subtype)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMismatchUnpackValue

Attempting to unpack a value of type {TYPE} which does not contain any subtypes of iterable (such as array or Traversable)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeMissingReturn

Method {METHOD} is declared to return {TYPE} in phpdoc but has no return value

This issue is emitted from the following code

php
class H { function f() : int {} }

PhanTypeMissingReturnReal

Method {METHOD} is declared to return {TYPE} in its real type signature but has no return value

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeModifyImmutableObjectProperty

Saw attempt to modify {TYPE} {CLASS}'s property ${PROPERTY} declared at {FILE}:{LINE} (immutability of properties is enforced at runtime)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeNoAccessiblePropertiesForeach

Class {TYPE} was passed to foreach, but it does not extend Traversable and none of its declared properties are accessible from this context. (This check excludes dynamic properties)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeNoPropertiesForeach

Note: This and other checks of foreach deliberately don't warn about stdClass for now.

Class {TYPE} was passed to foreach, but it does not extend Traversable and doesn't have any declared properties. (This check excludes dynamic properties)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeNonVarPassByRef

Only variables can be passed by reference at argument {INDEX} of {FUNCTIONLIKE}

This issue is emitted from the following code

php
class F { static function f(&$v) {} } F::f('string');

PhanTypeNonVarReturnByRef

Only variables can be returned by reference in {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeObjectUnsetDeclaredProperty

Suspicious attempt to unset class {TYPE}'s property ${PROPERTY} declared at {FILE}:{LINE} (This can be done, but is more commonly done for dynamic properties and Phan does not expect this)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeParentConstructorCalled

Must call parent::__construct() from {CLASS} which extends {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypePossiblyInvalidCallable

Saw type {TYPE} which is possibly not a callable

e.g. this issue is emitted when analyzing this PHP file.

PhanTypePossiblyInvalidCloneNotObject

Expected an object to be passed to clone() but got possible non-object {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypePossiblyInvalidDimOffset

Possibly invalid offset {SCALAR} of {CODE} of array type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeSuspiciousEcho

Suspicious argument {CODE} of type {TYPE} for an echo/print statement

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeSuspiciousIndirectVariable

Indirect variable ${(expr)} has invalid inner expression type {TYPE}, expected string/integer

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeSuspiciousNonTraversableForeach

Class {TYPE} was passed to foreach, but it does not extend Traversable. This may be intentional, because some of that class's declared properties are accessible from this context. (This check excludes dynamic properties)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeSuspiciousStringExpression

Suspicious type {TYPE} of a variable or expression {CODE} used to build a string. (Expected type to be able to cast to a string)

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeUnexpectedEnumCaseType

Saw enum case {CONST} with a value of type {TYPE} that did not match expected type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeVoidArgument

Cannot use void return value {CODE} as a function argument

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeVoidAssignment

This is triggered by assigning the return value of a function or method that returns void.

Cannot assign void return value

This issue will be emitted from the following code:

php
class A { /** @return void */ function v() {} }
$a = (new A)->v();

PhanTypeVoidExpression

Suspicious use of void return value {CODE} where a value is expected

e.g. this issue is emitted when analyzing this PHP file.

UndefError

This category of issue comes up when there are references to undefined things. These are a big source of false-positives in Phan given that code bases often take liberties with calling methods on sub-classes of the class defined to be returned by a function and things like that.

You can ignore all errors of this category by passing in the command-line argument -i or --ignore-undeclared.

PhanAmbiguousTraitAliasSource

Trait alias {METHOD} has an ambiguous source method {METHOD} with more than one possible source trait. Possibilities: {TRAIT}

e.g. this issue is emitted when analyzing this PHP file.

PhanClassContainsAbstractMethod

non-abstract class {CLASS} contains abstract method {METHOD} declared at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanClassContainsAbstractMethodInternal

non-abstract class {CLASS} contains abstract internal method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyFQSENInCallable

Possible call to a function '{FUNCTIONLIKE}' with an empty FQSEN.

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyFQSENInClasslike

Possible use of a classlike '{CLASSLIKE}' with an empty FQSEN.

e.g. this issue is emitted when analyzing this PHP file.

PhanEmptyFile

This low severity issue is emitted for empty files.

Empty file {FILE}

This would be emitted if you have a file with the contents

php

PhanInvalidFQSENInCallable

Possible call to a function '{FUNCTIONLIKE}' with an invalid FQSEN.

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidFQSENInClasslike

Possible use of a classlike '{CLASSLIKE}' with an invalid FQSEN.

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidRequireFile

Required file {FILE} is not a file

e.g. this issue is emitted when analyzing this PHP file.

PhanMissingRequireFile

This is emitted when a statement such as require or include_once refers to a path that doesn't exist.

If this is warning about a relative include, then you may want to adjust the config settings for include_paths and optionally warn_about_relative_include_paths.

Missing required file {FILE}

e.g. this issue is emitted when analyzing this PHP file.

PhanParentlessClass

Reference to parent of class {CLASS} that does not extend anything

This issue will be emitted from the following code

php
class F { function f() { $v = parent::f(); } }

PhanPossiblyUndeclaredGlobalVariable

Global variable ${VARIABLE} is possibly undeclared

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyUndeclaredMethod

Call to possibly undeclared method {METHOD} on type {TYPE} ({TYPE} does not declare the method)

PhanPossiblyUndeclaredProperty

Reference to possibly undeclared property {PROPERTY} of expression of type {TYPE} ({TYPE} does not declare that property)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyUndeclaredPropertyOfClass

Reference to possibly undeclared property {PROPERTY} of expression of type {TYPE} (instances of {CLASS} do not declare that property)

e.g. this issue is emitted when analyzing this PHP file.

PhanPossiblyUndeclaredVariable

Variable ${VARIABLE} is possibly undeclared

Phan does not attempt to analyze the relationship between variables or conditions at all, e.g. PhanPossiblyUndeclaredVariable will be emitted for the below snippet:

php
if ($cond) { $var = expr; }
// ...
if ($cond) { use($var); }

PhanPossiblyUnsetPropertyOfThis

Attempting to read property {PROPERTY} which was unset in the current scope

e.g. this issue is emitted when analyzing this PHP file.

PhanRequiredTraitNotAdded

This happens when a trait name is used in a trait adaptations clause, but that trait wasn't added to the class.

Required trait {TRAIT} for trait adaptation was not added to class
php
trait T1 {}
trait T2 {}
class A {
	use T1 {T2::foo as bar;}
}

PhanTraitParentReference

Reference to parent from trait {TRAIT}

This issue will be emitted from the following code

php
trait T { function f() { return parent::f(); } }

PhanTraitRequireExtendsMissing

This happens when a trait annotated with @require-extends (or @psalm-require-extends) is used by a class that does not extend the required class.

Trait {TRAIT} requires using class {CLASS} to extend {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTraitRequireImplementsMissing

This happens when a trait annotated with @require-implements (or @psalm-require-implements) is used by a class that does not implement the required interface.

Trait {TRAIT} requires using class {CLASS} to implement {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredAliasedMethodOfTrait

Alias {METHOD} was defined for a method {METHOD} which does not exist in trait {TRAIT}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClass

Reference to undeclared class {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassAliasOriginal

Reference to undeclared class {CLASS} for the original class of a class_alias for {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassAttribute

Reference to undeclared class {CLASS} in an attribute

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassCatch

Catching undeclared class {CLASS}

The following code will emit this error.

php
try {} catch (Undef $exception) {}

PhanUndeclaredClassConstant

Reference to constant {CONST} from undeclared class {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassInCallable

Reference to undeclared class {CLASS} in callable {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassInstanceof

Checking instanceof against undeclared class {CLASS}

This issue will be emitted from the following code

php
$v = null;
if ($v instanceof Undef) {}

PhanUndeclaredClassMethod

Call to method {METHOD} from undeclared class {CLASS}

This issue will be emitted from the following code

php
function g(Undef $v) { $v->f(); }

PhanUndeclaredClassProperty

Reference to instance property {PROPERTY} from undeclared class {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassReference

Reference to undeclared class {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClassStaticProperty

Reference to static property {PROPERTY} from undeclared class {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredClosureScope

Reference to undeclared class {CLASS} in @phan-closure-scope

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredConstant

This issue comes up when you reference a constant that doesn't exist.

Reference to undeclared constant {CONST}. This would throw an Error.
php
$v7 = UNDECLARED_CONSTANT;

PhanUndeclaredConstantOfClass

Reference to undeclared class constant {CONST}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredExtendedClass

Class extends undeclared class {CLASS}

This issue will be emitted from the following code

php
class E extends UndeclaredClass {}

PhanUndeclaredFunction

This issue will be emitted if you reference a function that doesn't exist.

Call to undeclared function {FUNCTION}

This issue will be emitted for the code

php
some_missing_function();

PhanUndeclaredFunctionInCallable

Call to undeclared function {FUNCTION} in callable

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredGlobalVariable

Global variable ${VARIABLE} is undeclared

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredInterface

Class implements undeclared interface {INTERFACE}
php
class C17 implements UndeclaredInterface {}

PhanUndeclaredInvokeInCallable

Possible attempt to access missing magic method {FUNCTIONLIKE} of '{CLASS}'

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredMagicConstant

Reference to magic constant {CONST} that is undeclared in the current scope: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredMethod

Call to undeclared method {METHOD}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredMethodInCallable

Call to undeclared method {METHOD} in callable. Possible object type(s) for that method are {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredProperty

Reference to undeclared property {PROPERTY}

This issue will be emitted from the following code

php
class C {}
$v = (new C)->undef;

PhanUndeclaredStaticMethod

Static call to undeclared method {METHOD}

This issue will be emitted from the following code

php
C::staticMethod();

PhanUndeclaredStaticMethodInCallable

Reference to undeclared static method {METHOD} in callable

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredStaticProperty

Static property '{PROPERTY}' on {CLASS} is undeclared

An example would be

php
class C22 {}
$v11 = C22::$p;

PhanUndeclaredThis

Variable ${VARIABLE} is undeclared

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredTrait

Class uses undeclared trait {TRAIT}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredTypeClassConstant

Class constant {CONST} has undeclared class type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredTypeParameter

Parameter ${PARAMETER} has undeclared type {TYPE}

This issue will be emitted from the following code

php
function f(Undef $p) {}

PhanUndeclaredTypeProperty

Property {PROPERTY} has undeclared type {TYPE}

This issue will be emitted from the following code

php
class D { /** @var Undef */ public $p; }

PhanUndeclaredTypeReturnType

Return type of {METHOD} is undeclared type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredTypeThrowsType

@throws type of {METHOD} has undeclared type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredVariable

Variable ${VARIABLE} is undeclared

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredVariableAssignOp

Variable ${VARIABLE} was undeclared, but it is being used as the left-hand side of an assignment operation

e.g. this issue is emitted when analyzing this PHP file.

PhanUndeclaredVariableDim

Variable ${VARIABLE} was undeclared, but array fields are being added to it.

e.g. this issue is emitted when analyzing this PHP file.

VarError

PhanVariableUseClause

Non-variables ({CODE}) not allowed within use clause

Generic

This category contains issues related to Phan's generic type support

PhanGenericConstructorTypes

Missing template parameter for type {TYPE} on constructor for generic class {CLASS} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanGenericGlobalVariable

Global variable {VARIABLE} may not be assigned an instance of a generic class

PhanGenericMissingParameters

Class {CLASS} must substitute all {COUNT} template parameters when inheriting {CLASS} (found {COUNT}) defined at {FILE}:{LINE} (use @extends or @inherit)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantBoolAndFalseInUnion

Duplicate type false is redundant in union type {TYPE} (bool already includes false)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantBoolAndTrueInUnion

Duplicate type true is redundant in union type {TYPE} (bool already includes true)

e.g. this issue is emitted when analyzing this PHP file.

PhanRedundantTrueAndFalseInUnion

Type {TYPE} contains both true and false - bool should be used instead

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeConstant

This is emitted when a class constant's PHPDoc contains a type declared in a class's phpdoc template annotations.

constant {CONST} may not have a template type

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeConstraintViolation

Template type {TYPE} of {CLASS} must be compatible with {TYPE}, but {TYPE} was provided in {CLASS}

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeDuplicate

Template type {TYPE} is already declared in this comment

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeNotDeclaredInFunctionParams

Template type {TYPE} not declared in parameters of function/method {FUNCTIONLIKE} (or Phan can't extract template types for this use case)

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeNotUsedInFunctionReturn

Template type {TYPE} not used in return value of function/method {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeShadowsClass

Template type {TYPE} is already declared in the containing class

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeStaticMethod

This is emitted when a static method's PHPDoc contains a param/return type declared in a class's phpdoc template annotations.

static method {METHOD} does not declare template type in its own comment and may not use the template type of class instances

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeStaticProperty

This is emitted when a static property's PHPDoc contains an @var type declared in the class's phpdoc template annotations.

static property {PROPERTY} may not have a template type

e.g. this issue is emitted when analyzing this PHP file.

PhanTemplateTypeVarianceViolation

Template type {TYPE} declared {VARIANCE} cannot be used in {POSITION} of {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file. Another example covering property variance (including contravariant properties, which are now disallowed even when write-only) appears in this issue file, triggered by this source snippet.

Internal

This issue category comes up when there is an attempt to access an @internal element (property, class, constant, method, function, etc.) outside of the namespace in which it's defined.

This category is completely unrelated to elements being internal to PHP (i.e. part of PHP core or PHP modules).

PhanAccessClassConstantInternal

This issue comes up when there is an attempt to access an @internal class constant outside of the namespace in which it's defined.

Cannot access internal class constant {CONST} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessClassInternal

This issue comes up when there is an attempt to access an @internal class constant outside of the namespace in which it's defined.

Cannot access internal {CLASS} defined at {FILE}:{LINE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessConstantInternal

This issue comes up when there is an attempt to access an @internal global constant outside of the namespace in which it's defined.

Cannot access internal constant {CONST} of namespace {NAMESPACE} defined at {FILE}:{LINE} from namespace {NAMESPACE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessMethodInternal

This issue comes up when there is an attempt to access an @internal method outside of the namespace in which it's defined.

Cannot access internal method {METHOD} of namespace {NAMESPACE} defined at {FILE}:{LINE} from namespace {NAMESPACE}

e.g. this issue is emitted when analyzing this PHP file.

PhanAccessPropertyInternal

This issue comes up when there is an attempt to access an @internal property outside of the namespace in which it's defined.

Cannot access internal property {PROPERTY} of namespace {NAMESPACE} defined at {FILE}:{LINE} from namespace {NAMESPACE}

e.g. this issue is emitted when analyzing this PHP file.

CommentError

This is emitted for some (but not all) comments which Phan thinks are invalid or unparsable.

PhanCommentAbstractOnInheritedConstant

Class {CLASS} inherits a class constant {CONST} declared at {FILE}:{LINE} marked as {COMMENT} in phpdoc but does not override it

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentAbstractOnInheritedMethod

Class {CLASS} inherits a method {METHOD} declared at {FILE}:{LINE} marked as {COMMENT} in phpdoc but does not override it

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentAbstractOnInheritedProperty

Class {CLASS} inherits a property {PROPERTY} declared at {FILE}:{LINE} marked as {COMMENT} in phpdoc but does not override it

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentAmbiguousClosure

Comment {STRING_LITERAL} refers to {TYPE} instead of \Closure - Assuming \Closure

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentDuplicateMagicMethod

Comment declares @method {METHOD} multiple times

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentDuplicateMagicProperty

Comment declares @property* ${PROPERTY} multiple times

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentDuplicateParam

Comment declares @param ${PARAMETER} multiple times

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentInheritDocOnNonOverrideMethod

Saw an @inheritDoc annotation for method {METHOD}, but could not find an overridden method and it is not a magic method

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentObjectInClassConstantType

Impossible phpdoc declaration that a class constant {CONST} has a type {TYPE} containing objects. This type is ignored during analysis.

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentOverrideOnNonOverrideConstant

Saw an @override annotation for class constant {CONST}, but could not find an overridden constant

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentOverrideOnNonOverrideMethod

Saw an @override annotation for method {METHOD}, but could not find an overridden method and it is not a magic method

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentOverrideOnNonOverrideProperty

Saw an @override annotation for property {PROPERTY}, but could not find an overridden property

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentParamAssertionWithoutRealParam

Saw an @phan-assert annotation for ${PARAMETER}, but it was not found in the param list of {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentParamOnEmptyParamList

Saw an @param annotation for ${PARAMETER}, but the param list of {FUNCTIONLIKE} is empty

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentParamOutOfOrder

Expected @param annotation for ${PARAMETER} to be before the @param annotation for ${PARAMETER}

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentParamWithoutRealParam

Saw an @param annotation for ${PARAMETER}, but it was not found in the param list of {FUNCTIONLIKE}

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentUnextractableTypeAlias

Saw a line {COMMENT} with a type alias that could not be extracted

e.g. this issue is emitted when analyzing this PHP file.

PhanCommentUnsupportedUnionType

Saw a union type {TYPE} with more than 1 type in a location that does not support union types

PhanCommentVarInsteadOfParam

Saw @var annotation for ${VARIABLE} but Phan expects the @param annotation to document the parameter with that name for {FUNCTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanDebugAnnotation

@phan-debug-var requested for variable ${VARIABLE} - it has union type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidCommentForDeclarationType

The phpdoc comment for {COMMENT} cannot occur on a {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanMisspelledAnnotation

Saw misspelled annotation {COMMENT}. {SUGGESTION}

e.g. this issue is emitted when analyzing this PHP file.

PhanThrowTypeAbsent

{FUNCTIONLIKE} can throw {CODE} of type {TYPE} here, but has no '@throws' declarations for that class

e.g. this issue is emitted when analyzing this PHP file.

PhanThrowTypeAbsentForCall

{FUNCTIONLIKE} can throw {TYPE} because it calls {FUNCTIONLIKE}, but has no '@throws' declarations for that class

e.g. this issue is emitted when analyzing this PHP file.

PhanThrowTypeMismatch

{FUNCTIONLIKE} throws {CODE} of type {TYPE} here, but it only has declarations of '@throws {TYPE}'

e.g. this issue is emitted when analyzing this PHP file.

PhanThrowTypeMismatchForCall

{FUNCTIONLIKE} throws {TYPE} because it calls {FUNCTIONLIKE}, but it only has declarations of '@throws {TYPE}'

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeAliasInternalTypeConflict

Saw attempt to use {TYPE} as a type alias for {TYPE} but internal types cannot be redefined.

e.g. this issue is emitted when analyzing this PHP file.

PhanTypeAliasUsedOutsideComment

Saw a type alias {TYPE} used outside of a comment - this will refer to a class name instead of {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanUnextractableAnnotation

Saw unextractable annotation for comment '{COMMENT}'

e.g. this issue is emitted when analyzing this PHP file.

PhanUnextractableAnnotationElementName

Saw possibly unextractable annotation for a fragment of comment '{COMMENT}': after {TYPE}, did not see an element name (will guess based on comment order)

e.g. this issue is emitted when analyzing this PHP file.

PhanUnextractableAnnotationPart

Saw unextractable annotation for a fragment of comment '{COMMENT}': '{COMMENT}'

e.g. this issue is emitted when analyzing this PHP file.

PhanUnextractableAnnotationSuffix

Saw a token Phan may have failed to parse after '{COMMENT}': after {TYPE}, saw '{COMMENT}'

e.g. this issue is emitted when analyzing this PHP file.

Syntax

Emitted for syntax errors.

PhanContinueOrBreakNotInLoop

'{OPERATOR}' not in the 'loop' or 'switch' context.

e.g. this issue is emitted when analyzing this PHP file.

PhanContinueOrBreakTooManyLevels

Cannot '{OPERATOR}' {INDEX} levels.

e.g. this issue is emitted when analyzing this PHP file.

PhanContinueTargetingSwitch

This detects code causing a PHP warning.

"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

PhanDuplicateUseConstant

Cannot use constant {CONST} as {CONST} because the name is already in use

e.g. this issue is emitted when analyzing this PHP file.

PhanDuplicateUseFunction

Cannot use function {FUNCTION} as {FUNCTION} because the name is already in use

e.g. this issue is emitted when analyzing this PHP file.

PhanDuplicateUseNormal

Cannot use {CLASSLIKE} as {CLASSLIKE} because the name is already in use

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidConstantExpression

Constant expression contains invalid operations ({CODE})

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidNode

%s

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidTraitUse

Invalid trait use: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanInvalidWriteToTemporaryExpression

Cannot use temporary expression ({CODE} of type {TYPE}) in write context

e.g. this issue is emitted when analyzing this PHP file.

PhanPrivateFinalConstant

Private constant is not allowed to be final

e.g. this issue is emitted when analyzing this PHP file.

PhanPrivateFinalMethod

PHP warns about private method {METHOD} being final

e.g. this issue is emitted when analyzing this PHP file.

PhanPropertyHookWithDefaultValue

Virtual property {PROPERTY} cannot have a default value - only properties with a set hook or backing storage can have defaults

e.g. this issue is emitted when analyzing this PHP file.

PhanReadonlyPropertyHasSetHook

Readonly property {PROPERTY} cannot have a set hook

e.g. this issue is emitted when analyzing this PHP file.

PhanReadonlyPropertyMissingType

Readonly property ${PROPERTY} must have a declared type

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxCompileWarning

Saw a warning while parsing: {DETAILS}

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxEmptyListArrayDestructuring

Cannot use an empty list in the left hand side of an array destructuring operation

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxEnumCaseExpectedValue

Syntax error: Case {CONST} of backed enum {CLASS} must have a value of type {TYPE}

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxEnumCaseUnexpectedValue

Syntax error: Case {CONST} of unit enum {CLASS} must not have a value

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxError

This emits warnings for unparsable PHP files (detected by php-ast). Note: This is not the same thing as running php -l on a file - PhanSyntaxError checks for syntax errors, but not semantics such as where certain expressions can occur (Which php -l would check for).

Note: If the native parser is used, the reported column is a guess. Phan will use the column of the error reported by the polyfill if the errors are on the same line.

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxMixedKeyNoKeyArrayDestructuring

Cannot mix keyed and unkeyed array entries in array destructuring assignments ({CODE})

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxReturnExpectedValue

Syntax error: Function {FUNCTIONLIKE} with return type {TYPE} must return a value (did you mean "{CODE}" instead of "{CODE}"?)

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxReturnStatementInNever

Syntax error: function {FUNCTIONLIKE} has return type {TYPE}, meaning it must not contain return statements (it should exit, throw, or run forever)

e.g. this issue is emitted when analyzing this PHP file.

PhanSyntaxReturnValueInVoid

Syntax error: {TYPE} function {FUNCTIONLIKE} must not return a value (did you mean "{CODE}" instead of "{CODE}"?)

e.g. this issue is emitted when analyzing this PHP file.