Skip to content

Commit cb13116

Browse files
committed
fix compatibility with php 7.2
1 parent ebe8cdb commit cb13116

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.github/workflows/static-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
run: |
3535
sed -i ':a;$!N;1,12ba;P;$d;D' phpstan.neon
3636
37+
- name: Ignore error in PHP 7.2
38+
if: ${{ matrix.php == '7.2' }}
39+
run: |
40+
echo " - '#Constant JSON_THROW_ON_ERROR not found#'" >> phpstan.neon
41+
3742
- name: Run PHPStan
3843
run: |
3944
php vendor/bin/phpstan.phar --version

src/Body/RequestBody.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public function toArray(): ?array
3131
}
3232

3333
try {
34-
$content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
34+
if (\PHP_VERSION_ID >= 70300) {
35+
$content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
36+
} else {
37+
$content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING);
38+
}
3539
} catch (\JsonException $ex) {
3640
return null;
3741
}

0 commit comments

Comments
 (0)