mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Remove training wheels
This commit is contained in:
parent
20791bfae6
commit
ae0ca9553f
@ -36,10 +36,7 @@ class ForeachChecker
|
||||
$foreach_context = clone $context;
|
||||
$foreach_context->inside_loop = true;
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$key_type = null;
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$value_type = null;
|
||||
|
||||
$var_id = ExpressionChecker::getVarId(
|
||||
|
@ -40,13 +40,10 @@ class SwitchChecker
|
||||
|
||||
$original_context = clone $context;
|
||||
|
||||
/** @var array<string,Type\Union>|null */
|
||||
$new_vars_in_scope = null;
|
||||
|
||||
/** @var array<string,bool> */
|
||||
$new_vars_possibly_in_scope = [];
|
||||
|
||||
/** @var array<string,Type\Union>|null */
|
||||
$redefined_vars = null;
|
||||
|
||||
// the last statement always breaks, by default
|
||||
|
@ -518,10 +518,7 @@ class CallChecker
|
||||
$first_arg_type = $stmt->args[0]->value->inferredType;
|
||||
|
||||
if ($first_arg_type->hasGeneric()) {
|
||||
/** @var Type\Union|null */
|
||||
$key_type = null;
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$value_type = null;
|
||||
|
||||
foreach ($first_arg_type->types as $type) {
|
||||
@ -660,7 +657,6 @@ class CallChecker
|
||||
$config = Config::getInstance();
|
||||
|
||||
if ($class_type && is_string($stmt->name)) {
|
||||
/** @var Type\Union|null */
|
||||
$return_type = null;
|
||||
|
||||
foreach ($class_type->types as $class_type_part) {
|
||||
@ -772,7 +768,6 @@ class CallChecker
|
||||
$class_template_params = [];
|
||||
|
||||
if ($class_type_part instanceof TGenericObject) {
|
||||
/** @var array<int, string> */
|
||||
$reversed_class_template_types = array_reverse(array_keys($class_storage->template_types));
|
||||
|
||||
$provided_type_param_count = count($class_type_part->type_params);
|
||||
|
@ -309,7 +309,6 @@ class FetchChecker
|
||||
if ($class_storage->template_types) {
|
||||
$class_template_params = [];
|
||||
|
||||
/** @var array<int, string> */
|
||||
$reversed_class_template_types = array_reverse(array_keys($class_storage->template_types));
|
||||
|
||||
$provided_type_param_count = count($lhs_type_part->type_params);
|
||||
@ -836,7 +835,6 @@ class FetchChecker
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$inferred_key_type = null;
|
||||
|
||||
if (isset($stmt->var->inferredType)) {
|
||||
|
@ -644,13 +644,10 @@ class ExpressionChecker
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$item_key_type = null;
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$item_value_type = null;
|
||||
|
||||
/** @var array<string,Type\Union> */
|
||||
$property_types = [];
|
||||
|
||||
$can_create_objectlike = true;
|
||||
@ -663,7 +660,6 @@ class ExpressionChecker
|
||||
|
||||
if (isset($item->key->inferredType)) {
|
||||
if ($item_key_type) {
|
||||
/** @var Type\Union */
|
||||
$item_key_type = Type::combineUnionTypes($item->key->inferredType, $item_key_type);
|
||||
} else {
|
||||
/** @var Type\Union */
|
||||
|
@ -96,7 +96,6 @@ class TypeChecker
|
||||
$right_clauses = [new Clause([], true)];
|
||||
}
|
||||
|
||||
/** @var array<string, array<string>> */
|
||||
$possibilities = [];
|
||||
|
||||
if ($left_clauses[0]->wedge && $right_clauses[0]->wedge) {
|
||||
@ -339,7 +338,6 @@ class TypeChecker
|
||||
*/
|
||||
public static function getTruthsFromFormula(array $clauses)
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
$truths = [];
|
||||
|
||||
if (empty($clauses)) {
|
||||
@ -1057,7 +1055,6 @@ class TypeChecker
|
||||
$new_base_key = $base_key . '->' . $key_parts[$i];
|
||||
|
||||
if (!isset($existing_keys[$new_base_key])) {
|
||||
/** @var null|Type\Union */
|
||||
$new_base_type = null;
|
||||
|
||||
foreach ($existing_keys[$base_key]->types as $existing_key_type_part) {
|
||||
@ -1138,7 +1135,6 @@ class TypeChecker
|
||||
$new_base_key = $base_key . '[' . $key_parts[$i] . ']';
|
||||
|
||||
if (!isset($existing_keys[$new_base_key])) {
|
||||
/** @var Type\Union|null */
|
||||
$new_base_type = null;
|
||||
|
||||
foreach ($existing_keys[$base_key]->types as $existing_key_type_part) {
|
||||
|
@ -20,7 +20,6 @@ class EffectsAnalyser
|
||||
*/
|
||||
public static function getReturnTypes(array $stmts, array &$yield_types, $collapse_types = false)
|
||||
{
|
||||
/** @var array<int, Type\Atomic> */
|
||||
$return_types = [];
|
||||
|
||||
$last_stmt = null;
|
||||
@ -82,10 +81,7 @@ class EffectsAnalyser
|
||||
if ($collapse_types) {
|
||||
// if it's a generator, boil everything down to a single generator return type
|
||||
if ($yield_types) {
|
||||
/** @var Type\Union */
|
||||
$key_type = null;
|
||||
|
||||
/** @var Type\Union|null */
|
||||
$value_type = null;
|
||||
|
||||
foreach ($yield_types as $type) {
|
||||
|
@ -489,10 +489,7 @@ abstract class Type
|
||||
throw new \InvalidArgumentException('You must pass at least one type to combineTypes');
|
||||
}
|
||||
|
||||
/** @var array<string, array<string, Union>> */
|
||||
$key_types = [];
|
||||
|
||||
/** @var array<string, array<string, Union|null>> */
|
||||
$value_types = [];
|
||||
|
||||
foreach ($types as $type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user