Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"php": "^8.2",
"guzzlehttp/guzzle": "^7.8",
"justinrainbow/json-schema": "^5.2",
"justinrainbow/json-schema": "^5.2 || ^6.0",
"caseyamcl/guzzle_retry_middleware": "^2.9"
},
"require-dev": {
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ parameters:
- identifier: match.unhandled
path: src/Generated/V2/Schemas/Marketplace/*.php
- identifier: instanceof.alwaysTrue
path: src/Generated
path: src/Generated
# justinrainbow/json-schema 5.x has incorrect doc-comments on the Factory constructor
- identifier: argument.type
path: src/Validator/Validator.php
reportUnmatched: false
10 changes: 9 additions & 1 deletion src/Validator/SchemaStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@

namespace Mittwald\ApiClient\Validator;

use JsonSchema\Constraints\BaseConstraint;
use JsonSchema\SchemaStorageInterface;
use stdClass;

class SchemaStorage implements SchemaStorageInterface
{
private array $schemas = [];

/**
* @param mixed $schema Schema; may be passed as array, despite the interface docs
*/
public function addSchema($id, $schema = null): void
{
if (is_array($schema)) {
$schema = BaseConstraint::arrayToObjectRecursive($schema);
}

$this->schemas[$id] = $schema;
}

public function getSchema($id): object
public function getSchema($id): object|bool
{
return $this->schemas[$id];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Validator extends \JsonSchema\Validator
public function __construct()
{
$schemaStorage = new SchemaStorage();
$factory = new Factory($schemaStorage); // @phpstan-ignore argument.type (doc-comments are incorrect)
$factory = new Factory($schemaStorage);

parent::__construct($factory);
}
Expand Down
Loading