Skip to content

Commit

Permalink
Tweak the code to avoid fabbot false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 12, 2020
1 parent c571fa9 commit 88d1745
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions HttpClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ private static function jsonEncode($value, int $flags = null, int $maxDepth = 51
try {
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0), $maxDepth);
} catch (\JsonException $e) {
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
throw new InvalidArgumentException('Invalid value for "json" option: '.$e->getMessage());
}

if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error() && (false === $value || !($flags & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', json_last_error_msg()));
throw new InvalidArgumentException('Invalid value for "json" option: '.json_last_error_msg());
}

return $value;
Expand Down
4 changes: 2 additions & 2 deletions Response/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ public function toArray(bool $throw = true): array
try {
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
} catch (\JsonException $e) {
throw new JsonException(sprintf('%s for "%s".', $e->getMessage(), $this->getInfo('url')), $e->getCode());
throw new JsonException(sprintf($e->getMessage().' for "%s".', $this->getInfo('url')), $e->getCode());
}

if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error()) {
throw new JsonException(sprintf('%s for "%s".', json_last_error_msg(), $this->getInfo('url')), json_last_error());
throw new JsonException(sprintf(json_last_error_msg().' for "%s".', $this->getInfo('url')), json_last_error());
}

if (!\is_array($content)) {
Expand Down

0 comments on commit 88d1745

Please sign in to comment.