Closed mimmi20 closed 2 years ago
@mimmi20, I have no relevant experience with PHP, but I think the short answer is no. Most likely, your best bet would be to disable phplint, and run it outside of MegaLinter. You can achieve that by adding the following to your MegaLinter config:
DISABLE_LINTERS:
- PHP_PHPLINT
MegaLinter v6 will be released soon, but most likely without support for running phplint on PHP 8 unfortunately. My understanding is that there were some issues that are making upgrading difficult right now, although @llaville may correct me if I misunderstood.
@Kurt-von-Laven I'm away from my Laptop, but yes there is a solution to switch PHP version runtime used. I'll give the solution when I'll be back in few hours
@Kurt-von-Laven and @mimmi20 PHP switch capability was introduced in MegaLinter since version 5.3 with https://github.com/megalinter/megalinter/pull/1083
All you have to do is to use the PRE_COMMAND syntax on PHP_PHPLINT like that :
Remember that in MegaLinter v5.x, default PHP BUILTIN linter version is PHP 7 (7.4.x)
PHP_PHPLINT_PRE_COMMANDS:
- command: "update-alternatives --set php /usr/bin/php8"
cwd: root
NOTE: PHPLint 3.0 is compatible PHP 7.4 and 8.0 (until we use composer built-in with a PHP 7 version)
You should see in MegaLinter logs something like
[Pre][PHP_PHPLINT] run: [update-alternatives --set php /usr/bin/php8] in cwd [/]
[Pre][PHP_PHPLINT] [update-alternatives: using /usr/bin/php8 to provide /usr/bin/php (php) in manual mode
] update-alternatives: using /usr/bin/php8 to provide /usr/bin/php (php) in manual mode
### Processed [PHP] files
- Using [phplint v3.0] https://megalinter.github.io/v5/descriptors/php_phplint
- MegaLinter key: [PHP_PHPLINT]
- Rules config: [.phplint.yml]
- Number of files analyzed: [39]
✅ Linted [PHP] files with [phplint] successfully - (0.22s)
@llaville Does this switch also exists for all other php related linters? As you may see in my sample, the PHP_BUILTIN
linter has the same issue.
yes it exist for all PHP linters
I have decided to not change my config file, to disable the php checks for megalinter and run these checks in seperate tasks.
I am started using the megalinter when upgrading my projects to PHP 8.1.
In one project I got this error:
The linter uses PHP 7.4, but the code is written for PHP 8.1.
Is there any option to define the PHP version used by the linter?