Skip to content

Commit 3e05142

Browse files
authored
[PHP 8.5] ini_get("max_memory_limit") is a string
1 parent 5f49473 commit 3e05142

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/Php/PhpVersions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ public function supportsTrueAndFalseStandaloneType(): TrinaryLogic
4848
return IntegerRangeType::fromInterval(80200, null)->isSuperTypeOf($this->phpVersions)->result;
4949
}
5050

51+
public function supportsMaxMemoryLimit(): TrinaryLogic
52+
{
53+
return IntegerRangeType::fromInterval(80500, null)->isSuperTypeOf($this->phpVersions)->result;
54+
}
55+
5156
}

src/Type/Php/IniGetReturnTypeExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public function getTypeFromFunctionCall(
4747
'precision' => $numericString,
4848
];
4949

50+
if ($scope->getPhpVersion()->supportsMaxMemoryLimit()->yes()) {
51+
$types['max_memory_limit'] = new StringType();
52+
}
53+
5054
$argType = $scope->getType($args[0]->value);
5155
$results = [];
5256
foreach ($argType->getConstantStrings() as $constantString) {

tests/PHPStan/Analyser/nsrt/ini-get.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@ function doFoo() {
2626
}
2727
assertType('string|false', ini_get($key));
2828
assertType('string|false', ini_get('unknown'));
29+
30+
if (PHP_VERSION_ID >= 80500) {
31+
assertType('string', ini_get("max_memory_limit"));
32+
} else {
33+
assertType('string|false', ini_get("max_memory_limit"));
34+
}
35+
if (PHP_VERSION_ID >= 80300) {
36+
assertType('string|false', ini_get("max_memory_limit"));
37+
}
38+
if (PHP_VERSION_ID < 80300) {
39+
assertType('string|false', ini_get("max_memory_limit"));
40+
}
2941
}

0 commit comments

Comments
 (0)