add some obvious cases and return when encountering an unhandled type

This commit is contained in:
orklah 2021-02-23 23:29:55 +01:00
parent f41818eedf
commit 09fe67f2e8

View File

@ -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 !== []) {