PhpStorm 2023.3 Help

Quality Tools

PHP_CodeSniffer

In this section, enable and configure the PHP_CodeSniffer quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens PHP_CodeSniffer Dialog.

Show ignored files

Click to open the PHP_CodeSniffer Ignored Files dialog, which lists the files that PHP_CodeSniffer skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the PHP_CodeSniffer exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have PHP_CodeSniffer process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Check files with extensions

Provide a comma-separated list of file extensions that should be checked by PHP_CodeSniffer.

Show warnings as...

To have PHP_CodeSniffer report warnings in addition to errors, select the checkbox and choose the severity degree from the list. Clear the checkbox to have only errors reported and suppress reporting warnings.

Show sniff name

Select the checkbox to have the corresponding sniff's name displayed in the editor or the inspection results in addition to the inspection summary.

Installed standard paths

If you are relying on a custom third-party coding standard (for example, Coder or Joomla Coding Standards), you need to integrate it with PHP_CodeSniffer prior to using it. To do this, select the Installed standard paths checkbox, click the Browse button and select the custom standard installation directory in the dialog that opens.

Coding standard

Appoint the coding standard to apply.

  • To use one of the predefined coding standards, select it in the Coding standard list, appoint the coding style to check your code against. The list contains all the coding standards installed inside the main php_codesniffer directory structure.

  • To have your code checked against your own previously defined coding standard, choose Custom from the list and provide the path to the ruleset.xml file with your own coding standard. Type the path manually or click the Browse button and select the relevant folder in the dialog that opens.

PHP_CodeSniffer Dialog

The dialog opens when you click the Browse button next to the Configuration list on the PHP_CodeSniffer page.

Use this dialog to configure the used PHP interpreter, path to the PHP_CodeSniffer executable file, as well as PHP_CodeSniffer's behaviour. For more information, refer to PHP_CodeSniffer.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the PHP_CodeSniffer from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

PHP_CodeSniffer path

In this field, specify the location of the PHP_CodeSniffer script: phpcs.bat for Windows or phpcs for Linux and macOS.

PhpStorm detects the path to the PHP_CodeSniffer executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to phpcs.bat or phpcs ensures interaction between PhpStorm and PHP_CodeSniffer, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the phpcs --version command. If validation passes successfully, PhpStorm displays the information on the detected PHP_CodeSniffer version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from PHP_CodeSniffer. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the PHP_CodeSniffer process behavior depending on the configuration of your computer and the rule sets used.

PHP Code Beautifier and Fixer Settings

In this area, provide a custom path to the PHP Code Beautifier and Fixer tool in the Path to phpcbf field. Type the path manually or click the Browse button and select the path in the dialog that opens.

PHP Code Beautifier and Fixer lets you automatically fix many of the errors detected by PHP_CodeSniffer.

PHP CS Fixer

In this section, enable and configure the PHP CS Fixer quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens PHP CS Fixer Dialog.

Show ignored files

Click to open the PHP CS Fixer Ignored Files dialog, which lists the files that PHP CS Fixer skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the PHP CS Fixer exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have PHP CS Fixer process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Allow risky rules for built-in rulesets

Select the checkbox to allow risky rules, that is, the rules that can change code behavior. By default, risky rules are not allowed.

Ruleset

Appoint the ruleset to apply.

  • To use one of the predefined rulesets, select it from the drop-down list. The list contains all the rulesets declared inside the main php-cs-fixer directory structure.

  • To have your code checked against your own previously defined ruleset, choose Custom from the list and provide the path to the .php_cs or .php_cs.dist file with this ruleset. Type the path manually or click the Browse button and select the relevant folder in the dialog that opens.

PHP CS Fixer Dialog

The dialog opens when you click the Browse button next to the Configuration list on the PHP CS Fixer page.

Use this dialog to configure the used PHP interpreter, path to the PHP CS Fixer executable file, as well as PHP CS Fixer's behaviour. For more information, refer to PHP CS Fixer.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the PHP CS Fixer from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

PHP CS Fixer path

In this field, specify the location of the PHP CS Fixer script: php-cs-fixer.bat for Windows or php-cs-fixer for Linux and macOS.

