Skip to content

Commit d7d13a5

Browse files
authored
Fixed issue with false positive detection of valid json string (#209)
* Fixed false positive detection of valid json strings * CS Fixes * Added phive install step to github workflows
1 parent 48f1767 commit d7d13a5

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.github/workflows/mutation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ jobs:
3131
uses: "shivammathur/setup-php@v2"
3232
with:
3333
coverage: "pcov"
34+
tools: phive, composer:v2
3435
php-version: "${{ matrix.php-version }}"
3536
ini-values: memory_limit=-1
3637

38+
- name: "Install tools"
39+
run: "phive install --trust-gpg-keys E82B2FB314E9906E,CF1A108D0E7AE720,8A03EA3B385DBAA1,C5095986493B4AA0 --force-accept-unsigned"
40+
3741
- name: "Cache dependencies"
3842
uses: "actions/cache@v2"
3943
with:

.github/workflows/static-analyze.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ jobs:
3333
coverage: "pcov"
3434
php-version: "${{ matrix.php-version }}"
3535
ini-values: memory_limit=-1
36-
tools: composer:v2
36+
tools: phive, composer:v2
37+
38+
- name: "Install tools"
39+
run: "phive install --trust-gpg-keys E82B2FB314E9906E,CF1A108D0E7AE720,8A03EA3B385DBAA1,C5095986493B4AA0 --force-accept-unsigned"
3740

3841
- name: "Install lowest dependencies"
3942
if: ${{ matrix.dependencies == 'lowest' }}

.github/workflows/tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ jobs:
3737
coverage: "pcov"
3838
php-version: "${{ matrix.php-version }}"
3939
ini-values: memory_limit=-1
40-
tools: composer:v2
40+
tools: phive, composer:v2
41+
42+
- name: "Install tools"
43+
run: "phive install --trust-gpg-keys E82B2FB314E9906E,CF1A108D0E7AE720,8A03EA3B385DBAA1,C5095986493B4AA0 --force-accept-unsigned"
4144

4245
- name: "Install lowest dependencies"
4346
if: ${{ matrix.dependencies == 'lowest' }}

src/Matcher/Pattern/Assert/Json.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ public static function isValid($value) : bool
1818
return false;
1919
}
2020

21-
if (null === \json_decode($value) && JSON_ERROR_NONE !== \json_last_error()) {
21+
$result = \json_decode($value);
22+
23+
if (\is_float($result) && \is_infinite($result)) {
24+
return false;
25+
}
26+
27+
if (null === $result && JSON_ERROR_NONE !== \json_last_error()) {
2228
return false;
2329
}
2430

tests/Matcher/JsonMatcherTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public static function positiveMatches()
111111
'[{"name": "Norbert"},{"name":"Michał"},{"name":"Bob"},{"name":"Martin"}]',
112112
'"@array@.repeat({\"name\": \"@string@\"})"',
113113
],
114+
[
115+
'{"something": "5e61188283825"}',
116+
'{"something": "@string@"}',
117+
],
114118
];
115119
}
116120

0 commit comments

Comments
 (0)