Skip to content

Commit

Permalink
added config parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Mar 13, 2024
1 parent 28d2eb4 commit 8c64205
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
3 changes: 3 additions & 0 deletions conf/bleedingEdge.neon
@@ -1,4 +1,7 @@
parameters:
minPhpVersion: 70100
maxPhpVersion: 80399

featureToggles:
bleedingEdge: true
skipCheckGenericClasses!: []
Expand Down
4 changes: 4 additions & 0 deletions conf/config.neon
Expand Up @@ -136,6 +136,8 @@ parameters:
minimumNumberOfJobsPerProcess: 2
buffer: 134217728 # 128 MB
phpVersion: null
minPhpVersion: null
maxPhpVersion: null
polluteScopeWithLoopInitialAssignments: true
polluteScopeWithAlwaysIterableForeach: true
propertyAlwaysWrittenTags: []
Expand Down Expand Up @@ -380,6 +382,8 @@ services:
class: PHPStan\Php\ComposerPhpVersionFactory
arguments:
composerAutoloaderProjectPaths: %composerAutoloaderProjectPaths%
minVersion: %minPhpVersion%
maxVersion: %maxPhpVersion%

-
class: PHPStan\PhpDocParser\Lexer\Lexer
Expand Down
2 changes: 2 additions & 0 deletions conf/parametersSchema.neon
Expand Up @@ -131,6 +131,8 @@ parametersSchema:
buffer: int()
])
phpVersion: schema(anyOf(schema(int(), min(70100), max(80399))), nullable())
minPhpVersion: schema(anyOf(schema(int(), min(70100), max(80399))), nullable())
maxPhpVersion: schema(anyOf(schema(int(), min(70100), max(80399))), nullable())
polluteScopeWithLoopInitialAssignments: bool()
polluteScopeWithAlwaysIterableForeach: bool()
propertyAlwaysWrittenTags: listOf(string())
Expand Down
23 changes: 21 additions & 2 deletions src/Php/ComposerPhpVersionFactory.php
Expand Up @@ -26,10 +26,23 @@ class ComposerPhpVersionFactory
*/
public function __construct(
private array $composerAutoloaderProjectPaths,
?int $minVersion,
?int $maxVersion,
)
{
$composerPhpVersion = $this->getComposerRequireVersion();
if ($maxVersion !== null) {
$this->minVersion = new PhpVersion($minVersion);

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.1)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 34 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.
}

Check failure on line 35 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 35 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.
if ($minVersion !== null) {
$this->maxVersion = new PhpVersion($maxVersion);

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.1)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 37 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.
}

Check failure on line 38 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 38 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

if ($minVersion !== null && $maxVersion !== null) {
return; // use hardcoded values from config files

Check failure on line 41 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 41 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.
}

// fallback to composer.json based php-version constraint

Check failure on line 44 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, ubuntu-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.

Check failure on line 44 in src/Php/ComposerPhpVersionFactory.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.3, windows-latest)

Parameter #1 $versionId of class PHPStan\Php\PhpVersion constructor expects int, int|null given.
$composerPhpVersion = $this->getComposerRequireVersion();
if ($composerPhpVersion === null) {
$this->minVersion = null;
$this->maxVersion = null;
Expand All @@ -39,7 +52,13 @@ public function __construct(
$parser = new VersionParser();
$constraint = $parser->parseConstraints($composerPhpVersion);

$this->minVersion = $this->buildVersion($constraint->getLowerBound()->getVersion());
if ($this->minVersion === null) {
$this->minVersion = $this->buildVersion($constraint->getLowerBound()->getVersion());
}
if ($this->maxVersion !== null) {
return;
}

$this->maxVersion = $this->buildVersion($constraint->getUpperBound()->getVersion());
}

Expand Down

0 comments on commit 8c64205

Please sign in to comment.