File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ JSONPath for PHP 7.1+
33
44[ ![ Build Status] ( https://img.shields.io/github/workflow/status/SoftCreatR/JSONPath/Test/main?label=Build%20Status )] ( https://github.com/SoftCreatR/JSONPath/actions?query=workflow%3ATest )
55[ ![ Latest Release] ( https://img.shields.io/packagist/v/SoftCreatR/JSONPath?color=blue&label=Latest%20Release )] ( https://packagist.org/packages/softcreatr/jsonpath )
6- [ ![ MIT licensed] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( ./LICENSE.txt )
6+ [ ![ MIT licensed] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( ./LICENSE )
77[ ![ Codecov branch] ( https://img.shields.io/codecov/c/github/SoftCreatR/JSONPath/main )] ( https://codecov.io/gh/SoftCreatR/JSONPath/ )
88
99This is a [ JSONPath] ( http://goessner.net/articles/JsonPath/ ) implementation for PHP based on Stefan Goessner's JSONPath script.
Original file line number Diff line number Diff line change 99
1010namespace Flow \JSONPath \Filters ;
1111
12- use RuntimeException ;
1312use Flow \JSONPath \AccessHelper ;
13+ use RuntimeException ;
1414use function is_string ;
1515use function preg_match ;
1616use function preg_replace ;
1919class QueryMatchFilter extends AbstractFilter
2020{
2121 public const MATCH_QUERY_OPERATORS = '
22- @(\.(?<key>[^ =]+)|\[[" \']?(?<keySquare>.*?)[" \']?\])
22+ @(\.(?<key>[^\s<>! =]+)|\[[" \']?(?<keySquare>.*?)[" \']?\])
2323 (\s*(?<operator>==|=|<>|!==|!=|>=|<=|>|<|in|!in|nin)\s*(?<comparisonValue>.+))?
2424 ' ;
2525
@@ -29,8 +29,6 @@ class QueryMatchFilter extends AbstractFilter
2929 */
3030 public function filter ($ collection ): array
3131 {
32- $ return = [];
33-
3432 preg_match ('/^ ' . static ::MATCH_QUERY_OPERATORS . '$/x ' , $ this ->token ->value , $ matches );
3533
3634 if (!isset ($ matches [1 ])) {
@@ -67,6 +65,8 @@ public function filter($collection): array
6765 }
6866 }
6967
68+ $ return = [];
69+
7070 foreach ($ collection as $ value ) {
7171 if (AccessHelper::keyExists ($ value , $ key , $ this ->magicIsAllowed )) {
7272 $ value1 = AccessHelper::getValue ($ value , $ key , $ this ->magicIsAllowed );
You can’t perform that action at this time.
0 commit comments