Diagnostics

missing_method

Report if trying to call a class method which does not exist.

<?php

class Foobar
{
}

$f = new Foobar();
$f->bar();

Diagnostic(s):

  • ERROR: Method "bar" does not exist on class "Foobar"

docblock_missing_return

Report when a method has a return type should be augmented by a docblock tag

<?php

class Foobar
{
    public function foo() {
        return 'foobar';
    }
}

Diagnostic(s):

  • WARN: Method "foo" is missing docblock return type: string

docblock_missing_param

Report when a method has a parameter with a type that should be augmented by a docblock tag.

<?php

class Foobar
{
    public function foo(Closure $foobar) {
    }
}

Diagnostic(s):

  • WARN: Method "foo" is missing @param $foobar

assignment_to_missing_property

Report when assigning to a missing property definition.

<?php

class Foobar {
    public function baz(){
        $this->bar = 'foo';
    }
}

Diagnostic(s):

  • WARN: Property "bar" has not been defined

missing_return_type

Report if a method is missing a return type.

<?php

class Foobar {
    public function foo()
    {
        return 'string';
    }
}

Diagnostic(s):

  • WARN: Missing return type `string`

unresolvable_name

Report if a name (class, function, constant etc) can not be resolved.

<?php

function foo(string $name)
}


foo(Foobar::class);

Diagnostic(s):

  • ERROR: Class "Foobar" not found

unused_import

Report if a use statement is not required.

<?php

use Foobar as Barfoo;
use Bagggg as Bazgar;

new Barfoo();

Diagnostic(s):

  • WARN: Name "Bazgar" is imported but not used

deprecated usage

Report when a deprecated symbol (class, method, constant, function etc) is used.

<?php

/** @deprecated */
class Deprecated {
    public static foo(): void {}
}

class NotDeprecated {
    public static foo(): void {}
}

$fo = new Deprecated();
Deprecated::foo();
new NotDeprecated();

Diagnostic(s):

  • WARN: Call to deprecated class "Deprecated"

  • WARN: Call to deprecated class "Deprecated"

undefined_variable

Report if a variable is undefined and suggest variables with similar names.

<?php

$zebra = 'one';
$foa = 'two';

if ($foo) {
}

Diagnostic(s):

  • ERROR: Undefined variable "$foo", did you mean "$foa"

docblock_missing_extends_tag

Report when a class extends a generic class but does not provide an @extends tag.

<?php

/**
 * @template T
 */
class NeedGeneric
{
}

class Foobar extends NeedGeneric
{
}

Diagnostic(s):

  • WARN: Missing generic tag `@extends NeedGeneric<mixed>`

docblock_missing_implements_tag

Report when a class extends a generic class but does not provide an @extends tag.

<?php

/**
 * @template T
 */
interface NeedGeneric
{
}

class Foobar implements NeedGeneric
{
}

Diagnostic(s):

  • WARN: Missing generic tag `@implements NeedGeneric<mixed>`