mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-06-10 18:35:25 +02:00
Use closure for error handling
This commit is contained in:
@ -6,6 +6,7 @@ use Cerbero\JsonParser\Decoders\ArrayDecoder;
|
||||
use Cerbero\JsonParser\Decoders\DecodedValue;
|
||||
use Cerbero\JsonParser\Decoders\Decoder;
|
||||
use Cerbero\JsonParser\Pointers\Pointer;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* The configuration.
|
||||
@ -37,9 +38,9 @@ class Config
|
||||
/**
|
||||
* The callback to run during a parsing error.
|
||||
*
|
||||
* @var callable
|
||||
* @var Closure
|
||||
*/
|
||||
public callable $onError;
|
||||
public Closure $onError;
|
||||
|
||||
/**
|
||||
* Instantiate the class
|
||||
|
@ -6,6 +6,7 @@ use Cerbero\JsonParser\Decoders\Decoder;
|
||||
use Cerbero\JsonParser\Decoders\ObjectDecoder;
|
||||
use Cerbero\JsonParser\Pointers\Pointer;
|
||||
use Cerbero\JsonParser\Sources\AnySource;
|
||||
use Closure;
|
||||
use IteratorAggregate;
|
||||
use Traversable;
|
||||
|
||||
@ -114,10 +115,10 @@ class JsonParser implements IteratorAggregate
|
||||
/**
|
||||
* Set the logic to run during parsing errors
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param Closure $callback
|
||||
* @return static
|
||||
*/
|
||||
public function onError(callable $callback): static
|
||||
public function onError(Closure $callback): static
|
||||
{
|
||||
$this->config->onError = $callback;
|
||||
|
||||
|
Reference in New Issue
Block a user