PhpStorm 2019.1 Help

Change inspection severity

Inspection severity levels indicate how seriously the detected code problems affect your project. Every severity level has its own highlighting style. In PhpStorm, there is a set of predefined severity levels:

  • Error icon Error

  • Warning icon Warning

  • Weak Warning icon Weak Warning

  • Server Problem icon Server Problem

  • Typo icon Typo

  • Info icon No highlighting, only fix

Change inspection severity in all scopes

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections, and select the profile that you want to modify.

  2. Select the necessary inspection from the list. Make sure that it is enabled.

  3. From the Severity list, select a new severity level. You can also right-click the inspection and select the severity level from the context menu.

  4. Apply the changes and close the dialog. The modified inspection will now have the new severity level in the selected profile.

If the list of available severity levels lacks the one that you need, you can create a new one.

Change inspection severity in specific scopes

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections and select the profile in which you want to make changes.

  2. Select the necessary inspection from the list. Make sure that it is enabled.

  3. From the In All Scopes list, select the scope for which you want to change the severity.

    PhpStorm shows severities for two scopes: the selected one and Everywhere else.

    To add one more scope, click the Add button. If you want to create a new scope, select Edit Scopes Order from the list of scopes and click the Edit icon.

  4. Select the necessary severity level from the list and apply the changes.

    Changing inspection severity by scope

If you enable an inspection in multiple scopes, and files in these scopes match, the IDE will process these scopes according to their order in the list. For more information, refer to Change the order of scopes.

Configure error highlighting

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections and select the profile in which you want to make the changes.

  2. From the list of severity levels, select Edit severities.

  3. Select the severity for which you want to change the formatting and click Edit Settings | Colors & Fonts.

  4. Configure the new highlighting rules. Use the preview section at the bottom of the dialog.

    Changing error highlighting

You can also modify highlighting in the settings under Editor | Color Scheme | General.

Create a new severity level

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections and select the profile in which you want to create a new severity level.

  2. Click any inspection and select Edit severities from the list of severity levels.

  3. In the Severities Editor dialog, click the Add button and name the new severity level.

  4. Configure the formatting and set a priority using the Up and Down buttons — the higher you put the severity on the list, the higher its priority.

  5. Click OK when finished.

    Creating a new severity

Customizing inspections for Undefined elements

In the PHP context, the Undefined field and Undefined method inspections may erroneously report severe problems when actually no problems take place. This happens when you attempt to access or assign a value to a property, or to call a method that is not explicitly defined, while the referenced class contains the __get(), __set(), or __call() magic methods. No errors should be reported in such cases because these methods are invoked every time an undefined property or method is referenced, however, PhpStorm still treats them as errors or warnings, depending on the severity level you have specified for the inspection.

Suppress reporting for Undefined field errors

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections.

  2. Select the Undefined field inspection in the list.

  3. In the Options area, clear the Notify about access to a field via magic method and Notify about PHP dynamic field declaration checkboxes.

When the checkboxes are selected, PhpStorm reports errors even if the class contains the __get() and __set() magic methods.

Adjust reporting for Undefined method errors

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections.

  2. Select the Undefined method inspection in the list.

  3. In the Options area, select the Downgrade severity if __magic methods are present in class checkbox.

Undefined methods will now be indicated with the severity level that is one step lower than specified for inspections in general (by default, Info instead of Warning).

Configure reporting for Undefined variable errors

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Inspections.

  2. Select the Undefined field inspection in the list.

  3. In the Options area, configure the inspection as follows:

    • Enable inspection in global space: select this checkbox to run the inspection against variables outside functions/methods, classes, and namespaces, that is, in the global space.

      Undefined variable in global space
    • Report that variable might have not been defined: select this checkbox to have an error reported even if the definition of a variable is not definitely missing. Such situation may take place when a variable is used in several paths and some of them may never be reached, for example, in if() statements:

      ps_undefined_var_if_statement.png
    • Ignore 'include' and 'require' statements: Suppose the inspection scope contains an include or require statement. If this checkbox is cleared, PhpStorm treats an undefined variable as defined in the classes referenced through these statements and no error is reported. If this checkbox is selected, an Undefined variable error is reported.

Last modified: 26 July 2019

See Also

Procedures: