PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: Explicit types

Last modified: 13 May 2022

Reports a type annotation that doesn't match the current code style for explicit types.

Type declarations are not necessary when the type that is inferred from the context exactly matches the type annotation, for example:

var pi: number = 3.14

In some cases it is preferable to always have explicit types - this prevents accidental type changes and makes code more explicit.