-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathPropertyInterface.php
More file actions
182 lines (145 loc) · 5.95 KB
/
PropertyInterface.php
File metadata and controls
182 lines (145 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
declare(strict_types=1);
namespace PHPModelGenerator\Model\Property;
use PHPModelGenerator\Model\Attributes\PhpAttribute;
use PHPModelGenerator\Model\GeneratorConfiguration;
use PHPModelGenerator\Model\Schema;
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
use PHPModelGenerator\Model\Validator;
use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
use PHPModelGenerator\PropertyProcessor\Decorator\Property\PropertyDecoratorInterface;
use PHPModelGenerator\PropertyProcessor\Decorator\TypeHint\TypeHintDecoratorInterface;
use PHPModelGenerator\Utils\ResolvableInterface;
/**
* Interface PropertyInterface
*
* @package PHPModelGenerator\Model
*/
interface PropertyInterface extends ResolvableInterface
{
public function getName(): string;
/**
* @param bool $variableName If set to true the name for the variable is returned. Otherwise, the name for functions
* will be returned
*/
public function getAttribute(bool $variableName = false): string;
/**
* @param bool $outputType If set to true the output type will be returned (may differ from the base type)
*/
public function getType(bool $outputType = false): ?PropertyType;
/**
* @param PropertyType|null $outputType By default the output type will be equal to the base type but due to applied
* filters the output type may change
* @param bool $reset set to true for a full type reset (including type hint decorators like array, ...)
*/
public function setType(
?PropertyType $type = null,
?PropertyType $outputType = null,
bool $reset = false,
): PropertyInterface;
/**
* @param bool $outputType If set to true the output type hint will be returned (may differ from the base type)
* @param string[] $skipDecorators Provide a set of decorators (FQCN) which shouldn't be applied
* (might be necessary to avoid infinite loops for recursive calls)
*/
public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string;
public function addTypeHintDecorator(TypeHintDecoratorInterface $typeHintDecorator): PropertyInterface;
/**
* Get a description for the property. If no description is available an empty string will be returned
*/
public function getDescription(): string;
public function getComment(): ?string;
public function setComment(string $comment): PropertyInterface;
public function getExamples(): array;
public function setExamples(array $examples): PropertyInterface;
/**
* Add a validator for the property
*
* The priority is used to order the validators applied to a property.
* The validators with the lowest priority number will be executed first.
*
* Priority 1: Required checks
* Priority 2: Type Checks
* Priority 3: Enum Checks
* Priority 10+: Filter validators
* Priority 99: Default priority used for casual validators
* Priority 100: Validators for compositions
*
* The optional $sourceKey records which schema keyword (e.g. 'pattern', 'minimum')
* caused this validator to be added. Normally set automatically by PropertyFactory
* after each Draft modifier runs; pass it explicitly only when transferring a validator
* from another property (e.g. multi-type sub-property transfer).
*/
public function addValidator(
PropertyValidatorInterface $validator,
int $priority = 99,
?string $sourceKey = null,
): PropertyInterface;
/**
* @return Validator[]
*/
public function getValidators(): array;
/**
* Filter the assigned validators
*/
public function filterValidators(callable $filter): PropertyInterface;
/**
* Retrieve all added validators ordered by priority
*
* @return PropertyValidatorInterface[]
*/
public function getOrderedValidators(): array;
/**
* Add a decorator to the property
*/
public function addDecorator(PropertyDecoratorInterface $decorator): PropertyInterface;
/**
* Resolve all decorators of the property
*/
public function resolveDecorator(string $input, bool $nestedProperty): string;
/**
* Filter the assigned decorators
*/
public function filterDecorators(callable $filter): PropertyInterface;
/**
* @return PropertyDecoratorInterface[]
*/
public function getDecorators(): array;
public function setRequired(bool $isPropertyRequired): PropertyInterface;
public function setReadOnly(bool $isPropertyReadOnly): PropertyInterface;
public function setInternal(bool $isPropertyInternal): PropertyInterface;
/**
* @param bool $raw By default, the provided value will be added to the generated code via var_export. If the raw
* option is enabled the value provided in $defaultValue will not be changed.
*/
public function setDefaultValue(mixed $defaultValue, bool $raw = false): PropertyInterface;
public function getDefaultValue(): ?string;
public function isRequired(): bool;
public function isReadOnly(): bool;
public function isWriteOnly(): bool;
public function setWriteOnly(bool $isPropertyWriteOnly): PropertyInterface;
public function isInternal(): bool;
/**
* Set a nested schema
*
* @return PropertyInterface
*/
public function setNestedSchema(Schema $schema);
/**
* Get a nested schema if a schema was appended to the property
*/
public function getNestedSchema(): ?Schema;
/**
* Get the JSON schema used to set up the property
*/
public function getJsonSchema(): JsonSchema;
public function addAttribute(
PhpAttribute $attribute,
?GeneratorConfiguration $generatorConfiguration = null,
?int $enablementFlag = null,
): static;
/**
* @return PhpAttribute[]
*/
public function getAttributes(): array;
}