PhpStorm detects the path to the PHP CS Fixer executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to php-cs-fixer.bat or php-cs-fixer ensures interaction between PhpStorm and PHP CS Fixer, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the php-cs-fixer --version command. If validation passes successfully, PhpStorm displays the information on the detected PHP CS Fixer version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from PHP CS Fixer. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the PHP CS Fixer process behavior depending on the configuration of your computer and the rule sets used.

Laravel Pint

In this section, enable and configure the Laravel Pint quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens Laravel Pint Dialog.

Show ignored files

Click to open the Laravel Pint Ignored Files dialog, which lists the files that Laravel Pint skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the Laravel Pint exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have Laravel Pint process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Reformat only uncommitted files

Select the checkbox to only modify the files that have uncommitted changes.

Path to pint.json

Specify the path to your own pint.json configuration file. pint.json files are optional: they are used to enable/disable specific rules from the predefined Laravel Pint presets, or to reuse custom rulesets from PHP CS Fixer.

Ruleset

Select one of Laravel Pint's predefined group of rules.

Laravel Pint Dialog

The dialog opens when you click the Browse button next to the Configuration list on the Laravel Pint page.

Use this dialog to configure the used PHP interpreter, path to the Laravel Pint executable file, as well as Laravel Pint's behaviour. For more information, refer to Laravel Pint.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the Laravel Pint from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

Laravel Pint path

In this field, specify the location of the Laravel Pint script: pint.bat for Windows or pint for Linux and macOS.

PhpStorm detects the path to the Laravel Pint executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to pint.bat or pint ensures interaction between PhpStorm and Laravel Pint, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. If validation passes successfully, PhpStorm displays the information on the detected Laravel Pint version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from Laravel Pint. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the Laravel Pint process behavior depending on the configuration of your computer and the rule sets used.

PHP Mess Detector

In this section, enable and configure the Mess Detector quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens Mess Detector Dialog.

Show ignored files

Click to open the Mess Detector Ignored Files dialog, which lists the files that Mess Detector skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the Mess Detector exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have Mess Detector process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Options

  • To use predefined rules, in the Options area, select the checkboxes next to the validations to be performed.

  • To use a custom ruleset:

    1. Create and save one or several ruleset files. A valid ruleset file is an .xml file that contains the <ruleset> root element with the name attribute. For more information about custom rulesets, refer to http://phpmd.org/documentation/creating-a-ruleset.html.

    2. In the Custom rulesets area, click Add button and select the relevant rule definition file in the dialog that opens. When you click OK, a new item is added to the Custom rulesets list, where the Name field shows the ruleset name retrieved from the attribute name within the <ruleset> tag and the File field shows the location of the selected ruleset file.

Mess Detector Dialog

The dialog opens when you click the Browse button next to the Configuration list on the Mess Detector page.

Use this dialog to configure the used PHP interpreter, path to the Mess Detector executable file, as well as Mess Detector's behaviour. For more information, refer to PHP Mess Detector.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the Mess Detector from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

Mess Detector path

In this field, specify the location of the Mess Detector script: phpmd.bat for Windows or phpmd for Linux and macOS.

PhpStorm detects the path to the Mess Detector executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to phpmd.bat or phpmd ensures interaction between PhpStorm and Mess Detector, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the phpmd --version command. If validation passes successfully, PhpStorm displays the information on the detected Mess Detector version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from Mess Detector. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the Mess Detector process behavior depending on the configuration of your computer and the rule sets used.

Psalm

In this section, enable and configure the Psalm quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens Psalm Dialog.

Show ignored files

Click to open the Psalm Ignored Files dialog, which lists the files that Psalm skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the Psalm exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have Psalm process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Configuration file

Provide the path to the Psalm configuration file. If the file is not present, PhpStorm displays the notification prompting you to create it.

Psalm config not found notification

Show info

Select the checkbox to have Psalm report the errors that are at a lower level than the errorLevel specified in the configuration file. If the checkbox is not selected, such errors will be ignored.

Find unused code

