1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\Php;
4:
5: use PHPStan\TrinaryLogic;
6: use PHPStan\Type\IntegerRangeType;
7: use PHPStan\Type\Type;
8:
9: /**
10: * Range-aware PHP version check that handles version uncertainty.
11: *
12: * Unlike PhpVersion (which represents a single known version), PhpVersions wraps
13: * a Type representing the possible PHP versions. When the exact version is known,
14: * queries return Yes/No. When a range of versions is possible, queries return Maybe.
15: *
16: * This is the return type of Scope::getPhpVersion().
17: *
18: * @api
19: */
20: final class PhpVersions
21: {
22:
23: public function __construct(
24: private Type $phpVersions,
25: )
26: {
27: }
28:
29: public function getType(): Type
30: {
31: return $this->phpVersions;
32: }
33:
34: public function supportsNoncapturingCatches(): TrinaryLogic
35: {
36: return IntegerRangeType::fromInterval(80000, null)->isSuperTypeOf($this->phpVersions)->result;
37: }
38:
39: public function producesWarningForFinalPrivateMethods(): TrinaryLogic
40: {
41: return IntegerRangeType::fromInterval(80000, null)->isSuperTypeOf($this->phpVersions)->result;
42: }
43:
44: public function supportsNamedArguments(): TrinaryLogic
45: {
46: return IntegerRangeType::fromInterval(80000, null)->isSuperTypeOf($this->phpVersions)->result;
47: }
48:
49: public function supportsNamedArgumentAfterUnpackedArgument(): TrinaryLogic
50: {
51: return IntegerRangeType::fromInterval(80100, null)->isSuperTypeOf($this->phpVersions)->result;
52: }
53:
54: public function supportsTrueAndFalseStandaloneType(): TrinaryLogic
55: {
56: return IntegerRangeType::fromInterval(80200, null)->isSuperTypeOf($this->phpVersions)->result;
57: }
58:
59: public function supportsMaxMemoryLimit(): TrinaryLogic
60: {
61: return IntegerRangeType::fromInterval(80500, null)->isSuperTypeOf($this->phpVersions)->result;
62: }
63:
64: }
65: