From 09fe67f2e8b49029e2e48404d3f17930b8cf1a67 Mon Sep 17 00:00:00 2001 From: orklah Date: Tue, 23 Feb 2021 23:29:55 +0100 Subject: [PATCH] add some obvious cases and return when encountering an unhandled type --- src/Hooks/NotEmptyHooks.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Hooks/NotEmptyHooks.php b/src/Hooks/NotEmptyHooks.php index d5282f1..a110fe0 100644 --- a/src/Hooks/NotEmptyHooks.php +++ b/src/Hooks/NotEmptyHooks.php @@ -84,6 +84,15 @@ class NotEmptyHooks implements AfterExpressionAnalysisInterface $replacement[] = $display_expr . ' ' . $comparison_operator . ' ' . '[]'; } elseif ($atomic_type instanceof Atomic\TBool) { $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 { // object, named objects could be replaced by false(or true 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($type->getId()); } + return true; } if ($replacement !== []) {