20
20
* @experimental
21
21
*/
22
22
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE )]
23
- class ApiResource
23
+ final class ApiResource
24
24
{
25
25
private $ operations ;
26
26
private $ uriTemplate ;
@@ -110,56 +110,57 @@ class ApiResource
110
110
private $ extraProperties ;
111
111
112
112
/**
113
- * @param string $uriTemplate
114
- * @param string $shortName
115
- * @param string $description
116
- * @param array|string $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
117
- * @param array|string $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
118
- * @param array|string $outputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
119
- * @param string $routePrefix https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
120
- * @param bool $stateless
121
- * @param string $sunset https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed
122
- * @param string $acceptPatch
123
- * @param string $status
124
- * @param string $class
125
- * @param int $urlGenerationStrategy
126
- * @param string $deprecationReason https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
127
- * @param array $cacheHeaders https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers
128
- * @param array $normalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
129
- * @param array $denormalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
130
- * @param string[] $hydraContext https://api-platform.com/docs/core/extending-jsonld-context/#hydra
131
- * @param array $openapiContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
132
- * @param array $validationContext https://api-platform.com/docs/core/validation/#using-validation-groups
133
- * @param string[] $filters https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
134
- * @param bool $elasticsearch https://api-platform.com/docs/core/elasticsearch/
135
- * @param bool|array $mercure https://api-platform.com/docs/core/mercure
136
- * @param bool $messenger https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
137
- * @param mixed $input https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
138
- * @param mixed $output https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
139
- * @param array $order https://api-platform.com/docs/core/default-order/#overriding-default-order
140
- * @param bool $fetchPartial https://api-platform.com/docs/core/performance/#fetch-partial
141
- * @param bool $forceEager https://api-platform.com/docs/core/performance/#force-eager
142
- * @param bool $paginationClientEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
143
- * @param bool $paginationClientItemsPerPage https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
144
- * @param bool $paginationClientPartial https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
145
- * @param array $paginationViaCursor https://api-platform.com/docs/core/pagination/#cursor-based-pagination
146
- * @param bool $paginationEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource
147
- * @param bool $paginationFetchJoinCollection https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
148
- * @param int $paginationItemsPerPage https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
149
- * @param int $paginationMaximumItemsPerPage https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
150
- * @param bool $paginationPartial https://api-platform.com/docs/core/performance/#partial-pagination
151
- * @param string $paginationType https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination
152
- * @param string $security https://api-platform.com/docs/core/security
153
- * @param string $securityMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
154
- * @param string $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
155
- * @param string $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
156
- * @param bool $compositeIdentifier
113
+ * @param string $uriTemplate
114
+ * @param string $shortName
115
+ * @param string $description
116
+ * @param string[]|string $types
117
+ * @param array|string $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
118
+ * @param array|string $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
119
+ * @param array|string $outputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
120
+ * @param string $routePrefix https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
121
+ * @param bool $stateless
122
+ * @param string $sunset https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed
123
+ * @param string $acceptPatch
124
+ * @param string $status
125
+ * @param string $class
126
+ * @param int $urlGenerationStrategy
127
+ * @param string $deprecationReason https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
128
+ * @param array $cacheHeaders https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers
129
+ * @param array $normalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
130
+ * @param array $denormalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
131
+ * @param string[] $hydraContext https://api-platform.com/docs/core/extending-jsonld-context/#hydra
132
+ * @param array $openapiContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
133
+ * @param array $validationContext https://api-platform.com/docs/core/validation/#using-validation-groups
134
+ * @param string[] $filters https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
135
+ * @param bool $elasticsearch https://api-platform.com/docs/core/elasticsearch/
136
+ * @param bool|array $mercure https://api-platform.com/docs/core/mercure
137
+ * @param bool $messenger https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
138
+ * @param mixed $input https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
139
+ * @param mixed $output https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
140
+ * @param array $order https://api-platform.com/docs/core/default-order/#overriding-default-order
141
+ * @param bool $fetchPartial https://api-platform.com/docs/core/performance/#fetch-partial
142
+ * @param bool $forceEager https://api-platform.com/docs/core/performance/#force-eager
143
+ * @param bool $paginationClientEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
144
+ * @param bool $paginationClientItemsPerPage https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
145
+ * @param bool $paginationClientPartial https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
146
+ * @param array $paginationViaCursor https://api-platform.com/docs/core/pagination/#cursor-based-pagination
147
+ * @param bool $paginationEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource
148
+ * @param bool $paginationFetchJoinCollection https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
149
+ * @param int $paginationItemsPerPage https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
150
+ * @param int $paginationMaximumItemsPerPage https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
151
+ * @param bool $paginationPartial https://api-platform.com/docs/core/performance/#partial-pagination
152
+ * @param string $paginationType https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination
153
+ * @param string $security https://api-platform.com/docs/core/security
154
+ * @param string $securityMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
155
+ * @param string $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
156
+ * @param string $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
157
+ * @param bool $compositeIdentifier
157
158
*/
158
159
public function __construct (
159
160
?string $ uriTemplate = null ,
160
161
?string $ shortName = null ,
161
162
?string $ description = null ,
162
- array $ types = [],
163
+ $ types = [],
163
164
$ operations = [],
164
165
$ formats = null ,
165
166
$ inputFormats = null ,
@@ -220,7 +221,7 @@ public function __construct(
220
221
$ this ->uriTemplate = $ uriTemplate ;
221
222
$ this ->shortName = $ shortName ;
222
223
$ this ->description = $ description ;
223
- $ this ->types = $ types ;
224
+ $ this ->types = ( array ) $ types ;
224
225
$ this ->formats = $ formats ;
225
226
$ this ->inputFormats = $ inputFormats ;
226
227
$ this ->outputFormats = $ outputFormats ;
@@ -295,7 +296,7 @@ public function getUriTemplate(): ?string
295
296
return $ this ->uriTemplate ;
296
297
}
297
298
298
- public function withUriTemplate (?string $ uriTemplate = null )
299
+ public function withUriTemplate (?string $ uriTemplate = null ): self
299
300
{
300
301
$ self = clone $ this ;
301
302
$ self ->uriTemplate = $ uriTemplate ;
@@ -308,7 +309,7 @@ public function getShortName(): ?string
308
309
return $ this ->shortName ;
309
310
}
310
311
311
- public function withShortName (?string $ shortName = null )
312
+ public function withShortName (?string $ shortName = null ): self
312
313
{
313
314
$ self = clone $ this ;
314
315
$ self ->shortName = $ shortName ;
@@ -321,7 +322,7 @@ public function getDescription(): ?string
321
322
return $ this ->description ;
322
323
}
323
324
324
- public function withDescription (?string $ description = null )
325
+ public function withDescription (?string $ description = null ): self
325
326
{
326
327
$ self = clone $ this ;
327
328
$ self ->description = $ description ;
@@ -334,10 +335,13 @@ public function getTypes(): array
334
335
return $ this ->types ;
335
336
}
336
337
337
- public function withTypes (array $ types = [])
338
+ /**
339
+ * @param string[]|string $types
340
+ */
341
+ public function withTypes ($ types = []): self
338
342
{
339
343
$ self = clone $ this ;
340
- $ self ->types = $ types ;
344
+ $ self ->types = ( array ) $ types ;
341
345
342
346
return $ self ;
343
347
}
0 commit comments