mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Add better return type for preg_split
This commit is contained in:
parent
5743471a19
commit
f83b50460a
@ -602,6 +602,17 @@ function implode($glue, array $pieces = []) : string {}
|
||||
*/
|
||||
function explode(string $delimiter, string $string, int $limit = -1) : array {}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @psalm-flow ($subject) -(array-assignment)-> return
|
||||
*
|
||||
* @return ($flags is 1|3|5|7 ? list<string>|false : non-empty-list<string>|false)
|
||||
*
|
||||
* @psalm-ignore-falsable-return
|
||||
*/
|
||||
function preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0) {}
|
||||
|
||||
/**
|
||||
* @param array $input
|
||||
*
|
||||
|
@ -1355,6 +1355,13 @@ class FunctionCallTest extends TestCase
|
||||
[],
|
||||
'7.4'
|
||||
],
|
||||
'pregSplit' => [
|
||||
'<?php
|
||||
/** @return non-empty-list */
|
||||
function foo(string $s) {
|
||||
return preg_split("/ /", $s);
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -1856,6 +1863,14 @@ class FunctionCallTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'ArgumentTypeCoercion',
|
||||
],
|
||||
'pregSplitNoEmpty' => [
|
||||
'<?php
|
||||
/** @return non-empty-list */
|
||||
function foo(string $s) {
|
||||
return preg_split("/ /", $s, -1, PREG_SPLIT_NO_EMPTY);
|
||||
}',
|
||||
'error_message' => 'InvalidReturnStatement'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user