Inspectopedia 2025.2 Help

Undefined variable

Produces two types of warnings:

  • Undefined variable: the variable's definition is not found in the project files, configured include paths, or among the PHP predefined variables.

  • Variable might have not been defined: there are one or more paths to reach the line with the variable usage without defining it.

Use the options below to customize the inspection:

  • Report that variable is probably undefined: clear the checkbox to disable the Variable might have not been defined warnings.

  • Enable inspection in global space: by default, the inspection is enabled for global space. Clear the checkbox to only report undefined variables from functions' local scope.

  • Search for variable's definition outside the current file: if selected, the IDE reports a global variable as undefined only in case there are no include or require statements in the current file and the variable's definition cannot be found in the project. Note that the IDE does not examine the actual content of included files but only checks the presence of include or require statements.

    Otherwise, if not selected, the IDE searches for the variable's definition only in the current file and ignores the include or require statements if any.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

PhpUndefinedVariableInspection
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | PHP | Undefined symbols

Inspection options

Here you can find the description of settings available for the Undefined variable inspection, and the reference of their default values.

Report that variable is probably undefined

Default value:

Selected
Enable inspection in global space

Default value:

Selected
Search for variable's definition outside the current file

Default value:

Not selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection PhpUndefinedVariableInspection

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Last modified: 18 September 2025