diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index f35470d63cb..329d7def1b4 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -39,6 +39,7 @@ 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 @@ private static function reconcileHasMethod( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? new Union([new TEmptyMixed()]) + : Type::getNever(); } /** @@ -899,7 +902,7 @@ private static function reconcileString( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; return $existing_var_type->from_docblock - ? Type::getMixed() + ? new Union([new TEmptyMixed()]) : Type::getNever(); } @@ -995,7 +998,7 @@ private static function reconcileInt( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; return $existing_var_type->from_docblock - ? Type::getMixed() + ? new Union([new TEmptyMixed()]) : Type::getNever(); } @@ -1471,7 +1474,9 @@ private static function reconcileCountable( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1532,7 +1537,9 @@ private static function reconcileIterable( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1574,7 +1581,9 @@ private static function reconcileInArray( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } return $intersection; @@ -2325,7 +2334,9 @@ private static function reconcileCallable( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -2544,7 +2555,7 @@ private static function reconcileClassConstant( if ($matched_class_constant_types === []) { $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return Type::getNever(); } return TypeCombiner::combine($matched_class_constant_types, $codebase); diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index 6e32b7a3f57..68b45b1f9b9 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -494,7 +494,9 @@ private static function reconcileBool( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -636,7 +638,9 @@ private static function reconcileNull( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -704,7 +708,9 @@ private static function reconcileFalse( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -758,7 +764,9 @@ private static function reconcileFalsyOrEmpty( $failed_reconciliation = 2; - return Type::getNever(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } if (!$did_remove_type) { @@ -974,7 +982,9 @@ private static function reconcileScalar( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1077,7 +1087,9 @@ private static function reconcileObject( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1169,7 +1181,9 @@ private static function reconcileNumeric( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1271,7 +1285,9 @@ private static function reconcileInt( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1368,7 +1384,9 @@ private static function reconcileFloat( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1474,7 +1492,9 @@ private static function reconcileString( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1577,7 +1597,9 @@ private static function reconcileArray( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /** @@ -1645,7 +1667,9 @@ private static function reconcileResource( $failed_reconciliation = Reconciler::RECONCILIATION_EMPTY; - return Type::getMixed(); + return $existing_var_type->from_docblock + ? Type::getMixed() + : Type::getNever(); } /**