Skip to content

Commit d4798fb

Browse files
jrfnlgrogy
authored andcommitted
README: document inline minimum version definition option
To be honest, I never realized this was possible until I looked at the code in more detail, so I have a feeling that this feature is barely known. This feature has been in the codebase since 2014 (b0b05d2), so let's document this option to raise awareness.
1 parent 10c5512 commit d4798fb

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Diff for: README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ The application is officially supported for use with PHP 5.3 to 8.1.
1919
3. [History](#history)
2020
4. [Command line options](#command-line-options)
2121
5. [Recommended excludes for Symfony framework](#recommended-excludes-for-symfony-framework)
22-
6. [How to upgrade](#how-to-upgrade)
22+
6. [Excluding files from a scan based on the PHP version used](#excluding-files-from-a-scan-based-on-the-PHP version-used)
23+
7. [How to upgrade](#how-to-upgrade)
2324

2425
## Installation
2526

@@ -35,7 +36,7 @@ Alternatively you can install as a standalone `composer` project:
3536
For colored output, install the suggested package `php-parallel-lint/php-console-highlighter`:
3637

3738
composer require --dev php-parallel-lint/php-console-highlighter
38-
39+
3940
Since v1.3.0, a PHAR file is also made available for each release.
4041
This PHAR file is published as an asset for each release and can be found on the [Releases](https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases) page.
4142

@@ -94,6 +95,24 @@ To run from the command line:
9495
vendor/bin/parallel-lint --exclude .git --exclude app --exclude vendor .
9596

9697

98+
## Excluding files from a scan based on the PHP version used
99+
100+
Sometimes a particular file in a project may not comply with the project-wide minimum PHP version, like a file which is conditionally included in the project and contains PHP syntax which needs a higher PHP version to run.
101+
102+
This can make it complicated to run Parallel Lint in a CI context, as the `exclude`s used in the command would have to be adjusted based on the PHP version on which the scan is being run.
103+
104+
PHP Parallel Lint offers a straight-forward way around this, as files can define their own minimum PHP version like so:
105+
```php
106+
<?php // lint >= 7.4
107+
108+
// Code which contains PHP 7.4 syntax.
109+
```
110+
111+
With this comment in place, the file will be automatically skipped when PHP Parallel Lint is run on a PHP version lower than PHP 7.4.
112+
113+
Note: The `// lint >= 7.4` comment has to be only the first line of the file and must directly follow the PHP open tag.
114+
115+
97116
## How to upgrade
98117

99118
Are you using `jakub-onderka/php-parallel-lint` package? You can switch to `php-parallel-lint/php-parallel-lint` using:

0 commit comments

Comments
 (0)