|
33 | 33 | * @Attribute("swaggerContext", type="array")
|
34 | 34 | * )
|
35 | 35 | */
|
| 36 | +#[\Attribute(\Attribute::TARGET_PROPERTY|\Attribute::TARGET_METHOD)] |
36 | 37 | final class ApiProperty
|
37 | 38 | {
|
38 | 39 | use AttributesHydratorTrait;
|
39 | 40 |
|
| 41 | + /** |
| 42 | + * @var array<string, array> |
| 43 | + */ |
| 44 | + private static $deprecatedAttributes = []; |
| 45 | + |
40 | 46 | /**
|
41 | 47 | * @var string
|
42 | 48 | */
|
@@ -88,66 +94,64 @@ final class ApiProperty
|
88 | 94 | public $example;
|
89 | 95 |
|
90 | 96 | /**
|
91 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
92 |
| - * |
93 |
| - * @var string |
94 |
| - */ |
95 |
| - private $deprecationReason; |
96 |
| - |
97 |
| - /** |
98 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
99 |
| - * |
100 |
| - * @var bool |
101 |
| - */ |
102 |
| - private $fetchable; |
103 |
| - |
104 |
| - /** |
105 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
106 |
| - * |
107 |
| - * @var bool |
108 |
| - */ |
109 |
| - private $fetchEager; |
110 |
| - |
111 |
| - /** |
112 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
113 |
| - * |
114 |
| - * @var array |
115 |
| - */ |
116 |
| - private $jsonldContext; |
117 |
| - |
118 |
| - /** |
119 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
| 97 | + * @param string $description |
| 98 | + * @param bool $readable |
| 99 | + * @param bool $writable |
| 100 | + * @param bool $readableLink |
| 101 | + * @param bool $writableLink |
| 102 | + * @param bool $required |
| 103 | + * @param bool $iri |
| 104 | + * @param bool $identifier |
| 105 | + * @param string|int|float|bool|array $default |
| 106 | + * @param string|int|float|bool|array|null $example |
120 | 107 | *
|
121 |
| - * @var array |
122 |
| - */ |
123 |
| - private $openapiContext; |
124 |
| - |
125 |
| - /** |
126 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
| 108 | + * @param string $deprecationReason |
| 109 | + * @param bool $fetchable |
| 110 | + * @param bool $fetchEager |
| 111 | + * @param array $jsonldContext |
| 112 | + * @param array $openapiContext |
| 113 | + * @param bool $push |
| 114 | + * @param string $security |
| 115 | + * @param array $swaggerContext |
127 | 116 | *
|
128 |
| - * @var bool |
129 |
| - */ |
130 |
| - private $push; |
131 |
| - |
132 |
| - /** |
133 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
134 |
| - * |
135 |
| - * @var string |
136 |
| - */ |
137 |
| - private $security; |
138 |
| - |
139 |
| - /** |
140 |
| - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 |
141 |
| - * |
142 |
| - * @var array |
143 |
| - */ |
144 |
| - private $swaggerContext; |
145 |
| - |
146 |
| - /** |
147 | 117 | * @throws InvalidArgumentException
|
148 | 118 | */
|
149 |
| - public function __construct(array $values = []) |
150 |
| - { |
151 |
| - $this->hydrateAttributes($values); |
| 119 | + public function __construct( |
| 120 | + $description = null, |
| 121 | + ?bool $readable = null, |
| 122 | + ?bool $writable = null, |
| 123 | + ?bool $readableLink = null, |
| 124 | + ?bool $writableLink = null, |
| 125 | + ?bool $required = null, |
| 126 | + ?string $iri = null, |
| 127 | + ?bool $identifier = null, |
| 128 | + $default = null, |
| 129 | + $example = null, |
| 130 | + |
| 131 | + // attributes |
| 132 | + ?array $attributes = null, |
| 133 | + ?string $deprecationReason = null, |
| 134 | + ?bool $fetchable = null, |
| 135 | + ?bool $fetchEager = null, |
| 136 | + ?array $jsonldContext = null, |
| 137 | + ?array $openapiContext = null, |
| 138 | + ?bool $push = null, |
| 139 | + ?string $security = null, |
| 140 | + ?array $swaggerContext = null |
| 141 | + ) { |
| 142 | + if (!is_array($description)) { |
| 143 | + [$publicProperties, $configurableAttributes] = self::getConfigMetadata(); |
| 144 | + |
| 145 | + foreach ($publicProperties as $prop => $_) { |
| 146 | + $this->{$prop} = $$prop; |
| 147 | + } |
| 148 | + |
| 149 | + $description = []; |
| 150 | + foreach ($configurableAttributes as $attribute => $_) { |
| 151 | + $description[$attribute] = $$attribute; |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + $this->hydrateAttributes($description); |
152 | 156 | }
|
153 | 157 | }
|
0 commit comments