Skip to content

Commit

Permalink
Add more Psalm flows for string functions (vimeo#4576)
Browse files Browse the repository at this point in the history
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 vimeo#3636
  • Loading branch information
LukasReschke committed Nov 17, 2020
1 parent 51f0096 commit e238947
Showing 1 changed file with 146 additions and 0 deletions.
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
{
}

0 comments on commit e238947

Please sign in to comment.