Skip to content

Commit a30b210

Browse files
committed
Fixed MATCH_QUERY_OPERATORS
1 parent 5f9b2c9 commit a30b210

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

99
This is a [JSONPath](http://goessner.net/articles/JsonPath/) implementation for PHP based on Stefan Goessner's JSONPath script.

src/Filters/QueryMatchFilter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
namespace Flow\JSONPath\Filters;
1111

12-
use RuntimeException;
1312
use Flow\JSONPath\AccessHelper;
13+
use RuntimeException;
1414
use function is_string;
1515
use function preg_match;
1616
use function preg_replace;
@@ -19,7 +19,7 @@
1919
class 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);

0 commit comments

Comments
 (0)