mirror of
https://github.com/danog/psalm-not-empty.git
synced 2024-11-30 04:29:13 +01:00
add some obvious cases and return when encountering an unhandled type
This commit is contained in:
parent
f41818eedf
commit
09fe67f2e8
@ -84,6 +84,15 @@ class NotEmptyHooks implements AfterExpressionAnalysisInterface
|
|||||||
$replacement[] = $display_expr . ' ' . $comparison_operator . ' ' . '[]';
|
$replacement[] = $display_expr . ' ' . $comparison_operator . ' ' . '[]';
|
||||||
} elseif ($atomic_type instanceof Atomic\TBool) {
|
} elseif ($atomic_type instanceof Atomic\TBool) {
|
||||||
$replacement[] = $display_expr . ' ' . $comparison_operator . ' ' . 'false';
|
$replacement[] = $display_expr . ' ' . $comparison_operator . ' ' . 'false';
|
||||||
|
} elseif ($atomic_type instanceof Atomic\TObject || $atomic_type instanceof Atomic\TNamedObject) {
|
||||||
|
if($comparison_operator === '==='){
|
||||||
|
$replacement[] = 'false';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$replacement[] = 'true';
|
||||||
|
}
|
||||||
|
} elseif ($atomic_type instanceof Atomic\TNull) {
|
||||||
|
$replacement[] = 'true';
|
||||||
} else {
|
} else {
|
||||||
// object, named objects could be replaced by false(or true if !empty)
|
// object, named objects could be replaced by false(or true if !empty)
|
||||||
// null could be replace by true (or false if !empty)
|
// null could be replace by true (or false if !empty)
|
||||||
@ -91,6 +100,7 @@ class NotEmptyHooks implements AfterExpressionAnalysisInterface
|
|||||||
var_dump(get_class($atomic_type));
|
var_dump(get_class($atomic_type));
|
||||||
var_dump($type->getId());
|
var_dump($type->getId());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($replacement !== []) {
|
if ($replacement !== []) {
|
||||||
|
Loading…
Reference in New Issue
Block a user