Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Metadata/ApiProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function withExample($example): self
return $self;
}

public function getDeprecationReason()
public function getDeprecationReason(): ?string
{
return $this->deprecationReason;
}
Expand All @@ -307,7 +307,7 @@ public function withDeprecationReason($deprecationReason): self
return $self;
}

public function isFetchable()
public function isFetchable(): ?bool
{
return $this->fetchable;
}
Expand All @@ -320,7 +320,7 @@ public function withFetchable($fetchable): self
return $self;
}

public function getFetchEager()
public function getFetchEager(): ?bool
{
return $this->fetchEager;
}
Expand All @@ -333,7 +333,7 @@ public function withFetchEager($fetchEager): self
return $self;
}

public function getJsonldContext()
public function getJsonldContext(): ?array
{
return $this->jsonldContext;
}
Expand All @@ -346,7 +346,7 @@ public function withJsonldContext($jsonldContext): self
return $self;
}

public function getOpenapiContext()
public function getOpenapiContext(): ?array
{
return $this->openapiContext;
}
Expand All @@ -359,7 +359,7 @@ public function withOpenapiContext($openapiContext): self
return $self;
}

public function getPush()
public function getPush(): ?bool
{
return $this->push;
}
Expand All @@ -372,7 +372,7 @@ public function withPush($push): self
return $self;
}

public function getSecurity()
public function getSecurity(): ?string
{
return $this->security;
}
Expand All @@ -385,7 +385,7 @@ public function withSecurity($security): self
return $self;
}

