internal/Issue-Types-Caught-by-Phan.md
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.
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)
Cannot directly access class constant {CONST} of trait {TRAIT} defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
final class FinalClass
class A extends FinalClass {}
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.
class A extends Closure {}
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.
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.
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.
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.
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.
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.
Cannot make non static property {PROPERTY} into the static property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Declaration of class constant {CONST} overrides final constant {CONST} defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
Accessing own constructor directly via {CLASS}::__construct
e.g. this issue is emitted when analyzing this PHP file.
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.
class A { public $prop = 'value'; }
$x = A::$prop;
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.
class C1 { private static $p = 42; }
print C1::$p;
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.
class C1 { protected static $p = 42; }
print C1::$p;
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.
class A { public static $prop = 'value'; }
$x = (new A())->prop;
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.
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.
Cannot modify readonly property {PROPERTY} after initialization
e.g. this issue is emitted when analyzing this PHP file.
Cannot modify {TYPE} property {PROPERTY} defined at {FILE}:{LINE} from {FILE}:{LINE}
Access level to {METHOD} must be compatible with {METHOD} defined in {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
Access level to {METHOD} must be compatible with internal {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
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.
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
Cannot make static property {PROPERTY} into the non static property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
Attempting to inherit internal {CLASSLIKE} as if it were a {CLASSLIKE}
e.g. this issue is emitted when analyzing this PHP file.
Access level to {CONST} must be compatible with {CONST} defined in {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
Access level to {CONST} must be compatible with internal {CONST}
Access level to {PROPERTY} must be compatible with {PROPERTY} defined in {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
Access level to {PROPERTY} must be compatible with internal {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
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).
'{CONST}' is an invalid FQSEN for a constant
e.g. this issue is emitted when analyzing this PHP file.
'{CONST}' has a reserved keyword in the constant name
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
This category of issue is emitted when there are compatibility issues.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
e.g. this issue is emitted when analyzing this PHP file.
Cannot use {TYPE} as a standalone type before php 8.2.
e.g. this issue is emitted when analyzing this PHP file
This is used for notices that are emitted while Phan is parsing with the native parser. Currently unused.
Saw a parse notice: {DETAILS}
Trait {TRAIT} declares constant {CONST} which is only allowed in 8.2+
e.g. this issue is emitted when analyzing this PHP file.
Cannot use {TYPE} as a type before php 8.2.
e.g. this issue is emitted when analyzing this PHP file.
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.
Unparenthesized '{CODE}' is deprecated. Use either '{CODE}' or '{CODE}'
e.g. this issue is emitted when analyzing this PHP file.
The unset cast (in {CODE}) is a fatal error.
e.g. this issue is emitted when analyzing this PHP file.
Only properties of enums can be fetched in constant expressions, {TYPE} given
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.
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.
new parent;
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.
Cannot use {CLASS} as type when not in object context in {FUNCTION}
e.g. this issue is emitted when analyzing this PHP file.
Suspicious reference to magic constant {CODE}: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
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.
Creating case-insensitive constants with define() is deprecated
e.g. this issue is emitted when analyzing this PHP file.
Using a deprecated class {CLASS} defined at {FILE}:{LINE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to deprecated class constant {CONST} defined at {FILE}:{LINE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw deprecated encapsulated string variable syntax for {CODE}: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
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.
/** @deprecated */
function f1() {}
f1();
Deprecated argument usage for function {FUNCTIONLIKE}: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Call to deprecated function {FUNCTIONLIKE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to deprecated constant {CONST}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Implicit nullable parameters ({TYPE} {PARAMETER} = null) have been deprecated in PHP 8.4
e.g. this issue is emitted when analyzing this PHP file.
Using a deprecated interface {INTERFACE} defined at {FILE}:{LINE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Reference to deprecated property {PROPERTY} defined at {FILE}:{LINE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Using a deprecated trait {TRAIT} defined at {FILE}:{LINE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Issues in this category are emitted when you have reasonable code but it isn't doing anything. They're all low severity.
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.
Saw a foreach statement with empty iterable type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Empty function {FUNCTION}
e.g. this issue is emitted when analyzing this PHP file.
Empty private method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Empty protected method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Empty public method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Saw a yield from statement with empty iterable type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Emitted when you have an array that is not used in any way.
Unused array
This will be emitted for the following code.
[1,2,3];
Unused array offset fetch
e.g. this issue is emitted when analyzing this PHP file.
Unused result of a binary '{OPERATOR}' operator
e.g. this issue is emitted when analyzing this PHP file.
Unused result of a ({TYPE})({CODE}) cast
e.g. this issue is emitted when analyzing this PHP file.
Emitted when you have a closure that is unused.
Unused closure
This will be emitted for the following code.
function () {};
Emitted when you have a reference to a constant that is unused.
Unused constant
This will be emitted for the following code.
const C = 42;
C;
Unused result of an empty({CODE}) check
e.g. this issue is emitted when analyzing this PHP file.
Unused result of an encapsulated string literal
e.g. this issue is emitted when analyzing this PHP file.
Unused result of an isset({CODE}) check
e.g. this issue is emitted when analyzing this PHP file.
This match expression only has the default arm in {CODE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
Unused result of a numeric literal {SCALAR} near this line
e.g. this issue is emitted when analyzing this PHP file.
Emitted when you have a reference to a property that is unused.
Unused property
This will be emitted for the following code.
class C {
public $p;
function f() {
$this->p;
}
}
Saw a repeated silence operator in {CODE}
e.g. this issue is emitted when analyzing this PHP file.
Unused result of a string literal {STRING_LITERAL} near this line
e.g. this issue is emitted when analyzing this PHP file.
This switch statement only has the default case
e.g. this issue is emitted when analyzing this PHP file.
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.
Unused result of a unary '{OPERATOR}' operator
e.g. this issue is emitted when analyzing this PHP file.
Emitted when you have a reference to a variable that is unused.
Unused variable
This will be emitted for the following code.
$a = 42;
$a;
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.
Providing an unused optional parameter ${PARAMETER} to {FUNCTIONLIKE} defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero write references to PHPDoc @property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
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.
Possibly zero write references to protected property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero write references to public property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
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.
Short arrow function shadows variable ${VARIABLE} from the outer scope
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw a for loop which probably has no side effects
e.g. this issue is emitted when analyzing this PHP file.
Saw a foreach loop which probably has no side effects
e.g. this issue is emitted when analyzing this PHP file.
Saw a while loop which probably has no side effects
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
class C {}
Keep in mind that for the following code we'd still emit the issue.
class C2 {}
$v = 'C2';
new $v;
$v2 = 'C' . (1 + 1);
new $v2;
YMMV.
Possibly zero references to {FUNCTION}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to global constant {CONST}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to function {FUNCTION}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to PHPDoc @property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to private class constant {CONST}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to private method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to private property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to protected class constant {CONST}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to protected method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to protected property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to public class constant {CONST}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to public method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to public property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to use statement for constant {CONST} ({CONST})
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to use statement for function {FUNCTION} ({FUNCTION})
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero references to use statement for classlike/namespace {CLASSLIKE} ({CLASSLIKE})
e.g. this issue is emitted when analyzing this PHP file.
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.
Closure use variable ${VARIABLE} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
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.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} is never used
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Unused definition of variable ${VARIABLE} as a caught exception
e.g. this issue is emitted when analyzing this PHP file.
Variable ${VARIABLE} for caught exception is declared as unused. Omit the variable instead.
e.g. this issue is emitted when analyzing this PHP file.
Unreferenced definition of variable ${VARIABLE} as a global variable
e.g. this issue is emitted when analyzing this PHP file.
Unused definition of variable ${VARIABLE} as a reference
e.g. this issue is emitted when analyzing this PHP file.
Unreferenced definition of variable ${VARIABLE} as a static variable
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
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.
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
Uses of ${VARIABLE} could probably be replaced with an empty array
Uses of ${VARIABLE} could probably be replaced with false or a named constant
Uses of ${VARIABLE} could probably be replaced with a literal or constant float
Uses of ${VARIABLE} could probably be replaced with literal integer or a named constant
Uses of ${VARIABLE} could probably be replaced with null or a named constant
Uses of ${VARIABLE} could probably be replaced with a literal or constant string
Uses of ${VARIABLE} could probably be replaced with true or a named constant
Possibly zero read references to PHPDoc @property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero read references to private property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero read references to protected property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
Possibly zero read references to public property {PROPERTY}
e.g. this issue is emitted when analyzing this PHP file.
This category of error comes up when you're messing up your method or function parameters in some way.
Cannot mix named arguments and argument unpacking in {CODE}
e.g. this issue is emitted when analyzing this PHP file.
Cannot repeat the same name for named arguments ({CODE}) and ({CODE})
e.g. this issue is emitted when analyzing this PHP file.
Saw a call with arguments ({CODE}) and ({CODE}) passed to the same parameter of {FUNCTIONLIKE} defined at {FILE}:{LINE}
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.
Missing named argument for {PARAMETER} in call to {METHOD} defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
Missing named argument for {PARAMETER} in call to {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
Note that this it may be appropriate to suppress this under the following circumstances:
$unused* or $_@internalSaw 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.
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.
Redefinition of parameter {PARAMETER}
e.g. this issue is emitted when analyzing this PHP file.
Required parameter {PARAMETER} follows optional {PARAMETER}
This will be emitted for the following code
function f2($p1 = null, $p2) {}
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.
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.
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.
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.
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}
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.
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.
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.
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.
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.
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.
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.
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.
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.
Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a non-reference parameter overriding a reference parameter)
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.
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.
Declaration of {METHOD} should be compatible with {METHOD} (parameter #{INDEX} is a non-variadic parameter replacing a variadic parameter) defined in {FILE}:{LINE}
Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} is a non-variadic parameter replacing a variadic parameter)
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.
Declaration of {METHOD} should be compatible with internal {METHOD} (parameter #{INDEX} of type '{TYPE}' cannot replace original parameter of type '{TYPE}')
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
The last argument to {FUNCTIONLIKE} must be of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
The second to last argument to {FUNCTIONLIKE} must be of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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
function f6($i) {}
f6();
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.
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.
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
strlen();
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.
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.
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
function f7($i) {}
f7(1, 2);
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.
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
strlen('str', 42);
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.
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.
Argument {INDEX} is {TYPE} but {FUNCTIONLIKE} takes {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Saw positional argument ({CODE}) after a named argument {CODE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
Saw a call with undeclared named argument ({CODE}) to {FUNCTIONLIKE}
e.g. this issue is emitted when analyzing this PHP file.
This category of issue comes up when more than one thing of whatever type have the same name and namespace.
Duplicate declaration of static variable ${VARIABLE} in {FUNCTIONLIKE} - previously declared at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Declaration of {METHOD} must be compatible with {METHOD} in {FILE} on line {LINE}
{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.
{CLASS} defined at {FILE}:{LINE} was previously defined as {CLASS} at {FILE}:{LINE}
This issue will be emitted for code like
class C15 {}
class C15 {}
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.
Class constant {CONST} defined at {FILE}:{LINE} was previously defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
{CLASS} defined at {FILE}:{LINE} was previously defined as {CLASS} internally
This issue will be emitted for code like
class DateTime {}
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
function f9() {}
function f9() {}
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
function strlen() {}
Property ${PROPERTY} defined at {FILE}:{LINE} was previously defined at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
e.g. this issue is emitted when analyzing this PHP file.
{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.
{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.
{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.
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.
Potentially calling an abstract static method {METHOD} in {CODE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Static call to non-static method {METHOD} defined at {FILE}:{LINE}. This would throw an Error.
class C19 { function f() {} }
C19::f();
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.
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.
This category of issue come from using incorrect types or types that cannot cast to the expected types.
Saw attribute {TYPE} which was declared without {CODE}
e.g. this issue is emitted when analyzing this PHP file.
Saw attribute with fqsen {TYPE} which was a {CODE} instead of a class
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Using {CODE} ?? null seems unnecessary - the expression appears to always be defined
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw {CODE} with a divisor of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Classlike {CLASSLIKE} cannot implement {INTERFACE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Impossible attempt to cast {CODE} of type {TYPE} to {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
Impossible attempt to check if {CODE} of type {TYPE} is identical to {CODE} of type {TYPE} in the global scope (likely a false positive)
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.
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.
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.
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)
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.
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.
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.
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.
Attempting to use a mixin of invalid or missing type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
{PARAMETER} is variadic in comment, but not variadic in param ({PARAMETER})
e.g. this issue is emitted when analyzing this PHP file.
{PARAMETER} is not variadic in comment, but variadic in param ({PARAMETER})
e.g. this issue is emitted when analyzing this PHP file.
Saw {CODE} with modulus of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Call to method {METHOD} on non-class type {TYPE}
An example would come from
$v8 = null;
$v8->f();
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Call to method {METHOD} on type {TYPE} that could be a non-object
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
Cannot override final property hook {PROPERTY}::{METHOD} defined at {FILE}:{LINE}
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.
Property hook {PROPERTY}::{METHOD} returns {CODE} of type {TYPE} but property is declared as {TYPE}
Redundant attempt to cast {CODE} of type {TYPE} to {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
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.
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.
Suspicious attempt to check if {CODE} of type {TYPE} is truthy/falsey. This contains both objects/arrays and scalars
Suspicious attempt to check if {CODE} of type {TYPE} is truthy/falsey. This is false both for '' and '0'
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.
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.
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.
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.
Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} in the global scope (likely a false positive)
Suspicious attempt to compare {CODE} of type {TYPE} to {CODE} of type {TYPE} in a loop body (likely a false positive)
Invalid array operand provided to operator '{OPERATOR}' between types {TYPE} and {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Suspicious array access to {CODE} of type {TYPE}
This issue will be emitted for the following code
$a = false; if($a[1]) {}
Suspicious array access to {CODE} of type null
e.g. this issue is emitted when analyzing this PHP file.
Suspicious array access to {CODE} of nullable type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Suspicious attempt to unset an offset of a value {CODE} of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
array to {TYPE} comparison
An example would be
if ([1, 2] == 'string') {}
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.
{TYPE} to array comparison
An example would be
if (42 == [1, 2]) {}
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.
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.
array to {TYPE} conversion
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw an error when attempting to infer the type of expression {CODE}: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Expected an object instance but saw expression {CODE} with type {TYPE}
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.
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.
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.
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.
Instantiation of abstract class {CLASS}
This issue will be emitted for the following code
abstract class D {} (new D);
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.
Saw instantiation of enum {ENUM}
e.g. this issue is emitted when analyzing this PHP file.
Instantiation of interface {INTERFACE}
This issue will be emitted for the following code
interface E {} (new E);
Instantiation of trait {TRAIT}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
Probably unused assignment to function result {CODE} for function returning {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Saw type {TYPE} which cannot be a callable
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Method name of callable must be a string, got {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Expected an object to be passed to clone() but got {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Invalid @phan-closure-scope: expected a class name, got {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Invalid offset {SCALAR} of {CODE} of array type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Eval statement was passed an invalid expression of type {TYPE} (expected a string)
e.g. this issue is emitted when analyzing this PHP file.
Invalid value {CODE} of type {TYPE} in an array destructuring assignment, expected {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Invalid operator: right operand is array and left is not
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: left operand of {OPERATOR} is {TYPE} (expected array or number)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: left operand of {OPERATOR} is {TYPE} (expected int|string)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: left operand of {OPERATOR} is {TYPE} (expected int)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: left operand of {OPERATOR} is {TYPE} (expected number)
e.g. this issue is emitted when analyzing this PHP file.
Instance method name must be a string, got {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Require statement was passed an invalid expression of type {TYPE} (expected a string)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: left operand is array and right is not
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: right operand of {OPERATOR} is {TYPE} (expected array or number)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: right operand of {OPERATOR} is {TYPE} (expected int|string)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: right operand of {OPERATOR} is {TYPE} (expected int)
e.g. this issue is emitted when analyzing this PHP file.
Invalid operator: right operand of {OPERATOR} is {TYPE} (expected number)
e.g. this issue is emitted when analyzing this PHP file.
Static method name must be a string, got {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
{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.
@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.
@throws annotation of {FUNCTIONLIKE} has invalid trait type {TYPE}, expected a class
e.g. this issue is emitted when analyzing this PHP file.
@throws annotation of {FUNCTIONLIKE} has invalid non-object type {TYPE}, expected a class
e.g. this issue is emitted when analyzing this PHP file.
@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.
{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.
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.
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.
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.
Invalid operator: unary operand of {STRING_LITERAL} is {TYPE} (expected number)
e.g. this issue is emitted when analyzing this PHP file.
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.
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 ignores the return value of some magic methods, such as __set)
class A { public function __set() { return true; } }
Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE} defined at {FILE}:{LINE}
This will be emitted for the code
function f8(int $i) {}
f8('string');
Argument {INDEX} (${PARAMETER}) is {CODE} of type {TYPE} but {FUNCTIONLIKE} takes {TYPE}
This will be emitted for the code
strlen(42);
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.
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.
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.
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.
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.
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.
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.
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Default value for {TYPE} ${PARAMETER} can't be {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
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
foreach (null as $i) {}
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.
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.
Assigning {CODE} of type {TYPE} to property but {PROPERTY} is {TYPE}
This issue is emitted from the following code
function f(int $p = false) {}
{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.
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.
Default value for {TYPE} ${PROPERTY} can't be {CODE} of type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Assigning {CODE} of type {TYPE}{DETAILS} to property but {PROPERTY} is {TYPE}{DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
{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.
Returning {CODE} of type {TYPE} but {FUNCTIONLIKE} is declared to return {TYPE}
This issue is emitted from the following code
class G { /** @param string $s */ function f($s) : int { return $s; } }
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.
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.
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:
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
class G { function f() : int { return 'string'; } }
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.
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.
Method {METHOD} is declared to return {TYPE} in phpdoc but has no return value
This issue is emitted from the following code
class H { function f() : int {} }
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.
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.
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.
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.
Only variables can be passed by reference at argument {INDEX} of {FUNCTIONLIKE}
This issue is emitted from the following code
class F { static function f(&$v) {} } F::f('string');
Only variables can be returned by reference in {FUNCTIONLIKE}
e.g. this issue is emitted when analyzing this PHP file.
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.
Must call parent::__construct() from {CLASS} which extends {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
Saw type {TYPE} which is possibly not a callable
e.g. this issue is emitted when analyzing this PHP file.
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.
Possibly invalid offset {SCALAR} of {CODE} of array type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Suspicious argument {CODE} of type {TYPE} for an echo/print statement
e.g. this issue is emitted when analyzing this PHP file.
Indirect variable ${(expr)} has invalid inner expression type {TYPE}, expected string/integer
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
Cannot use void return value {CODE} as a function argument
e.g. this issue is emitted when analyzing this PHP file.
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:
class A { /** @return void */ function v() {} }
$a = (new A)->v();
Suspicious use of void return value {CODE} where a value is expected
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
non-abstract class {CLASS} contains abstract method {METHOD} declared at {FILE}:{LINE}
e.g. this issue is emitted when analyzing this PHP file.
non-abstract class {CLASS} contains abstract internal method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Possible call to a function '{FUNCTIONLIKE}' with an empty FQSEN.
e.g. this issue is emitted when analyzing this PHP file.
Possible use of a classlike '{CLASSLIKE}' with an empty FQSEN.
e.g. this issue is emitted when analyzing this PHP file.
This low severity issue is emitted for empty files.
Empty file {FILE}
This would be emitted if you have a file with the contents
Possible call to a function '{FUNCTIONLIKE}' with an invalid FQSEN.
e.g. this issue is emitted when analyzing this PHP file.
Possible use of a classlike '{CLASSLIKE}' with an invalid FQSEN.
e.g. this issue is emitted when analyzing this PHP file.
Required file {FILE} is not a file
e.g. this issue is emitted when analyzing this PHP file.
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.
Reference to parent of class {CLASS} that does not extend anything
This issue will be emitted from the following code
class F { function f() { $v = parent::f(); } }
Global variable ${VARIABLE} is possibly undeclared
e.g. this issue is emitted when analyzing this PHP file.
Call to possibly undeclared method {METHOD} on type {TYPE} ({TYPE} does not declare the method)
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.
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.
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:
if ($cond) { $var = expr; }
// ...
if ($cond) { use($var); }
Attempting to read property {PROPERTY} which was unset in the current scope
e.g. this issue is emitted when analyzing this PHP file.
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
trait T1 {}
trait T2 {}
class A {
use T1 {T2::foo as bar;}
}
Reference to parent from trait {TRAIT}
This issue will be emitted from the following code
trait T { function f() { return parent::f(); } }
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.
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.
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.
Reference to undeclared class {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
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.
Reference to undeclared class {CLASS} in an attribute
e.g. this issue is emitted when analyzing this PHP file.
Catching undeclared class {CLASS}
The following code will emit this error.
try {} catch (Undef $exception) {}
Reference to constant {CONST} from undeclared class {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to undeclared class {CLASS} in callable {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
Checking instanceof against undeclared class {CLASS}
This issue will be emitted from the following code
$v = null;
if ($v instanceof Undef) {}
Call to method {METHOD} from undeclared class {CLASS}
This issue will be emitted from the following code
function g(Undef $v) { $v->f(); }
Reference to instance property {PROPERTY} from undeclared class {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to undeclared class {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to static property {PROPERTY} from undeclared class {CLASS}
e.g. this issue is emitted when analyzing this PHP file.
Reference to undeclared class {CLASS} in @phan-closure-scope
e.g. this issue is emitted when analyzing this PHP file.
This issue comes up when you reference a constant that doesn't exist.
Reference to undeclared constant {CONST}. This would throw an Error.
$v7 = UNDECLARED_CONSTANT;
Reference to undeclared class constant {CONST}
e.g. this issue is emitted when analyzing this PHP file.
Class extends undeclared class {CLASS}
This issue will be emitted from the following code
class E extends UndeclaredClass {}
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
some_missing_function();
Call to undeclared function {FUNCTION} in callable
e.g. this issue is emitted when analyzing this PHP file.
Global variable ${VARIABLE} is undeclared
e.g. this issue is emitted when analyzing this PHP file.
Class implements undeclared interface {INTERFACE}
class C17 implements UndeclaredInterface {}
Possible attempt to access missing magic method {FUNCTIONLIKE} of '{CLASS}'
e.g. this issue is emitted when analyzing this PHP file.
Reference to magic constant {CONST} that is undeclared in the current scope: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Call to undeclared method {METHOD}
e.g. this issue is emitted when analyzing this PHP file.
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.
Reference to undeclared property {PROPERTY}
This issue will be emitted from the following code
class C {}
$v = (new C)->undef;
Static call to undeclared method {METHOD}
This issue will be emitted from the following code
C::staticMethod();
Reference to undeclared static method {METHOD} in callable
e.g. this issue is emitted when analyzing this PHP file.
Static property '{PROPERTY}' on {CLASS} is undeclared
An example would be
class C22 {}
$v11 = C22::$p;
Variable ${VARIABLE} is undeclared
e.g. this issue is emitted when analyzing this PHP file.
Class uses undeclared trait {TRAIT}
e.g. this issue is emitted when analyzing this PHP file.
Class constant {CONST} has undeclared class type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Parameter ${PARAMETER} has undeclared type {TYPE}
This issue will be emitted from the following code
function f(Undef $p) {}
Property {PROPERTY} has undeclared type {TYPE}
This issue will be emitted from the following code
class D { /** @var Undef */ public $p; }
Return type of {METHOD} is undeclared type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
@throws type of {METHOD} has undeclared type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Variable ${VARIABLE} is undeclared
e.g. this issue is emitted when analyzing this PHP file.
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.
Variable ${VARIABLE} was undeclared, but array fields are being added to it.
e.g. this issue is emitted when analyzing this PHP file.
Non-variables ({CODE}) not allowed within use clause
This category contains issues related to Phan's generic type support
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.
Global variable {VARIABLE} may not be assigned an instance of a generic class
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.
Duplicate type false is redundant in union type {TYPE} (bool already includes false)
e.g. this issue is emitted when analyzing this PHP file.
Duplicate type true is redundant in union type {TYPE} (bool already includes true)
e.g. this issue is emitted when analyzing this PHP file.
Type {TYPE} contains both true and false - bool should be used instead
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Template type {TYPE} is already declared in this comment
e.g. this issue is emitted when analyzing this PHP file.
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.
Template type {TYPE} not used in return value of function/method {FUNCTIONLIKE}
e.g. this issue is emitted when analyzing this PHP file.
Template type {TYPE} is already declared in the containing class
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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).
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.
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.
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.
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.
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.
This is emitted for some (but not all) comments which Phan thinks are invalid or unparsable.
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.
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.
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.
Comment {STRING_LITERAL} refers to {TYPE} instead of \Closure - Assuming \Closure
e.g. this issue is emitted when analyzing this PHP file.
Comment declares @method {METHOD} multiple times
e.g. this issue is emitted when analyzing this PHP file.
Comment declares @property* ${PROPERTY} multiple times
e.g. this issue is emitted when analyzing this PHP file.
Comment declares @param ${PARAMETER} multiple times
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.
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.
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.
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.
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.
Expected @param annotation for ${PARAMETER} to be before the @param annotation for ${PARAMETER}
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw a line {COMMENT} with a type alias that could not be extracted
e.g. this issue is emitted when analyzing this PHP file.
Saw a union type {TYPE} with more than 1 type in a location that does not support union types
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.
@phan-debug-var requested for variable ${VARIABLE} - it has union type {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
The phpdoc comment for {COMMENT} cannot occur on a {TYPE}
e.g. this issue is emitted when analyzing this PHP file.
Saw misspelled annotation {COMMENT}. {SUGGESTION}
e.g. this issue is emitted when analyzing this PHP file.
{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.
{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.
{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.
{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.
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.
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.
Saw unextractable annotation for comment '{COMMENT}'
e.g. this issue is emitted when analyzing this PHP file.
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.
Saw unextractable annotation for a fragment of comment '{COMMENT}': '{COMMENT}'
e.g. this issue is emitted when analyzing this PHP file.
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.
Emitted for syntax errors.
'{OPERATOR}' not in the 'loop' or 'switch' context.
e.g. this issue is emitted when analyzing this PHP file.
Cannot '{OPERATOR}' {INDEX} levels.
e.g. this issue is emitted when analyzing this PHP file.
This detects code causing a PHP warning.
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
Cannot use constant {CONST} as {CONST} because the name is already in use
e.g. this issue is emitted when analyzing this PHP file.
Cannot use function {FUNCTION} as {FUNCTION} because the name is already in use
e.g. this issue is emitted when analyzing this PHP file.
Cannot use {CLASSLIKE} as {CLASSLIKE} because the name is already in use
e.g. this issue is emitted when analyzing this PHP file.
Constant expression contains invalid operations ({CODE})
e.g. this issue is emitted when analyzing this PHP file.
%s
e.g. this issue is emitted when analyzing this PHP file.
Invalid trait use: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
Cannot use temporary expression ({CODE} of type {TYPE}) in write context
e.g. this issue is emitted when analyzing this PHP file.
Private constant is not allowed to be final
e.g. this issue is emitted when analyzing this PHP file.
PHP warns about private method {METHOD} being final
e.g. this issue is emitted when analyzing this PHP file.
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.
Readonly property {PROPERTY} cannot have a set hook
e.g. this issue is emitted when analyzing this PHP file.
Readonly property ${PROPERTY} must have a declared type
e.g. this issue is emitted when analyzing this PHP file.
Saw a warning while parsing: {DETAILS}
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
Syntax error: Case {CONST} of unit enum {CLASS} must not have a value
e.g. this issue is emitted when analyzing this PHP file.
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.
Cannot mix keyed and unkeyed array entries in array destructuring assignments ({CODE})
e.g. this issue is emitted when analyzing this PHP file.
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.
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.
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.