@@ -152,22 +152,48 @@ public function filter(array|object $collection): array
152152 $ comparisonResult = null ;
153153
154154 if ($ notNothing ) {
155- $ comparisonResult = match ($ operator ) {
156- null => AccessHelper::keyExists ($ node , $ key , $ this ->magicIsAllowed ) || (!$ key ),
157- "= " , "== " => $ this ->compareEquals ($ selectedNode , $ comparisonValue ),
158- "!= " , "!== " , "<> " => !$ this ->compareEquals ($ selectedNode , $ comparisonValue ),
159- '=~ ' => @\preg_match ($ comparisonValue , $ selectedNode ),
160- '< ' => $ this ->compareLessThan ($ selectedNode , $ comparisonValue ),
161- '<= ' => $ this ->compareLessThan ($ selectedNode , $ comparisonValue )
162- || $ this ->compareEquals ($ selectedNode , $ comparisonValue ),
163- '> ' => $ this ->compareLessThan ($ comparisonValue , $ selectedNode ), //rfc semantics
164- '>= ' => $ this ->compareLessThan ($ comparisonValue , $ selectedNode ) //rfc semantics
165- || $ this ->compareEquals ($ selectedNode , $ comparisonValue ),
166- "in " => \is_array ($ comparisonValue ) && \in_array ($ selectedNode , $ comparisonValue , true ),
167- 'nin ' , "!in " => \is_array ($ comparisonValue )
168- && !\in_array ($ selectedNode , $ comparisonValue , true ),
169- default => false ,
170- };
155+ $ comparisonResult = false ;
156+
157+ switch ($ operator ) {
158+ case null :
159+ $ comparisonResult = AccessHelper::keyExists ($ node , $ key , $ this ->magicIsAllowed ) || (!$ key );
160+ break ;
161+ case "= " :
162+ case "== " :
163+ $ comparisonResult = $ this ->compareEquals ($ selectedNode , $ comparisonValue );
164+ break ;
165+ case "!= " :
166+ case "!== " :
167+ case "<> " :
168+ $ comparisonResult = !$ this ->compareEquals ($ selectedNode , $ comparisonValue );
169+ break ;
170+ case '=~ ' :
171+ $ comparisonResult = @\preg_match ($ comparisonValue , $ selectedNode );
172+ break ;
173+ case '< ' :
174+ $ comparisonResult = $ this ->compareLessThan ($ selectedNode , $ comparisonValue );
175+ break ;
176+ case '<= ' :
177+ $ comparisonResult = $ this ->compareLessThan ($ selectedNode , $ comparisonValue )
178+ || $ this ->compareEquals ($ selectedNode , $ comparisonValue );
179+ break ;
180+ case '> ' :
181+ $ comparisonResult = $ this ->compareLessThan ($ comparisonValue , $ selectedNode ); //rfc semantics
182+ break ;
183+ case '>= ' :
184+ $ comparisonResult = $ this ->compareLessThan ($ comparisonValue , $ selectedNode ) //rfc semantics
185+ || $ this ->compareEquals ($ selectedNode , $ comparisonValue );
186+ break ;
187+ case "in " :
188+ $ comparisonResult = \is_array ($ comparisonValue )
189+ && \in_array ($ selectedNode , $ comparisonValue , true );
190+ break ;
191+ case 'nin ' :
192+ case "!in " :
193+ $ comparisonResult = \is_array ($ comparisonValue )
194+ && !\in_array ($ selectedNode , $ comparisonValue , true );
195+ break ;
196+ }
171197 }
172198
173199 if ($ negateFilter ) {
0 commit comments