public function getSecurityPostDenormalize()
public function getSecurityPostDenormalize(): ?string
{
return $this->securityPostDenormalize;
}
Expand Down
108 changes: 56 additions & 52 deletions src/Metadata/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @experimental
*/
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class ApiResource
final class ApiResource
{
private $operations;
private $uriTemplate;
Expand Down Expand Up @@ -110,56 +110,57 @@ class ApiResource
private $extraProperties;

/**
* @param string $uriTemplate
* @param string $shortName
* @param string $description
* @param array|string $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $outputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param string $routePrefix https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
* @param bool $stateless
* @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
* @param string $acceptPatch
* @param string $status
* @param string $class
* @param int $urlGenerationStrategy
* @param string $deprecationReason https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
* @param array $cacheHeaders https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers
* @param array $normalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
* @param array $denormalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
* @param string[] $hydraContext https://api-platform.com/docs/core/extending-jsonld-context/#hydra
* @param array $openapiContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
* @param array $validationContext https://api-platform.com/docs/core/validation/#using-validation-groups
* @param string[] $filters https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
* @param bool $elasticsearch https://api-platform.com/docs/core/elasticsearch/
* @param bool|array $mercure https://api-platform.com/docs/core/mercure
* @param bool $messenger https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
* @param mixed $input https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
* @param mixed $output https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
* @param array $order https://api-platform.com/docs/core/default-order/#overriding-default-order
* @param bool $fetchPartial https://api-platform.com/docs/core/performance/#fetch-partial
* @param bool $forceEager https://api-platform.com/docs/core/performance/#force-eager
* @param bool $paginationClientEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
* @param bool $paginationClientItemsPerPage https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
* @param bool $paginationClientPartial https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
* @param array $paginationViaCursor https://api-platform.com/docs/core/pagination/#cursor-based-pagination
* @param bool $paginationEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource
* @param bool $paginationFetchJoinCollection https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
* @param int $paginationItemsPerPage https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
* @param int $paginationMaximumItemsPerPage https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
* @param bool $paginationPartial https://api-platform.com/docs/core/performance/#partial-pagination
* @param string $paginationType https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination
* @param string $security https://api-platform.com/docs/core/security
* @param string $securityMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
* @param string $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
* @param string $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
* @param bool $compositeIdentifier
* @param string $uriTemplate
* @param string $shortName
* @param string $description
* @param string[]|string $types
* @param array|string $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $outputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param string $routePrefix https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations
* @param bool $stateless
* @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
* @param string $acceptPatch
* @param string $status
* @param string $class
* @param int $urlGenerationStrategy
* @param string $deprecationReason https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties
* @param array $cacheHeaders https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers
* @param array $normalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
* @param array $denormalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups
* @param string[] $hydraContext https://api-platform.com/docs/core/extending-jsonld-context/#hydra
* @param array $openapiContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts
* @param array $validationContext https://api-platform.com/docs/core/validation/#using-validation-groups
* @param string[] $filters https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters
* @param bool $elasticsearch https://api-platform.com/docs/core/elasticsearch/
* @param bool|array $mercure https://api-platform.com/docs/core/mercure
* @param bool $messenger https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus
* @param mixed $input https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
* @param mixed $output https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation
* @param array $order https://api-platform.com/docs/core/default-order/#overriding-default-order
* @param bool $fetchPartial https://api-platform.com/docs/core/performance/#fetch-partial
* @param bool $forceEager https://api-platform.com/docs/core/performance/#force-eager
* @param bool $paginationClientEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1
* @param bool $paginationClientItemsPerPage https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3
* @param bool $paginationClientPartial https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6
* @param array $paginationViaCursor https://api-platform.com/docs/core/pagination/#cursor-based-pagination
* @param bool $paginationEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource
* @param bool $paginationFetchJoinCollection https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator
* @param int $paginationItemsPerPage https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page
* @param int $paginationMaximumItemsPerPage https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page
* @param bool $paginationPartial https://api-platform.com/docs/core/performance/#partial-pagination
* @param string $paginationType https://api-platform.com/docs/core/graphql/#using-the-page-based-pagination
* @param string $security https://api-platform.com/docs/core/security
* @param string $securityMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
* @param string $securityPostDenormalize https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization
* @param string $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message
* @param bool $compositeIdentifier
*/
public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$operations = [],
$formats = null,
$inputFormats = null,
Expand Down Expand Up @@ -220,7 +221,7 @@ public function __construct(
$this->uriTemplate = $uriTemplate;
$this->shortName = $shortName;
$this->description = $description;
$this->types = $types;
$this->types = (array) $types;
$this->formats = $formats;
$this->inputFormats = $inputFormats;
$this->outputFormats = $outputFormats;
Expand Down Expand Up @@ -295,7 +296,7 @@ public function getUriTemplate(): ?string
return $this->uriTemplate;
}

public function withUriTemplate(?string $uriTemplate = null)
public function withUriTemplate(?string $uriTemplate = null): self
{
$self = clone $this;
$self->uriTemplate = $uriTemplate;
Expand All @@ -308,7 +309,7 @@ public function getShortName(): ?string
return $this->shortName;
}

public function withShortName(?string $shortName = null)
public function withShortName(?string $shortName = null): self
{
$self = clone $this;
$self->shortName = $shortName;
Expand All @@ -321,7 +322,7 @@ public function getDescription(): ?string
return $this->description;
}

public function withDescription(?string $description = null)
public function withDescription(?string $description = null): self
{
$self = clone $this;
$self->description = $description;
Expand All @@ -334,10 +335,13 @@ public function getTypes(): array
return $this->types;
}

public function withTypes(array $types = [])
/**
* @param string[]|string $types
*/
public function withTypes($types = []): self
{
$self = clone $this;
$self->types = $types;
$self->types = (array) $types;

return $self;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Metadata;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class Delete extends Operation
final class Delete extends Operation
{
/**
* {@inheritdoc}
Expand All @@ -24,7 +24,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/GetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Metadata;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class GetCollection extends Operation
final class GetCollection extends Operation
{
/**
* {@inheritdoc}
Expand All @@ -23,7 +23,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down
14 changes: 9 additions & 5 deletions src/Metadata/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class Operation
* @param string $uriTemplate
* @param string $shortName
* @param string $description
* @param string[]|string $types
* @param array|string $formats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $inputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
* @param array|string $outputFormats https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation
Expand Down Expand Up @@ -180,7 +181,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down Expand Up @@ -251,7 +252,7 @@ public function __construct(
$this->uriTemplate = $uriTemplate;
$this->shortName = $shortName;
$this->description = $description;
$this->types = $types;
$this->types = (array) $types;
$this->formats = $formats;
$this->inputFormats = $inputFormats;
$this->outputFormats = $outputFormats;
Expand Down Expand Up @@ -367,7 +368,7 @@ public function getShortName(): ?string
return $this->shortName;
}

public function withShortName(?string $shortName = null)
public function withShortName(?string $shortName = null): self
{
$self = clone $this;
$self->shortName = $shortName;
Expand All @@ -380,7 +381,7 @@ public function getDescription(): ?string
return $this->description;
}

public function withDescription(?string $description = null)
public function withDescription(?string $description = null): self
{
$self = clone $this;
$self->description = $description;
Expand All @@ -393,7 +394,10 @@ public function getTypes(): array
return $this->types;
}

public function withTypes(array $types = [])
/**
* @param string[]|string $types
*/
public function withTypes($types = []): self
{
$self = clone $this;
$self->types = $types;
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Patch.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Metadata;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class Patch extends Operation
final class Patch extends Operation
{
/**
* {@inheritdoc}
Expand All @@ -23,7 +23,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Metadata;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class Post extends Operation
final class Post extends Operation
{
/**
* {@inheritdoc}
Expand All @@ -23,7 +23,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/Put.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Metadata;

#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
class Put extends Operation
final class Put extends Operation
{
/**
* {@inheritdoc}
Expand All @@ -23,7 +23,7 @@ public function __construct(
?string $uriTemplate = null,
?string $shortName = null,
?string $description = null,
array $types = [],
$types = [],
$formats = null,
$inputFormats = null,
$outputFormats = null,
Expand Down