mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Stub out str_replace types
This commit is contained in:
parent
b73b75f1a1
commit
94fefde376
@ -13,9 +13,6 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
|
||||
public static function getFunctionIds() : array
|
||||
{
|
||||
return [
|
||||
'str_replace',
|
||||
'str_ireplace',
|
||||
'substr_replace',
|
||||
'preg_replace',
|
||||
'preg_replace_callback',
|
||||
];
|
||||
@ -42,14 +39,12 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
|
||||
|
||||
$return_type = Type::getString();
|
||||
|
||||
if (in_array($function_id, ['preg_replace', 'preg_replace_callback'], true)) {
|
||||
$return_type->addType(new Type\Atomic\TNull());
|
||||
$return_type->addType(new Type\Atomic\TNull());
|
||||
|
||||
$codebase = $statements_source->getCodebase();
|
||||
$codebase = $statements_source->getCodebase();
|
||||
|
||||
if ($codebase->config->ignore_internal_nullable_issues) {
|
||||
$return_type->ignore_nullable_issues = true;
|
||||
}
|
||||
if ($codebase->config->ignore_internal_nullable_issues) {
|
||||
$return_type->ignore_nullable_issues = true;
|
||||
}
|
||||
|
||||
return $return_type;
|
||||
|
@ -326,4 +326,41 @@ function fclose(&$handle) : bool
|
||||
*/
|
||||
function sodium_memzero(string &$reference): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|string[] $search
|
||||
* @param string|string[] $replace
|
||||
* @param string|string[] $subject
|
||||
*
|
||||
* @psalm-return (
|
||||
* $subject is string
|
||||
* ? string
|
||||
* : string[]
|
||||
* )
|
||||
*/
|
||||
function str_replace($search, $replace, $subject, int &$replace_count = 0) {}
|
||||
|
||||
/**
|
||||
* @param string|string[] $search
|
||||
* @param string|string[] $replace
|
||||
* @param string|string[] $subject
|
||||
*
|
||||
* @psalm-return (
|
||||
* $subject is string
|
||||
* ? string
|
||||
* : string[]
|
||||
* )
|
||||
*/
|
||||
function str_ireplace($search, $replace, $subject, int &$replace_count = 0) {}
|
||||
|
||||
/**
|
||||
* @param string|string[] $subject
|
||||
*
|
||||
* @psalm-return (
|
||||
* $subject is string
|
||||
* ? string
|
||||
* : string[]
|
||||
* )
|
||||
*/
|
||||
function substr_replace ($subject, string $replacement, int $start, ?int $length = null) {}
|
||||
|
Loading…
Reference in New Issue
Block a user