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

empty reconciliation should return never or mixed depending of the source of the type

This commit is contained in:
orklah 2022-02-13 19:17:08 +01:00
parent 59d3d2aa31
commit cf25363fa1
2 changed files with 55 additions and 20 deletions

View File

@ -39,6 +39,7 @@ use Psalm\Type\Atomic\TCallableObject;
use Psalm\Type\Atomic\TCallableString;
use Psalm\Type\Atomic\TClassConstant;
use Psalm\Type\Atomic\TClassString;
use Psalm\Type\Atomic\TEmptyMixed;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TGenericObject;
use Psalm\Type\Atomic\TInt;
@ -806,7 +807,9 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? new Union([new TEmptyMixed()])
: Type::getNever();
}
/**
@ -899,7 +902,7 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return $existing_var_type->from_docblock
? Type::getMixed()
? new Union([new TEmptyMixed()])
: Type::getNever();
}
@ -995,7 +998,7 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return $existing_var_type->from_docblock
? Type::getMixed()
? new Union([new TEmptyMixed()])
: Type::getNever();
}
@ -1471,7 +1474,9 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1532,7 +1537,9 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1574,7 +1581,9 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
return $intersection;
@ -2325,7 +2334,9 @@ class SimpleAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -2544,7 +2555,7 @@ class SimpleAssertionReconciler extends Reconciler
if ($matched_class_constant_types === []) {
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return Type::getNever();
}
return TypeCombiner::combine($matched_class_constant_types, $codebase);

View File

@ -494,7 +494,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -636,7 +638,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -704,7 +708,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -758,7 +764,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = 2;
return Type::getNever();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
if (!$did_remove_type) {
@ -974,7 +982,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1077,7 +1087,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1169,7 +1181,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1271,7 +1285,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1368,7 +1384,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1474,7 +1492,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1577,7 +1597,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**
@ -1645,7 +1667,9 @@ class SimpleNegatedAssertionReconciler extends Reconciler
$failed_reconciliation = Reconciler::RECONCILIATION_EMPTY;
return Type::getMixed();
return $existing_var_type->from_docblock
? Type::getMixed()
: Type::getNever();
}
/**