1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Improve signature of FunctionReturnTypeProvider to omit internal things

This commit is contained in:
Matthew Brown 2019-02-16 15:29:54 -05:00
parent fa362b04cb
commit 2ef82d785f
19 changed files with 126 additions and 101 deletions

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
class FunctionReturnTypeProvider
@ -15,7 +15,7 @@ class FunctionReturnTypeProvider
* @var array<
* string,
* \Closure(
* StatementsAnalyzer,
* StatementsSource,
* string,
* array<PhpParser\Node\Arg>,
* Context,
@ -55,9 +55,9 @@ class FunctionReturnTypeProvider
{
if (version_compare(PHP_VERSION, '7.1.0') >= 0) {
/** @psalm-suppress UndefinedMethod */
$callable = \Closure::fromCallable([$class, 'get']);
$callable = \Closure::fromCallable([$class, 'getFunctionReturnType']);
} else {
$callable = (new \ReflectionClass($class))->getMethod('get')->getClosure(new $class);
$callable = (new \ReflectionClass($class))->getMethod('getFunctionReturnType')->getClosure(new $class);
}
foreach ($class::getFunctionIds() as $function_id) {
@ -66,6 +66,15 @@ class FunctionReturnTypeProvider
}
/**
* /**
* @param \Closure(
* StatementsSource,
* string,
* array<PhpParser\Node\Arg>,
* Context,
* CodeLocation
* ) : Type\Union $c
*
* @return void
*/
public function registerClosure(string $function_id, \Closure $c)
@ -82,14 +91,14 @@ class FunctionReturnTypeProvider
* @param array<PhpParser\Node\Arg> $call_args
*/
public function getReturnType(
StatementsAnalyzer $statements_analyzer,
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
CodeLocation $code_location
) : Type\Union {
return self::$handlers[strtolower($function_id)](
$statements_analyzer,
$statements_source,
$function_id,
$call_args,
$context,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class MethodReturnTypeProvider
{
@ -14,7 +14,7 @@ class MethodReturnTypeProvider
* @var array<
* string,
* \Closure(
* StatementsAnalyzer,
* StatementsSource,
* string,
* string,
* string,
@ -32,6 +32,16 @@ class MethodReturnTypeProvider
}
/**
* @param \Closure(
* StatementsSource,
* string,
* string,
* string,
* array<PhpParser\Node\Arg>,
* Context,
* CodeLocation
* ) : Type\Union $c
*
* @return void
*/
public function registerClosure(string $method_id, \Closure $c)
@ -48,7 +58,7 @@ class MethodReturnTypeProvider
* @param array<PhpParser\Node\Arg> $call_args
*/
public function getReturnType(
StatementsAnalyzer $statements_analyzer,
StatementsSource $statements_source,
string $method_id,
string $appearing_method_id,
string $declaring_method_id,
@ -57,7 +67,7 @@ class MethodReturnTypeProvider
CodeLocation $code_location
) : Type\Union {
return self::$handlers[strtolower($method_id)](
$statements_analyzer,
$statements_source,
$method_id,
$appearing_method_id,
$declaring_method_id,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Codebase\CallMap;
class ArrayColumnReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
@ -19,8 +19,8 @@ class ArrayColumnReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -7,7 +7,7 @@ use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\IssueBuffer;
use Psalm\Issue\InvalidReturnType;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\Statements\Expression\AssertionFinder;
use Psalm\Type;
use Psalm\Type\Reconciler;
@ -22,8 +22,8 @@ class ArrayFilterReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -71,7 +71,7 @@ class ArrayFilterReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
'No return type could be found in the closure passed to array_filter',
$code_location
),
$statements_analyzer->getSuppressedIssues()
$statements_source->getSuppressedIssues()
);
return Type::getArray();
@ -87,24 +87,26 @@ class ArrayFilterReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
&& $stmt instanceof PhpParser\Node\Stmt\Return_
&& $stmt->expr
) {
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
AssertionFinder::scrapeAssertions($stmt->expr, null, $statements_analyzer, $codebase);
AssertionFinder::scrapeAssertions($stmt->expr, null, $statements_source, $codebase);
$assertions = isset($stmt->expr->assertions) ? $stmt->expr->assertions : null;
if (isset($assertions['$' . $first_param->var->name])) {
$changed_var_ids = [];
assert($statements_source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer);
$reconciled_types = Reconciler::reconcileKeyedTypes(
['$inner_type' => $assertions['$' . $first_param->var->name]],
['$inner_type' => $inner_type],
$changed_var_ids,
['$inner_type' => true],
$statements_analyzer,
$statements_source,
[],
false,
new CodeLocation($statements_analyzer->getSource(), $stmt)
new CodeLocation($statements_source, $stmt)
);
if (isset($reconciled_types['$inner_type'])) {

View File

@ -5,7 +5,7 @@ namespace Psalm\Internal\Provider\ReturnTypeProvider;
use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\Statements\Expression\CallAnalyzer;
use Psalm\Internal\Codebase\CallMap;
use Psalm\Type;
@ -23,8 +23,8 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
* @param CodeLocation $code_location
* @param array $suppressed_issues
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -109,7 +109,7 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
|| $function_call_arg->value instanceof PhpParser\Node\Expr\BinaryOp\Concat
) {
$mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg(
$statements_analyzer,
$statements_source,
$function_call_arg->value
);
@ -117,7 +117,7 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
$mapping_return_type = null;
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
foreach ($mapping_function_ids as $mapping_function_id) {
$mapping_function_id = strtolower($mapping_function_id);
@ -159,7 +159,7 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
$mapping_function_id_part,
$context->calling_method_id,
new CodeLocation(
$statements_analyzer->getSource(),
$statements_source,
$function_call_arg->value
)
)) {
@ -184,10 +184,12 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
$mapping_return_type = $return_type;
}
} else {
if (!$codebase->functions->functionExists(
$statements_analyzer,
$mapping_function_id_part
)) {
if (!$statements_source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer
|| !$codebase->functions->functionExists(
$statements_source,
$mapping_function_id_part
)
) {
$mapping_return_type = Type::getMixed();
continue;
}
@ -195,7 +197,7 @@ class ArrayMapReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
$part_match_found = true;
$function_storage = $codebase->functions->getStorage(
$statements_analyzer,
$statements_source,
$mapping_function_id_part
);

View File

@ -7,7 +7,7 @@ use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Type\TypeCombination;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class ArrayMergeReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -19,8 +19,8 @@ class ArrayMergeReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class ArrayPointerAdjustmentReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -18,8 +18,8 @@ class ArrayPointerAdjustmentReturnTypeProvider implements \Psalm\Plugin\Hook\Fun
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -48,7 +48,7 @@ class ArrayPointerAdjustmentReturnTypeProvider implements \Psalm\Plugin\Hook\Fun
$value_type->addType(new Type\Atomic\TFalse);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_falsable_issues) {
$value_type->ignore_falsable_issues = true;

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class ArrayPopReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -18,8 +18,8 @@ class ArrayPopReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -63,7 +63,7 @@ class ArrayPopReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
if ($nullable) {
$value_type->addType(new Type\Atomic\TNull);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_nullable_issues) {
$value_type->ignore_nullable_issues = true;

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class ArrayRandReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -18,8 +18,8 @@ class ArrayRandReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTy
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\Statements\Expression\CallAnalyzer;
use Psalm\Internal\Analyzer\TypeAnalyzer;
use Psalm\Internal\Codebase\CallMap;
@ -23,8 +23,8 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -34,7 +34,7 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
return Type::getMixed();
}
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
$array_arg = $call_args[0]->value;
$function_call_arg = $call_args[1]->value;
@ -94,9 +94,9 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
if (IssueBuffer::accepts(
new InvalidArgument(
'The closure passed to array_reduce needs two params',
new CodeLocation($statements_analyzer->getSource(), $function_call_arg)
new CodeLocation($statements_source, $function_call_arg)
),
$statements_analyzer->getSuppressedIssues()
$statements_source->getSuppressedIssues()
)) {
// fall through
}
@ -126,9 +126,9 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
'The first param of the closure passed to array_reduce must take '
. $reduce_return_type . ' but only accepts ' . $carry_param->type,
$carry_param->type_location
?: new CodeLocation($statements_analyzer->getSource(), $function_call_arg)
?: new CodeLocation($statements_source, $function_call_arg)
),
$statements_analyzer->getSuppressedIssues()
$statements_source->getSuppressedIssues()
)) {
// fall through
}
@ -150,9 +150,9 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
'The second param of the closure passed to array_reduce must take '
. $array_arg_type->type_params[1] . ' but only accepts ' . $item_param->type,
$item_param->type_location
?: new CodeLocation($statements_analyzer->getSource(), $function_call_arg)
?: new CodeLocation($statements_source, $function_call_arg)
),
$statements_analyzer->getSuppressedIssues()
$statements_source->getSuppressedIssues()
)) {
// fall through
}
@ -169,7 +169,7 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
|| $function_call_arg instanceof PhpParser\Node\Expr\BinaryOp\Concat
) {
$mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg(
$statements_analyzer,
$statements_source,
$function_call_arg
);
@ -207,7 +207,7 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
$mapping_function_id_part,
$context->calling_method_id,
new CodeLocation(
$statements_analyzer->getSource(),
$statements_source,
$function_call_arg
)
)) {
@ -228,17 +228,19 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturn
$return_type
);
} else {
if (!$codebase->functions->functionExists(
$statements_analyzer,
$mapping_function_id_part
)) {
if (!$statements_source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer
|| !$codebase->functions->functionExists(
$statements_source,
$mapping_function_id_part
)
) {
return Type::getMixed();
}
$part_match_found = true;
$function_storage = $codebase->functions->getStorage(
$statements_analyzer,
$statements_source,
$mapping_function_id_part
);

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class ArraySliceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -18,8 +18,8 @@ class ArraySliceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
class FilterVarReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
{
@ -18,8 +18,8 @@ class FilterVarReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTy
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -7,7 +7,7 @@ use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Type\TypeCombination;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\Statements\Block\ForeachAnalyzer;
use Psalm\Internal\Analyzer\TypeAnalyzer;
use Psalm\Internal\Codebase\CallMap;
@ -24,8 +24,8 @@ class IteratorToArrayReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionRe
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -37,7 +37,7 @@ class IteratorToArrayReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionRe
$key_type = null;
$value_type = null;
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
foreach ($call_args[0]->value->inferredType->getTypes() as $call_arg_atomic_type) {
if ($call_arg_atomic_type instanceof Type\Atomic\TNamedObject
@ -47,9 +47,11 @@ class IteratorToArrayReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionRe
new Type\Atomic\TIterable([Type::getMixed(), Type::getMixed()])
)
) {
assert($statements_source instanceof \Psalm\Internal\Analyzer\StatementsAnalyzer);
$has_valid_iterator = true;
ForeachAnalyzer::handleIterable(
$statements_analyzer,
$statements_source,
$call_arg_atomic_type,
$call_args[0]->value,
$codebase,

View File

@ -6,7 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\TypeAnalyzer;
class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
@ -19,8 +19,8 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -31,7 +31,7 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
$component_type = $call_args[1]->value->inferredType;
if (!$component_type->hasMixed()) {
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
$acceptable_string_component_type = new Type\Union([
new Type\Atomic\TLiteralInt(PHP_URL_SCHEME),
@ -57,7 +57,7 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
new Type\Atomic\TNull
]);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_nullable_issues) {
$nullable_string->ignore_nullable_issues = true;
@ -76,7 +76,7 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
new Type\Atomic\TNull
]);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_nullable_issues) {
$nullable_int->ignore_nullable_issues = true;
@ -93,7 +93,7 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
new Type\Atomic\TNull
]);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_nullable_issues) {
$nullable_string_or_int->ignore_nullable_issues = true;
@ -118,7 +118,7 @@ class ParseUrlReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
new Type\Atomic\TFalse
]);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_falsable_issues) {
$nullable_string_or_int->ignore_falsable_issues = true;

View File

@ -7,7 +7,7 @@ use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Type\TypeCombination;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\TypeAnalyzer;
class RangeReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
@ -20,8 +20,8 @@ class RangeReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypePr
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -7,7 +7,7 @@ use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Type\TypeCombination;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\TypeAnalyzer;
class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
@ -26,8 +26,8 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -45,7 +45,7 @@ class StrReplaceReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnT
if (in_array($function_id, ['preg_replace', 'preg_replace_callback'], true)) {
$return_type->addType(new Type\Atomic\TNull());
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if ($codebase->config->ignore_internal_nullable_issues) {
$return_type->ignore_nullable_issues = true;

View File

@ -7,7 +7,7 @@ use Psalm\Context;
use Psalm\CodeLocation;
use Psalm\Type;
use Psalm\Internal\Type\TypeCombination;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\StatementsSource;
use Psalm\Internal\Analyzer\TypeAnalyzer;
class VersionCompareReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface
@ -20,8 +20,8 @@ class VersionCompareReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionRet
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,
@ -49,7 +49,7 @@ class VersionCompareReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionRet
new Type\Atomic\TLiteralString('ne'),
]);
$codebase = $statements_analyzer->getCodebase();
$codebase = $statements_source->getCodebase();
if (TypeAnalyzer::isContainedBy(
$codebase,

View File

@ -6,8 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Codebase\CallMap;
use Psalm\StatementsSource;
interface FunctionReturnTypeProviderInterface
{
@ -19,8 +18,8 @@ interface FunctionReturnTypeProviderInterface
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_source,
string $function_id,
array $call_args,
Context $context,

View File

@ -6,8 +6,7 @@ use PhpParser;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Type;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Codebase\CallMap;
use Psalm\StatementsSource;
interface MethodReturnTypeProviderInterface
{
@ -19,8 +18,8 @@ interface MethodReturnTypeProviderInterface
/**
* @param array<PhpParser\Node\Arg> $call_args
*/
public static function get(
StatementsAnalyzer $statements_analyzer,
public static function getFunctionReturnType(
StatementsSource $statements_srouce,
string $method_id,
string $appearing_method_id,
string $declaring_method_id,