So, you mean to highlight all pieces of code that will not work with the PHP version you are writing it in, right? That can be done here:
Preferences -> Languages & Frameworks > PHP
and the same on Mac:
PhpStorm -> Preferences (⌘,) -> Languages & Frameworks > PHP
Or with newer versions of PhpStorm in Windows:
File -> Settings -> Languages & Frameworks > PHP

then select your PHP version, for example, 7.0
This is very useful when your local system runs PHP 7.0, for example, but production is running PHP 5.5.
That way PhpStorm will warn you which parts will not work in production, show proper hints during writing code according to the selected version, etc.
Answer from Alejandro Moreno on Stack OverflowSo, you mean to highlight all pieces of code that will not work with the PHP version you are writing it in, right? That can be done here:
Preferences -> Languages & Frameworks > PHP
and the same on Mac:
PhpStorm -> Preferences (⌘,) -> Languages & Frameworks > PHP
Or with newer versions of PhpStorm in Windows:
File -> Settings -> Languages & Frameworks > PHP

then select your PHP version, for example, 7.0
This is very useful when your local system runs PHP 7.0, for example, but production is running PHP 5.5.
That way PhpStorm will warn you which parts will not work in production, show proper hints during writing code according to the selected version, etc.
In case your field is disabled.
Probably your settings "Synchronize IDE settings with composer.json" is enabled
You may change your PHP version in composer.json file
"require": {
"php": ">=7.1.0",
}
OR disable your settings in this path
File -> Settings -> Languages & Frameworks > PHP > Composer
*If you change your composer.json file - As Félix Gagnon-Grenier commented, Keep in mind it has effects on the way packages will be required later
phpstorm - How to see the latest version of the package in package.json? - Stack Overflow
macos - Update PhpStorm to the latest version via JetBrains Toolbox, and know the CodeGeeX plugin generates an error - Stack Overflow
The latest PhpStorm update
PhpStorm 2018 - how to inspect whole project to php 7.2 compatibility? - Stack Overflow
Videos
Hey guys!
I am currently on PhpStorm 2024.1 - Build #PS-241.14494.237, built on March 27, 2024.
Before this version everything was running perfect.
Now, PhpStorm feels slow, sometimes unresponsive like 1-2 minutes. It's just real pain in the ass to work.
My question is... Is this only me?
You have two options here, which depend on each other.
Install PHP_CodeSniffer
To check your project for 7.2 compatibility I recommend the PHP CodeSniffer. This is a little yet powerful command line program which statically checks your code against predefined coding standards.
Install it via Composer from within your the root level of your project:
$ composer require --dev squizlabs/php_codesniffer
You can also install it globally or as a Phar. Please consult the documentation for alternate installation methods.
Once installed, you can call it via:
$ vendor/bin/phpcs --version // This outputs you the version
As mentioned above, PHPCS comes with ready to use coding standards. Use
$ vendor/bin/phpcs -i to list them.
To check if your code is PSR-2 compatible run:
$ vendor/bin/phpcs --standard=PSR2 .
As you like to check your project for PHP 7.2 compatibility, you have to install this standard: https://github.com/PHPCompatibility/PHPCompatibility
$ composer require --dev phpcompatibility/php-compatibility
Now register the standard in PHPCS. Open your composer.json and add this lines to the scripts section:
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
}
This will take care if you install/update your dependencies. To register the standard right now, you have to call the script manually:
$ composer run-script post-install-cmd
To check if the new standard is successfully installed run:
$ vendor/bin/phpcs -i
Now you are able to run the check from the cli:
$ vendor/bin/phpcs -p . --standard=PHPCompatibility
Configure PhpStorm to use PHP_CodeSniffer
As you already have configured the PHP Interpreter in PhpStorm, open your Preferences and to to PHP | Quality Tools | CodeSniffer. Click on the ... and type the path to your PHP_CodeSniffer installation. In our case vendor/bin/phpcs and hit Validate. It shows an tooltip with the current version.

Now click on OK.
Enable the Inspections
Inside the Preferences go to Editor | Inspections | PHP | Quality tools. Enable the PHP Code Sniffer validation checkbox. Then to the right you find the settings page. You have to select the PHPCompatibility standard from the select field and hit the reload button next to the select. Once done, click OK.
You should now see the errors inside the editor underlined. The severity and the color can be set in the configuration pane we just closed.

Conclusion
Now you have two ways to check your projects code. The CLI-way gives you a better overall overview about the state of your code where the IDE-way can help you while coding to be aware of not using old language constructs.
- Open "Settings"
- Search for "Languages & Frameworks"
- Under PHP, choose "Composer"
- Deslect "Synchronize IDE Settings with composer.json"
- Choose PHP
- Set "PHP language level" to 7.2
Enjoy :)
