Skip to content

Commit 904ff28

Browse files
committed
Utilize composer min-php version to narrow PHP_VERSION_ID
1 parent 11998ed commit 904ff28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+460
-19
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,35 @@ jobs:
292292
- script: |
293293
cd e2e/bug-11819
294294
../../bin/phpstan
295+
- script: |
296+
cd e2e/composer-max-version
297+
composer install
298+
../../bin/phpstan analyze test.php --level=0
299+
- script: |
300+
cd e2e/composer-min-max-version
301+
composer install
302+
../../bin/phpstan analyze test.php --level=0
303+
- script: |
304+
cd e2e/composer-min-open-end-version
305+
composer install
306+
../../bin/phpstan analyze test.php --level=0
307+
- script: |
308+
cd e2e/composer-min-version-bc
309+
composer install
310+
../../bin/phpstan analyze test.php --level=0
311+
- script: |
312+
cd e2e/composer-min-version
313+
composer install
314+
../../bin/phpstan analyze test.php --level=0
315+
- script: |
316+
cd e2e/composer-version-config
317+
composer install
318+
../../bin/phpstan analyze test.php --level=0
319+
- script: |
320+
cd e2e/composer-version-config-invalid
321+
OUTPUT=$(../../bin/phpstan 2>&1 || true)
322+
grep 'Invalid configuration' <<< "$OUTPUT"
323+
grep 'Invalid PHP version range: phpVersion.max should be greater or equal to phpVersion.min.' <<< "$OUTPUT"
295324
296325
steps:
297326
- name: "Checkout"

conf/config.neon

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,16 @@ services:
339339
-
340340
class: PHPStan\Php\PhpVersionFactoryFactory
341341
arguments:
342-
versionId: %phpVersion%
342+
phpVersion: %phpVersion%
343343
composerAutoloaderProjectPaths: %composerAutoloaderProjectPaths%
344+
bleedingEdge: %featureToggles.bleedingEdge%
345+
346+
-
347+
class: PHPStan\Php\ComposerPhpVersionFactory
348+
arguments:
349+
phpVersion: %phpVersion%
350+
composerAutoloaderProjectPaths: %composerAutoloaderProjectPaths%
351+
bleedingEdge: %featureToggles.bleedingEdge%
344352

345353
-
346354
class: PHPStan\PhpDocParser\ParserConfig

conf/parametersSchema.neon

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ parametersSchema:
7979
minimumNumberOfJobsPerProcess: int(),
8080
buffer: int()
8181
])
82-
phpVersion: schema(anyOf(schema(int(), min(70100), max(80499))), nullable())
82+
phpVersion: schema(anyOf(
83+
schema(int(), min(70100), max(80499)),
84+
structure([
85+
min: schema(int(), min(70100), max(80499)),
86+
max: schema(int(), min(70100), max(80499))
87+
])
88+
), nullable())
8389
polluteScopeWithLoopInitialAssignments: bool()
8490
polluteScopeWithAlwaysIterableForeach: bool()
8591
polluteScopeWithBlock: bool()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"php": "<=8.3"
4+
}
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
includes:
2+
- ../../conf/bleedingEdge.neon

e2e/composer-max-version/test.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
\PHPStan\Testing\assertType('int<50207, 80300>', PHP_VERSION_ID);
4+
\PHPStan\Testing\assertType('int<5, 8>', PHP_MAJOR_VERSION);
5+
\PHPStan\Testing\assertType('int<0, max>', PHP_MINOR_VERSION);
6+
\PHPStan\Testing\assertType('int<0, max>', PHP_RELEASE_VERSION);
7+
8+
\PHPStan\Testing\assertType('-1|0|1', version_compare(PHP_VERSION, '7.0.0'));
9+
\PHPStan\Testing\assertType('bool', version_compare(PHP_VERSION, '7.0.0', '<'));
10+
\PHPStan\Testing\assertType('bool', version_compare(PHP_VERSION, '7.0.0', '>'));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
composer.lock
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"php": ">=8.1, <=8.2.99"
4+
}
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
includes:
2+
- ../../conf/bleedingEdge.neon

0 commit comments

Comments
 (0)