From a1fd92d9fd46d05de1e4614345d69c0acd30847c Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 16 Nov 2020 21:50:07 +0100 Subject: [PATCH] Add more Psalm flows for string functions (#4576) This adds string functions from https://www.php.net/manual/en/ref.strings.php This commit adds the flows for functions from "addcslashes" to "sprintf". More are to follow in later commits. Ref #3636 --- stubs/CoreGenericFunctions.phpstub | 146 +++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index 24c97376d..ca5e13ee0 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -443,6 +443,7 @@ function date(string $format, int $timestamp = 0) {} * * @param mixed $vars * @param-out string|int|float $vars + * @psalm-flow ($str, $format) -> return * @return (func_num_args() is 2 ? list : int) */ function sscanf(string $str, string $format, &...$vars) {} @@ -531,6 +532,26 @@ function rtrim(string $str, string $character_mask = " \t\n\r\0\x0B") : string { */ function implode($glue, array $pieces = []) : string {} +/** + * @psalm-pure + * + * @param string|array $glue + * + * @return ( + * $glue is non-empty-string + * ? ($pieces is non-empty-array + * ? non-empty-string + * : string) + * : string + * ) + * + * @psalm-flow ($glue) -> return + * @psalm-flow ($pieces) -(array-fetch)-> return + */ +function join($glue, array $pieces = []): string +{ +} + /** * @psalm-pure * @@ -727,6 +748,15 @@ function preg_quote(string $str, ?string $delimiter = null) : string {} */ function sprintf(string $format, ...$args) : string {} +/** + * @psalm-pure + * + * @param string|int|float $args + * + * @psalm-flow ($format, $values) -> return + */ +function printf(string $format, ...$values) : string {} + /** * @psalm-pure * @@ -779,3 +809,119 @@ function random_int(int $min, int $max): int {} * @psalm-pure */ function array_count_values(array $array): array {} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function addcslashes(string $str, string $charlist) : string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function addslashes(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function ucfirst(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str, $delimiters) -> return + */ +function ucwords (string $str, string $delimiters = " \t\r\n\f\v"): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function lcfirst(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function nl2br(string $str, bool $is_xhtml = false): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function quoted_printable_decode(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function quoted_printable_encode(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function quotemeta(string $str): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($str) -> return + */ +function chop(string $str, string $character_mask = " \t\n\r\0\x0B"): string +{ +} + +/** + * @psalm-pure + * @psalm-flow ($str, $end) -> return + */ +function chunk_split(string $str, int $chunklen = 76, string $end= ''): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($data) -> return + */ +function convert_uudecode(string $data): string +{ +} + +/** + * @psalm-pure + * + * @psalm-flow ($data) -> return + */ +function convert_uuencode(string $data) : string +{ +}