uuf6429 / jetbrains-php-version-switcher

PHP Version Switcher Plugin for PhpStorm/IDEA
MIT License
0 stars 0 forks source link

PHP Version Switcher Plugin

PhpStorm IDEA Ultimate Version Downloads License

This is an IDE plugin that switches the PHP Language Level automatically whenever an editor window is focused, based on the version defined in the nearest composer.json file (to the focused editor file).

That behaviour would be helpful if your project contains PHP code intended to run on different PHP versions (PhpStorm/IDEA) or if you are opening multiple projects as modules (IDEA).

https://github.com/user-attachments/assets/db36e668-5f40-4e8d-b69c-62a518c7223a

Caveat ingeniator

Directory-based Behaviour (at the moment)

You cannot have multiple PHP files with different language level in the same directory, since there can only be one composer.json per directory.

The composer.json Requirement

The PHP version is only switched when a composer.json file exists, containing a "php" entry in the "require" section. The "require-dev" section is currently ignored.

Conflicting Split Views

The language level is still a global setting. If you have a PHP-7.4 file open next to a PHP-5.6 file, and you focus the PHP-5.6 one, errors/warnings will probably show up in the PHP-7.4 file since it tries to apply the PHP version there.