Select the checkbox to have Psalm report the located unused code (including unused variables).

Find unused @psalm-suppress annotations

Select the checkbox to have Psalm report all unused @psalm-suppress annotations.

Psalm Dialog

The dialog opens when you click the Browse button next to the Configuration list on the Psalm page.

Use this dialog to configure the used PHP interpreter, path to the Psalm executable file, as well as Psalm's behaviour. For more information, refer to Psalm.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the Psalm from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

Psalm path

In this field, specify the location of the Psalm script: psalm.bat for Windows or psalm for Linux and macOS.

PhpStorm detects the path to the Psalm executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to psalm.bat or psalm ensures interaction between PhpStorm and Psalm, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the psalm --version command. If validation passes successfully, PhpStorm displays the information on the detected Psalm version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from Psalm. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the Psalm process behavior depending on the configuration of your computer and the rule sets used.

PHPStan

In this section, enable and configure the PHPStan quality tool.

Item

Description

Configuration

Select the required interpreter from the list. The list contains all the currently configured local and remote PHP interpreters. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

Clicking the Browse button to the right of the drop-down list opens PHPStan Dialog.

Show ignored files

Click to open the PHPStan Ignored Files dialog, which lists the files that PHPStan skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the PHPStan exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.

  • To add a file, click the Add button and locate the desired file in the dialog that opens.

  • To delete a file from the list and have PHPStan process it again, select the file and click the Remove file button the Remove button.

  • To remove all the files from the list, click the Close button.

Full project run (batch mode only)

Use the option to select whether the entire project or only its source roots are included in the inspection run scope.

Level

Provide the desired Rule Level against which the PHPStan checks are performed. Note that if a configuration file is provided, PhpStorm relies on the level value specified in this file, and the Level field is ignored.

Configuration file

Provide the path to the PHPStan configuration file

Autoload file

Provide the path to the autoloader. Note that if a configuration file is provided, PhpStorm relies on the autoload-file value specified in this file, and the Autoload file field is ignored.

Memory limit

Provide the maximum amount of RAM PHPStan is allowed to allocate. You can either provide an explicit integer value in bytes or use a shorthand notation (500M, 4G, and so on).

PHPStan Dialog

The dialog opens when you click the Browse button next to the Configuration list on the PHPStan page.

Use this dialog to configure the used PHP interpreter, path to the PHPStan executable file, as well as PHPStan's behaviour. For more information, refer to PHPStan.

Item

Description

Interpreters pane

The left-hand pane of the dialog shows the default PHP interpreter to use the PHPStan from. To add a different interpreter, click the Add button and select an item from the list of CLI interpreters configured in the project.

PHPStan path

In this field, specify the location of the PHPStan script: phpstan.bat for Windows or phpstan for Linux and macOS.

PhpStorm detects the path to the PHPStan executable file in the vendor/bin folder and fills in the field automatically, but you can edit it if necessary. Type the path manually or click the Browse button and select the path in the dialog that opens.

To check that the specified path to phpstan.bat or phpstan ensures interaction between PhpStorm and PHPStan, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the phpstan --version command. If validation passes successfully, PhpStorm displays the information on the detected PHPStan version.

Tool process timeout

In this field, specify how long you want PhpStorm to wait for a result from PHPStan. If the timeout is exceeded, the process is terminated to prevent excessive CPU and memory usage. This lets you fine-tune the PHPStan process behavior depending on the configuration of your computer and the rule sets used.

External formatters

In this section, you can set up some of the code quality tools to be used as an external formatter during code reformatting.

Item

Description

External formatters

The following code quality tools can be used as external formatters:

  • PHP Code Beautifier and Fixer: select if the PHP_CodeSniffer and PHP Code Beautifier and Fixer tools are configured in the PHP_CodeSniffer section.

  • PHP CS Fixer: select if the PHP CS Fixer tool is configured in the PHP CS Fixer section.

  • Laravel Pint: select if the Laravel Pint tool is configured in the Laravel Pint section.

  • No External Formatter: select to use PhpStorm's built-in code formatting rules. The default option when several or none code quality tools are configured.

Last modified: 20 February 2024