Configuring Inspection Severities
In this section:
- Changing severity of an inspection
- Changing severity of an inspection for different scopes
- Changing the highlighting style for a specific severity level
- Defining a custom severity level
Inspection severity indicates how seriously the code issues detected by the inspection impact the project and determines how the detected issues should be highlighted in the editor. By default, each inspection has one of the following severity levels:
- Server problem
- Weak Warning
You can increase or decrease the severity level of each inspection. That is, you can force PhpStorm to display some warnings as errors or weak warnings. In a similar way, what is initially considered a weak warning can be displayed as a warning or error, or just as info.
You can also configure the color and font style used to highlight each severity level. Besides, you can create custom severity levels and set them for specific inspections.
If necessary, you can set different severity levels for the same inspection in different scopes.
Changing severity of an inspection
- In the inspection settings, select the desired profile. The inspections associated with the profile are displayed in the tree view.
- Select the desired inspection. If this inspection is disabled, select the check box next to it.
- Select the desired severity from the context menu of the inspection or from the
Severity selector on the right:
Note that inspections, whose state is changed relative to the default values, and all their grouping nodes are highlighted with blue.
- Apply the changes. The modified inspection will now have the new severity level when this profile is used.
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 a property or to assign a value to a property that is not explicitly defined
while the referenced class contains the
_set() magic methods.
No error should be reported because these methods are invoked every time an undefined property is referenced,
however, PhpStorm still treats them as errors or warnings, depending on the severity you have specified for the inspection in general.
To suppress reporting Undefined method errors in such cases, re-configure the inspection severity. To do that, open the Inspections page of the Settings dialog box, click the inspection name in the list and select the Downgrade severity if __magic methods are present in class check box in the Options area. After that undefined properties in such cases will be indicated one step lower than specified for inspections in general, by default, Info instead of Warning.
To suppress irrelevant reporting of Undefined field errors,
clear the Notify about access to a field via magic method and Notify about PHP dynamic field declaration check boxes.
When the check boxes are selected, PhpStorm reports errors even if the class contains the
__set() magic methods.
- Enable inspection in global space: select this check box to run the inspection against variables outside functions/methods, classes, and namespaces, that is, in the global space.
Report that variable might have not been defined: select this check box to have a warning displayed
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
Ignore 'include' and 'require' statements
Suppose the inspection scope contains an
requirestatement. If this check box is cleared, PhpStorm treats such variable as defined in the classes referenced through these statements and no error is reported. If this check box is selected, an Undefined variable error is reported.
Changing severity of an inspection for different scopes
- Choose the desired profile and inspection.
- Click the drop-down list In All Scopes, and select the scope you want to change inspection severity in:
PhpStorm shows severities for two scopes: for the selected one and Everywhere else
- Click severity drop-down list for the selected scope and choose the appropriate severity level from the drop-down list:
Changing the highlighting style for a specific severity level
Do one of the following:
- In the Settings dialog, select , and then select the style corresponding to the desired severity level.
In the inspection settings, select the desired inspection and choose
Edit severities from the Severity selector.
Next, in the Severities Editor dialog box that opens, select the desired severity level and click Editor | Colors & Fonts.
Either way you will see the styles associated with this severity in the Colors and Fonts settings page.
- Configure the color and font styles as necessary and apply changes. The detected issues with the corresponding severity will now be highlighted in the editor with the modified style when the current profile is used.
Defining a custom severity level
- In the inspection settings, select the desired inspection and choose Edit severities from the Severity selector. .
- In the Severities Editor dialog box that opens, click :
- Type the name for the new severity in the New Highlight Severity
The custom severity is added to the list of severities.
- Specify color and font settings for the new severity using the controls to the right of the list of severities.
- Use the Up and Down buttons to change the priority of the new severity.
Apply the changes.
The new severity level will now be available for all inspections within the current
assign it to specific inspections and get the corresponding code issues
highlighted with the specified style in the editor.
If necessary, you can remove the custom severity level later by selecting it in the Severities Editor dialog box and clicking .
You cannot change priorities of the pre-defined severity levels, or remove them.