PHPStan

https://phpstan.org/

Analyse statique de code:

Level 0

Unknown classes

Unknown functions

Unknown `$this->foo()` calls

$this->foo($wrong, $number, $of, $argument)

Always undefined variable

Level 1

Possible undefined variable

Unknown magic method with __call

Unknown magic properties with __get

Level 2

Unknown methods

PHPDoc validation

Phpdoc

int

string

bool (true, false)

null

float

array

iterable

callable

resource

void

object

array-key = (int|string)

int<1, 10>

positive-int = int<1, max>

negative-int = int<min, -1>

class-string

non-empty-string

non-falsy-string

non-empty-array

list

non-empty-list

FooClass::TYPE_*

never

Stubs

Level 3

Return types

Types assigned to properties

Level 4

Always false checks

Dead `else` check

Unreachable code after return

Type never

Level 5

Checking type of argument passed to method

Checking type of argument passed to function

Intersection vs Union

Level 6

Report missing typehint

Report missing iterable value type

Report missing templates in generics

Iterables

string[]

array<string>

array<array-key, string>

array<int|string, string>

array<string, string>

array<int, string>

array{e: string, 1: string}

array{e: string, f: string}

array{0: string, 1: string}

list<string>

array<array<string, array{id: int, options: array<string, mixed>}>>

Alias

Generics

Generics (suite)

Generics (suite)

Generics (suite)

Level 7

Report partially wrong union type

Collections

Level 8

Report partially wrong union type with null

Report calling method on nullable values

Entities

Plugins

Symfony

Plugins

Doctrine

Strict-rules

Todo ?

Narrowing types

Dynamic results

Conditional return types

Dynamic extensions

Ignorer les erreurs ?

Baseline

vendor/bin/phpstan analyse --generate-baseline

Débugger les erreurs !

https://phpstan.org/try

PHPStan

By Vincent Langlet