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
Remove php version from composer.json
Can not set Language level to PHP 7.4 in PhpStorm - Stack Overflow
phpstorm - PHP Language level missing latest (version 7.3 is the highest) - Stack Overflow
Unexpected/Incorrect PHP Version when running unit tests
My version of PHPStorm is 2018.3.6
Upgrade your IDE to a newer version. PHP 7.4 support was added later (initial support in 2019.2 and proper one in 2019.3: https://www.jetbrains.com/phpstorm/whatsnew/2019-3/).
P.S. Latest PhpStorm is 2021.1.1 and it supports PHP 8.0
https://www.jetbrains.com/phpstorm/whatsnew/
You need to update to new version of PHP Storm.
The current version that I'm using is:
PhpStorm 2020.2 Build #PS-202.6397.115, built on July 29, 2020
and supports version 7.4 and latest 8.0 for PHP Language Level pack.
Hi, probably me doing something stupid but after much google-fu and delving in storm's preferences I still cannot crack it.
I am running a mac and use brew to install / switch between multiple PHP versions. In terminal I am running the expected PHP version (8.1):
$ which php
/opt/homebrew/opt/php/bin/php
$ /opt/homebrew/opt/php/bin/php -v
/opt/homPHP 8.1.7 (cli) (built: Jun 9 2022 14:08:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans
with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
In Preferences -> PHP
I have PHP language level set to 8.1 and CLI Interpreter to my 8.1 executable location (which shows the correct version and xdebug version).
However, when I run my unit tests it is using my php 7.4 version.
You should install php7.1 to your system first to be able to use it.
For ubuntu:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
For windows and other OS just google it (e.g. How can I install php on Windows).
Then you should say PHPUnit to use specific version of php, but it depends on how exactly you run tests.
See Run test in phpunit with specific php version or PHPUnit - This version of PHPUnit requires PHP 5.6; using the latest version of PHP is highly recommended - OSX 10.11
You should install PHP 7.1 if you using PhpUnit 7.1
Change this line
"php": ">=5.5.9"
To
"php": "^7.1"
After that execute composer update