Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Psalm flows for string functions #4576

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
146 changes: 146 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
{
}