mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Revert "Stub out str_replace types"
This reverts commit 94fefde3768701a6f83ca760711abdab6a62ba00.
This commit is contained in:
parent
649a33b27b
commit
6b25b33d81
@ -13,6 +13,9 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
|
||||
public static function getFunctionIds() : array
|
||||
{
|
||||
return [
|
||||
'str_replace',
|
||||
'str_ireplace',
|
||||
'substr_replace',
|
||||
'preg_replace',
|
||||
'preg_replace_callback',
|
||||
];
|
||||
@ -39,12 +42,14 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
|
||||
|
||||
$return_type = Type::getString();
|
||||
|
||||
$return_type->addType(new Type\Atomic\TNull());
|
||||
if (in_array($function_id, ['preg_replace', 'preg_replace_callback'], true)) {
|
||||
$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,41 +326,4 @@ 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…
x
Reference in New Issue
Block a user