Skip to content

Commit

Permalink
Add string functions from sscanf to wordwrap
Browse files Browse the repository at this point in the history
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php

Continuation of vimeo#4576

Ref vimeo#3636
  • Loading branch information
LukasReschke committed Nov 17, 2020
1 parent 43af3b1 commit ad93170
Showing 1 changed file with 150 additions and 0 deletions.
150 changes: 150 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,27 @@ function strtolower(string $str) : string {}
*/
function strtoupper(string $str) : string {}

/**
* @psalm-pure
*
* @psalm-flow ($str, $to) -> return
*/
function strtr(string $str, string $from, string $to) : string {}

/**
* @psalm-pure
*
* @psalm-flow ($str, $replace_pairs) -> return
*/
function strtr(string $str, array $replace_pairs) : string {}

/**
* @psalm-pure
*
* @psalm-flow ($string, $replacement) -> return
*/
function substr_replace(mixed $string, mixed $replacement, mixed $start, ?mixed $length) : mixed

/**
* @psalm-pure
*
Expand Down Expand Up @@ -610,6 +631,20 @@ function array_product(array $input) {}
*/
function strip_tags(string $str, ?string $allowable_tags = null) : string {}

/**
* @psalm-pure
*
* @psalm-flow ($str) -> return
*/
function stripcslashes(string $str) : string {}

/**
* @psalm-pure
*
* @psalm-flow ($str) -> return
*/
function stripslashes(string $str) : string {}

/**
* @psalm-pure
*
Expand Down Expand Up @@ -661,6 +696,103 @@ function htmlspecialchars_decode(string $string, ?int $quote_style = null) : str
*/
function str_replace($search, $replace, $subject, &$count = null) {}

/**
* @psalm-pure
*
* @param string|array<string|int|float> $search
* @param string|array<string|int|float> $replace
* @param string|array<string|int|float> $subject
* @param int $count
* @return ($subject is array ? array<string> : string)
*
* @psalm-flow ($replace, $subject) -> return
*/
function str_ireplace($search, $replace, $subject, &$count = null) {}

/**
* @psalm-pure
*
* @psalm-flow ($input, $pad_string) -> return
*/
function str_pad(string $input, int $pad_length, $pad_string = '', int $pad_type = STR_PAD_RIGHT): string {}

/**
* @psalm-pure
*
* @psalm-flow ($input) -> return
*/
function str_repeat(string $input, int $multiplier): string {}

/**
* @psalm-pure
*
* @psalm-flow ($str) -> return
*/
function str_rot13(string $str): string {}

/**
* @psalm-pure
*
* @psalm-flow ($str) -> return
*/
function str_shuffle(string $str): string {}

/**
* @psalm-pure
*
* @psalm-flow ($string) -> return
*/
function str_split(string $string, int $split_length = 1): array {}

/**
* @psalm-pure
*
* @psalm-flow ($haystack, $needle) -> return
*/
function strstr(string $haystack, mixed $needle, bool $before_needle = false): array {}

/**
* @psalm-pure
*
* @psalm-flow ($haystack) -> return
*/
function stristr(string $haystack, mixed $needle, bool $before_needle = false): array {}

/**
* @psalm-pure
*
* @psalm-flow ($haystack) -> return
*/
function strchr(string $haystack, mixed $needle, bool $before_needle = false): array {}

/**
* @psalm-pure
*
* @psalm-flow ($haystack) -> return
*/
function strpbrk(string $haystack, string $char_list): string {}

/**
* @psalm-pure
*
* @psalm-flow ($haystack) -> return
*/
function strrchr(string $haystack, mixed $needle): string {}

/**
* @psalm-pure
*
* @psalm-flow ($string) -> return
*/
function strrev(string $string): string {}

/**
* @psalm-pure
*
* @psalm-flow ($string) -> return
*/
function strtok(string $str, string $token): string {}

/**
* @psalm-pure
*
Expand Down Expand Up @@ -748,6 +880,22 @@ function preg_quote(string $str, ?string $delimiter = null) : string {}
*/
function sprintf(string $format, ...$args) : string {}

/**
* @psalm-pure
* @return string|false
*
* @psalm-flow ($format, $args) -> return
*/
function vsprintf(string $format, array $args) {}

/**
* @psalm-pure
* @return string
*
* @psalm-flow ($str) -> return
*/
function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string {}

/**
* @psalm-pure
*
Expand Down Expand Up @@ -789,6 +937,8 @@ function strval ($var): string {}
/**
* @return ($input is non-empty-string ? non-empty-list<string> : non-empty-list<string>|array{null})
* @psalm-pure
*
* @psalm-flow ($input) -> return
*/
function str_getcsv(string $input, string $delimiter = ',', string $enclosure = '"', string $escape = '\\\\')
{
Expand Down

0 comments on commit ad93170

Please sign in to comment.