Skip to content

Commit e10a7aa

Browse files
authored
Cover non-empty-string in more string fuctions
1 parent b04e60a commit e10a7aa

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Type/Php/NonEmptyStringFunctionsReturnTypeExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class NonEmptyStringFunctionsReturnTypeExtension implements DynamicFunctionRetur
1717
public function isFunctionSupported(FunctionReflection $functionReflection): bool
1818
{
1919
return in_array($functionReflection->getName(), [
20+
'addslashes',
21+
'addcslashes',
22+
'escapeshellarg',
23+
'escapeshellcmd',
2024
'strtoupper',
2125
'strtolower',
2226
'mb_strtoupper',

tests/PHPStan/Analyser/data/non-empty-string.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ class MoreNonEmptyStringFunctions
305305
*/
306306
public function doFoo(string $s, string $nonEmpty, int $i)
307307
{
308+
assertType('string', addslashes($s));
309+
assertType('non-empty-string', addslashes($nonEmpty));
310+
assertType('string', addcslashes($s));
311+
assertType('non-empty-string', addcslashes($nonEmpty));
312+
313+
assertType('string', escapeshellarg($s));
314+
assertType('non-empty-string', escapeshellarg($nonEmpty));
315+
assertType('string', escapeshellcmd($s));
316+
assertType('non-empty-string', escapeshellcmd($nonEmpty));
317+
308318
assertType('string', strtoupper($s));
309319
assertType('non-empty-string', strtoupper($nonEmpty));
310320
assertType('string', strtolower($s));

0 commit comments

Comments
 (0)