diff --git a/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php b/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php index 4a88a6616f0..f1d3e7fdf0b 100644 --- a/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php +++ b/src/Type/Php/TrimFunctionDynamicReturnTypeExtension.php @@ -71,7 +71,7 @@ public function getTypeFromFunctionCall( if (count($stringConstantStrings) > 0) { foreach ($stringConstantStrings as $stringConstantString) { $result[] = new ConstantStringType( - $functionName === 'rtrim' + in_array($functionName, ['rtrim', 'chop'], true) ? rtrim($stringConstantString->getValue(), $trimConstantString->getValue()) : trim($stringConstantString->getValue(), $trimConstantString->getValue()), true, diff --git a/tests/PHPStan/Analyser/nsrt/bug-15684.php b/tests/PHPStan/Analyser/nsrt/bug-15684.php new file mode 100644 index 00000000000..6ebb65d56f7 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug-15684.php @@ -0,0 +1,13 @@ +