diff --git a/composer.json b/composer.json
index cd9552e..7401906 100644
--- a/composer.json
+++ b/composer.json
@@ -3,6 +3,7 @@
"description": "A Symfony bundle for knplabs/php-json-schema",
"type": "library",
"license": "MIT",
+ "minimum-stability": "dev",
"autoload": {
"psr-4": {
"Knp\\JsonSchemaBundle\\": "src/"
@@ -16,10 +17,13 @@
],
"require": {
"php": ">=8.0",
- "knplabs/php-json-schema": ">=0.0.3",
+ "knplabs/php-json-schema": ">=0.0.4",
"zircote/swagger-php": ">=4.4",
"symfony/http-kernel": ">=6.0",
"symfony/dependency-injection": ">=6.0",
"symfony/config": ">=6.0"
+ },
+ "require-dev": {
+ "vimeo/psalm": "5.x-dev"
}
}
diff --git a/psalm.xml b/psalm.xml
new file mode 100644
index 0000000..7c0333d
--- /dev/null
+++ b/psalm.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/DependencyInjection/JsonSchemaExtension.php b/src/DependencyInjection/JsonSchemaExtension.php
index 0587dcb..f55dedc 100644
--- a/src/DependencyInjection/JsonSchemaExtension.php
+++ b/src/DependencyInjection/JsonSchemaExtension.php
@@ -12,7 +12,7 @@
class JsonSchemaExtension extends Extension
{
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader(
$container,
diff --git a/src/OpenApi/Annotation/JsonSchema.php b/src/OpenApi/Annotation/JsonSchema.php
index 5000a0c..305a5ef 100644
--- a/src/OpenApi/Annotation/JsonSchema.php
+++ b/src/OpenApi/Annotation/JsonSchema.php
@@ -10,7 +10,7 @@
class JsonSchema extends Schema
{
/**
- * @var array
+ * @var array
*/
public static $_required = ['schema'];
@@ -34,10 +34,10 @@ public function __construct(array $properties)
$this->required = $jsonSchema['required'] ?? false;
$this->additionalProperties = $jsonSchema['additionalProperties'] ?? true;
- $this->properties = array_map(function ($name, $property) {
+ $this->properties = array_map(function ($name, array $property) {
if (\array_key_exists('oneOf', $property)) {
$property['oneOf'] = array_map(
- fn ($schema) => new Schema($schema),
+ fn (array $schema) => new Schema($schema),
$property['oneOf']
);
}
diff --git a/src/OpenApi/Attributes/JsonSchema.php b/src/OpenApi/Attributes/JsonSchema.php
index 30479c7..dbb02f2 100644
--- a/src/OpenApi/Attributes/JsonSchema.php
+++ b/src/OpenApi/Attributes/JsonSchema.php
@@ -30,10 +30,10 @@ public function __construct(array $properties)
$this->required = $jsonSchema['required'] ?? false;
$this->additionalProperties = $jsonSchema['additionalProperties'] ?? true;
- $this->properties = array_map(function ($name, $property) {
+ $this->properties = array_map(function ($name, array $property) {
if (\array_key_exists('oneOf', $property)) {
$property['oneOf'] = array_map(
- fn ($schema) => new Schema($schema),
+ fn (object $schema) => new Schema($schema),
$property['oneOf']
);
}
diff --git a/src/RequestHandler.php b/src/RequestHandler.php
index a6d016f..79a434c 100644
--- a/src/RequestHandler.php
+++ b/src/RequestHandler.php
@@ -5,6 +5,7 @@
namespace Knp\JsonSchemaBundle;
use Knp\JsonSchema\Collection;
+use Knp\JsonSchema\JsonSchemaInterface;
use Knp\JsonSchema\Validator;
use Knp\JsonSchemaBundle\Exception\JsonSchemaException;
use Symfony\Component\HttpFoundation\Request;
@@ -20,16 +21,21 @@ class RequestHandler
'application/json;charset=utf-8',
];
+ private Collection $schemas;
+ private Validator $validator;
+
public function __construct(
- private readonly Collection $schemas,
- private readonly Validator $validator
+ Collection $schemas,
+ Validator $validator
) {
+ $this->schemas = $schemas;
+ $this->validator = $validator;
}
/**
* @template T
*
- * @param class-string> $schemaClass
+ * @param class-string> $schemaClass
*
* @return T
*/