Skip to content

Commit ff83f93

Browse files
committed
[PHP 8.5] ini_get("max_memory_limit") is a string
1 parent 2674c0f commit ff83f93

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ 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+
assertType('string|false', ini_get("max_memory_limit"));
2936
}

0 commit comments

Comments
 (0)