mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-16 20:48:15 +01:00
Improve static analysis
This commit is contained in:
parent
fbafffaa3c
commit
3bc9eab5b0
@ -1,16 +0,0 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Generator expects key type int\\|string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Parser.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$json of method Cerbero\\\\JsonParser\\\\Decoders\\\\ConfigurableDecoder\\:\\:decode\\(\\) expects string, int\\|string given\\.$#"
|
||||
count: 1
|
||||
path: src/Parser.php
|
||||
|
||||
-
|
||||
message: "#^Binary operation \"\\+\" between int\\|string and 1 results in an error\\.$#"
|
||||
count: 1
|
||||
path: src/Tree.php
|
@ -20,14 +20,14 @@ final class ConfigurableDecoder
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the given JSON.
|
||||
* Decode the given value.
|
||||
*
|
||||
* @param string $json
|
||||
* @param string|int $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function decode(string $json): mixed
|
||||
public function decode(string|int $value): mixed
|
||||
{
|
||||
$decoded = $this->config->decoder->decode($json);
|
||||
$decoded = $this->config->decoder->decode((string) $value);
|
||||
|
||||
if (!$decoded->succeeded) {
|
||||
call_user_func($this->config->onError, $decoded);
|
||||
|
@ -68,6 +68,7 @@ final class Parser implements IteratorAggregate
|
||||
}
|
||||
|
||||
if ($this->state->hasBuffer()) {
|
||||
/** @var string|int $key */
|
||||
$key = $this->decoder->decode($this->state->key());
|
||||
$value = $this->decoder->decode($this->state->value());
|
||||
|
||||
|
@ -115,7 +115,9 @@ final class Tree
|
||||
public function traverseArray(array $referenceTokens): void
|
||||
{
|
||||
$referenceToken = $referenceTokens[$this->depth] ?? null;
|
||||
$this->original[$this->depth] = isset($this->original[$this->depth]) ? $this->original[$this->depth] + 1 : 0;
|
||||
$index = $this->original[$this->depth] ?? null;
|
||||
|
||||
$this->original[$this->depth] = is_int($index) ? $index + 1 : 0;
|
||||
$this->wildcarded[$this->depth] = $referenceToken == '-' ? '-' : $this->original[$this->depth];
|
||||
|
||||
$this->trim();
|
||||
|
Loading…
x
Reference in New Issue
Block a user