mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #4418 - improve try analysis for mixed, too
This commit is contained in:
parent
c16d779bca
commit
870d07ba51
@ -384,10 +384,6 @@ class TryAnalyzer
|
||||
$possibly_referenced_var_ids
|
||||
);
|
||||
|
||||
if ($codebase->find_unused_variables && $catch_actions[$i] !== [ScopeAnalyzer::ACTION_END]) {
|
||||
// something
|
||||
}
|
||||
|
||||
if ($catch_context->collect_exceptions) {
|
||||
$context->mergeExceptions($catch_context);
|
||||
}
|
||||
|
@ -445,10 +445,6 @@ abstract class Type
|
||||
$combined_type->initialized = false;
|
||||
}
|
||||
|
||||
if ($type_1->possibly_undefined_from_try || $type_2->possibly_undefined_from_try) {
|
||||
$combined_type->possibly_undefined_from_try = true;
|
||||
}
|
||||
|
||||
if ($type_1->from_docblock || $type_2->from_docblock) {
|
||||
$combined_type->from_docblock = true;
|
||||
}
|
||||
@ -482,6 +478,10 @@ abstract class Type
|
||||
$combined_type->possibly_undefined = true;
|
||||
}
|
||||
|
||||
if ($type_1->possibly_undefined_from_try || $type_2->possibly_undefined_from_try) {
|
||||
$combined_type->possibly_undefined_from_try = true;
|
||||
}
|
||||
|
||||
if ($type_1->parent_nodes || $type_2->parent_nodes) {
|
||||
$combined_type->parent_nodes = $type_1->parent_nodes + $type_2->parent_nodes;
|
||||
}
|
||||
|
@ -441,6 +441,30 @@ class TryCatchTest extends TestCase
|
||||
return $foo;
|
||||
}'
|
||||
],
|
||||
'mixedNotUndefinedAfterTry' => [
|
||||
'<?php
|
||||
/**
|
||||
* @return array<int, mixed>
|
||||
* @psalm-suppress MixedAssignment
|
||||
*/
|
||||
function fetchFromCache(mixed $m)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
try {
|
||||
$value = $m;
|
||||
} catch (Throwable $e) {
|
||||
$value = $m;
|
||||
}
|
||||
|
||||
$data[] = $value;
|
||||
|
||||
return $data;
|
||||
}',
|
||||
[],
|
||||
[],
|
||||
'8.0'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user