mirror of
https://github.com/halaxa/json-machine.git
synced 2025-01-17 13:08:16 +01:00
Removed deprecated Decoder interface
This commit is contained in:
parent
5738c463f6
commit
e7cdefd2ef
@ -4,6 +4,7 @@
|
||||
### Removed
|
||||
- Removed deprecated functions `objects()` and `httpClientChunks()`.
|
||||
- Removed deprecated `JsonMachine` entrypoint class.
|
||||
- Removed deprecated `Decoder` interface.
|
||||
|
||||
### Changed
|
||||
- Default decoding structure of `Parser` is object. (You don't notice unless you use `Parser` class directly)
|
||||
@ -14,6 +15,7 @@
|
||||
## 0.8.0
|
||||
### Changed
|
||||
- Internal decoders moved to `ItemDecoder`. `ErrorWrappingDecoder` decorator now requires `ItemDecoder` as well.
|
||||
- Dropped PHP 5.6 support.
|
||||
|
||||
### Deprecated
|
||||
- `JsonMachine\JsonMachine` entry point class is deprecated, use `JsonMachine\Items` instead.
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace JsonMachine\JsonDecoder;
|
||||
|
||||
@trigger_error(sprintf(
|
||||
'Interface %s is deprecated. Use %s instead.',
|
||||
Decoder::class,
|
||||
ItemDecoder::class
|
||||
), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated Use ItemDecoder instead.
|
||||
*/
|
||||
interface Decoder
|
||||
{
|
||||
/**
|
||||
* @param string $jsonScalarKey
|
||||
* @return DecodingResult
|
||||
*/
|
||||
public function decodeKey($jsonScalarKey);
|
||||
|
||||
/**
|
||||
* @param string $jsonValue
|
||||
* @return DecodingResult
|
||||
*/
|
||||
public function decodeValue($jsonValue);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace JsonMachine\JsonDecoder;
|
||||
|
||||
@trigger_error(sprintf(
|
||||
'Class %s is deprecated. Use one of %s, %s or %s instead.',
|
||||
DecodingResult::class,
|
||||
ValidResult::class,
|
||||
ValidStringResult::class,
|
||||
InvalidResult::class
|
||||
), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class DecodingResult
|
||||
{
|
||||
private $isOk;
|
||||
private $value;
|
||||
private $errorMessage;
|
||||
|
||||
/**
|
||||
* DecodingResult constructor.
|
||||
* @param bool $isOk
|
||||
* @param mixed $value
|
||||
* @param string $errorMessage
|
||||
*/
|
||||
public function __construct($isOk, $value, $errorMessage = null)
|
||||
{
|
||||
$this->isOk = $isOk;
|
||||
$this->value = $value;
|
||||
$this->errorMessage = $errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return bool
|
||||
*/
|
||||
public function isOk()
|
||||
{
|
||||
return $this->isOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string|null
|
||||
*/
|
||||
public function getErrorMessage()
|
||||
{
|
||||
return $this->errorMessage;
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace JsonMachine\JsonDecoder;
|
||||
class ErrorWrappingDecoder implements ItemDecoder
|
||||
{
|
||||
/**
|
||||
* @var Decoder
|
||||
* @var ItemDecoder
|
||||
*/
|
||||
private $innerDecoder;
|
||||
|
||||
|
@ -8,7 +8,6 @@ use JsonMachine\Exception\PathNotFoundException;
|
||||
use JsonMachine\Exception\SyntaxError;
|
||||
use JsonMachine\Exception\UnexpectedEndSyntaxErrorException;
|
||||
use JsonMachine\JsonDecoder\ItemDecoder;
|
||||
use JsonMachine\JsonDecoder\Decoder;
|
||||
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
||||
use Traversable;
|
||||
|
||||
@ -39,15 +38,15 @@ class Parser implements \IteratorAggregate, PositionAware
|
||||
/** @var string */
|
||||
private $jsonPointer;
|
||||
|
||||
/** @var Decoder|ItemDecoder */
|
||||
/** @var ItemDecoder */
|
||||
private $jsonDecoder;
|
||||
|
||||
/**
|
||||
* @param Traversable $lexer
|
||||
* @param string $jsonPointer Follows json pointer RFC https://tools.ietf.org/html/rfc6901
|
||||
* @param Decoder|ItemDecoder $jsonDecoder
|
||||
* @param ItemDecoder $jsonDecoder
|
||||
*/
|
||||
public function __construct(Traversable $lexer, $jsonPointer = '', $jsonDecoder = null)
|
||||
public function __construct(Traversable $lexer, $jsonPointer = '', ItemDecoder $jsonDecoder = null)
|
||||
{
|
||||
if (0 === preg_match('_^(/(([^/~])|(~[01]))*)*$_', $jsonPointer, $matches)) {
|
||||
throw new InvalidArgumentException(
|
||||
@ -153,11 +152,7 @@ class Parser implements \IteratorAggregate, PositionAware
|
||||
$key = $token;
|
||||
} elseif ($currentLevel < $iteratorLevel) {
|
||||
$key = $token;
|
||||
if ($this->jsonDecoder instanceof ItemDecoder) {
|
||||
$keyResult = $this->jsonDecoder->decodeInternalKey($token);
|
||||
} elseif ($this->jsonDecoder instanceof Decoder) {
|
||||
$keyResult = $this->jsonDecoder->decodeKey($token);
|
||||
}
|
||||
$keyResult = $this->jsonDecoder->decodeInternalKey($token);
|
||||
if (! $keyResult->isOk()) {
|
||||
$this->error($keyResult->getErrorMessage(), $token);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user