Skip to content

Commit d4dee72

Browse files
author
Kirill Nesmeyanov
committed
Add array-like configuration drivers
1 parent d98f9df commit d4dee72

File tree

8 files changed

+691
-4
lines changed

8 files changed

+691
-4
lines changed

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "^8.1",
1313
"psr/log": "^1.0|^2.0|^3.0",
1414
"psr/simple-cache": "^1.0|^2.0|^3.0",
15-
"type-lang/parser": "^1.2",
15+
"type-lang/parser": "^1.3",
1616
"type-lang/printer": "^1.2"
1717
},
1818
"autoload": {
@@ -42,6 +42,10 @@
4242
"TypeLang\\Mapper\\Tests\\": "tests"
4343
}
4444
},
45+
"suggest": {
46+
"type-lang/phpdoc-standard-tags": "(^1.0) Required for DocBlockDriver mapping driver support",
47+
"justinrainbow/json-schema": "(^5.3|^6.0) Required for configuration drivers validation"
48+
},
4549
"extra": {
4650
"branch-alias": {
4751
"dev-master": "1.0.x-dev",

resources/config.schema.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/php-type-language/mapper/refs/heads/master/resources/config.schema.json",
4+
"title": "Config",
5+
"type": "object",
6+
"description": "A mapper configuration schema",
7+
"additionalProperties": false,
8+
"properties": {
9+
"normalize_as_array": {
10+
"type": "boolean",
11+
"description": "Responsible for enabling or disabling the conversion to an associative array"
12+
},
13+
"discriminator": {
14+
"type": "object",
15+
"description": "Configuration of discriminator map",
16+
"additionalProperties": false,
17+
"required": ["field", "map"],
18+
"properties": {
19+
"field": {
20+
"type": "string",
21+
"description": "The name of the field with which the discriminator map values should be compared",
22+
"minLength": 1
23+
},
24+
"map": {
25+
"type": "object",
26+
"description": "List of values for discriminator map. Each key must contain a value for the configured field",
27+
"patternProperties": {
28+
"^.+?$": {
29+
"type": "string",
30+
"description": "Concrete type for discriminator map in case of key matches discriminator field",
31+
"minLength": 1
32+
}
33+
},
34+
"additionalProperties": false
35+
},
36+
"otherwise": {
37+
"type": "string",
38+
"description": "An optional type in case the field's value is not found in the discriminator map",
39+
"minLength": 1
40+
}
41+
}
42+
},
43+
"properties": {
44+
"type": "object",
45+
"description": "List of properties for the specified class. Each key must contain the actual name of the class property",
46+
"patternProperties": {
47+
"^[a-zA-Z_\\x80-\\xff][a-zA-Z0-9_\\x80-\\xff]*$": {
48+
"anyOf": [
49+
{
50+
"type": "object",
51+
"description": "Configuration of a specific class property",
52+
"additionalProperties": false,
53+
"properties": {
54+
"name": {
55+
"type": "string",
56+
"description": "Public name of the property",
57+
"minLength": 1
58+
},
59+
"type": {
60+
"type": "string",
61+
"description": "Specific property type",
62+
"minLength": 1
63+
},
64+
"skip": {
65+
"description": "Rules according to which a property should be excluded during normalization",
66+
"anyOf": [
67+
{
68+
"type": "string",
69+
"description": "A specific rule to exclude: Can contain 'null' (if a field should be excluded when it contains null), 'empty' (if a field should be excluded when it empty), or an expression (if a complex expression is required for exclusion)",
70+
"minLength": 1
71+
},
72+
{
73+
"type": "array",
74+
"description": "List of multiple rules to exclude. Only one of the rules is taken into account (logical disjunction)",
75+
"minItems": 1,
76+
"items": {
77+
"type": "string",
78+
"description": "A specific rule to exclude: Can contain 'null' (if a field should be excluded when it contains null), 'empty' (if a field should be excluded when it empty), or an expression (if a complex expression is required for exclusion)",
79+
"minLength": 1
80+
}
81+
}
82+
]
83+
}
84+
}
85+
},
86+
{
87+
"type": "string",
88+
"description": "Specific property type",
89+
"minLength": 1
90+
}
91+
]
92+
}
93+
},
94+
"additionalProperties": false
95+
}
96+
}
97+
}

src/Exception/Definition/Template/TooManyTemplateArgumentsException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace TypeLang\Mapper\Exception\Definition\Template;
66

77
use TypeLang\Parser\Node\Stmt\NamedTypeNode;
8-
use TypeLang\Parser\Node\Stmt\TypeStatement;
98

109
/**
1110
* Occurs when a type supports fewer arguments than were passed

0 commit comments

Comments
 (0)