diff --git a/src/Php/PhpVersions.php b/src/Php/PhpVersions.php index cc2ea94c98..993ee23acf 100644 --- a/src/Php/PhpVersions.php +++ b/src/Php/PhpVersions.php @@ -48,4 +48,9 @@ public function supportsTrueAndFalseStandaloneType(): TrinaryLogic return IntegerRangeType::fromInterval(80200, null)->isSuperTypeOf($this->phpVersions)->result; } + public function supportsMaxMemoryLimit(): TrinaryLogic + { + return IntegerRangeType::fromInterval(80500, null)->isSuperTypeOf($this->phpVersions)->result; + } + } diff --git a/src/Type/Php/IniGetReturnTypeExtension.php b/src/Type/Php/IniGetReturnTypeExtension.php index 21aab0b82f..60795cd7af 100644 --- a/src/Type/Php/IniGetReturnTypeExtension.php +++ b/src/Type/Php/IniGetReturnTypeExtension.php @@ -47,6 +47,10 @@ public function getTypeFromFunctionCall( 'precision' => $numericString, ]; + if ($scope->getPhpVersion()->supportsMaxMemoryLimit()->yes()) { + $types['max_memory_limit'] = new StringType(); + } + $argType = $scope->getType($args[0]->value); $results = []; foreach ($argType->getConstantStrings() as $constantString) { diff --git a/tests/PHPStan/Analyser/nsrt/ini-get.php b/tests/PHPStan/Analyser/nsrt/ini-get.php index 6751b3cc16..c11655be35 100644 --- a/tests/PHPStan/Analyser/nsrt/ini-get.php +++ b/tests/PHPStan/Analyser/nsrt/ini-get.php @@ -26,4 +26,16 @@ function doFoo() { } assertType('string|false', ini_get($key)); assertType('string|false', ini_get('unknown')); + + if (PHP_VERSION_ID >= 80500) { + assertType('string', ini_get("max_memory_limit")); + } else { + assertType('string|false', ini_get("max_memory_limit")); + } + if (PHP_VERSION_ID >= 80300) { + assertType('string|false', ini_get("max_memory_limit")); + } + if (PHP_VERSION_ID < 80300) { + assertType('string|false', ini_get("max_memory_limit")); + } }