1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

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
This commit is contained in:
Lukas Reschke 2020-11-16 21:50:07 +01:00 committed by Daniil Gentili
parent 4e7bd1e39b
commit a1fd92d9fd
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -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<float|int|string> : 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
{
}