@@ -20,7 +20,7 @@ class QueryMatchFilter extends AbstractFilter
2020 protected const MATCH_QUERY_NEGATION_WRAPPED = '^(?<negate>!)\((?<logicalexpr>.+)\)$ ' ;
2121 protected const MATCH_QUERY_NEGATION_UNWRAPPED = '^(?<negate>!)(?<logicalexpr>.+)$ ' ;
2222 protected const MATCH_QUERY_OPERATORS = '
23- @( \.(?<key>[^\s<>!=]+)|\[[" \']?(?<keySquare>.*?)[" \']?\])
23+ (@ \.(?<key>[^\s<>!=]+)|@ \[[" \']?(?<keySquare>.*?)[" \']?\]|(?<node>@) )
2424 (\s*(?<operator>==|=~|=|<>|!==|!=|>=|<=|>|<|in|!in|nin)\s*(?<comparisonValue>.+?(?=(&&|$))))?
2525 (\s*(?<logicaland>&&)\s*)?
2626 ' ;
@@ -60,9 +60,9 @@ public function filter($collection): array
6060 for ($ logicalAndNum = 0 ; $ logicalAndNum < \count ($ matches [0 ]); $ logicalAndNum ++) {
6161 $ key = $ matches ['key ' ][$ logicalAndNum ] ?: $ matches ['keySquare ' ][$ logicalAndNum ];
6262
63- if ($ key === '' ) {
64- throw new RuntimeException ('Malformed filter query: key was not set ' );
65- }
63+ // if ($key === '') {
64+ // throw new RuntimeException('Malformed filter query: key was not set');
65+ // }
6666
6767 $ operator = $ matches ['operator ' ][$ logicalAndNum ] ?? null ;
6868 $ comparisonValue = $ matches ['comparisonValue ' ][$ logicalAndNum ] ?? null ;
@@ -87,14 +87,19 @@ public function filter($collection): array
8787 $ value1 = null ;
8888
8989 $ notNothing = AccessHelper::keyExists ($ value , $ key , $ this ->magicIsAllowed );
90- if ($ notNothing ) {
91- $ value1 = AccessHelper::getValue ($ value , $ key , $ this ->magicIsAllowed );
92- } elseif (\str_contains ($ key , '. ' )) {
93- $ foundValue = (new JSONPath ($ value ))->find ($ key )->getData ();
94- if ($ foundValue ) {
95- $ value1 = $ foundValue [0 ];
96- $ notNothing = true ;
90+ if ($ key ) {
91+ if ($ notNothing ) {
92+ $ value1 = AccessHelper::getValue ($ value , $ key , $ this ->magicIsAllowed );
93+ } elseif (\str_contains ($ key , '. ' )) {
94+ $ foundValue = (new JSONPath ($ value ))->find ($ key )->getData ();
95+ if ($ foundValue ) {
96+ $ value1 = $ foundValue [0 ];
97+ $ notNothing = true ;
98+ }
9799 }
100+ } else {
101+ $ value1 = $ value ;
102+ $ notNothing = true ;
98103 }
99104
100105 $ comparisonResult = null ;
0 commit comments