diff --git a/src/Annotation/ApiProperty.php b/src/Annotation/ApiProperty.php index 2ec25e3545a..5b0b21aaf81 100644 --- a/src/Annotation/ApiProperty.php +++ b/src/Annotation/ApiProperty.php @@ -76,55 +76,6 @@ final class ApiProperty */ public $identifier; - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $deprecationReason; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $fetchable; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $fetchEager; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $jsonldContext; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $openapiContext; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $push; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $swaggerContext; - /** * @throws InvalidArgumentException */ diff --git a/src/Annotation/ApiResource.php b/src/Annotation/ApiResource.php index 34010e5b2c6..af64b790bca 100644 --- a/src/Annotation/ApiResource.php +++ b/src/Annotation/ApiResource.php @@ -25,22 +25,16 @@ * @Attributes( * @Attribute("accessControl", type="string"), * @Attribute("accessControlMessage", type="string"), - * @Attribute("attributes", type="array"), * @Attribute("cacheHeaders", type="array"), - * @Attribute("collectionOperations", type="array"), * @Attribute("denormalizationContext", type="array"), * @Attribute("deprecationReason", type="string"), - * @Attribute("description", type="string"), * @Attribute("elasticsearch", type="bool"), * @Attribute("fetchPartial", type="bool"), * @Attribute("forceEager", type="bool"), * @Attribute("formats", type="array"), * @Attribute("filters", type="string[]"), - * @Attribute("graphql", type="array"), * @Attribute("hydraContext", type="array"), * @Attribute("input", type="mixed"), - * @Attribute("iri", type="string"), - * @Attribute("itemOperations", type="array"), * @Attribute("mercure", type="mixed"), * @Attribute("messenger", type="mixed"), * @Attribute("normalizationContext", type="array"), @@ -62,8 +56,6 @@ * @Attribute("securityMessage", type="string"), * @Attribute("securityPostDenormalize", type="string"), * @Attribute("securityPostDenormalizeMessage", type="string"), - * @Attribute("shortName", type="string"), - * @Attribute("subresourceOperations", type="array"), * @Attribute("sunset", type="string"), * @Attribute("swaggerContext", type="array"), * @Attribute("validationGroups", type="mixed") @@ -116,275 +108,6 @@ final class ApiResource */ public $subresourceOperations; - /** - * @see https://api-platform.com/docs/core/performance/#setting-custom-http-cache-headers - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $cacheHeaders; - - /** - * @see https://api-platform.com/docs/core/serialization/#using-serialization-groups - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $denormalizationContext; - - /** - * @see https://api-platform.com/docs/core/deprecations/#deprecating-resource-classes-operations-and-properties - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $deprecationReason; - - /** - * @see https://api-platform.com/docs/core/elasticsearch/ - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $elasticsearch; - - /** - * @see https://api-platform.com/docs/core/performance/#fetch-partial - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $fetchPartial; - - /** - * @see https://api-platform.com/docs/core/performance/#force-eager - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $forceEager; - - /** - * @see https://api-platform.com/docs/core/content-negotiation/#configuring-formats-for-a-specific-resource-or-operation - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $formats; - - /** - * @see https://api-platform.com/docs/core/filters/#doctrine-orm-and-mongodb-odm-filters - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string[] - */ - private $filters; - - /** - * @see https://api-platform.com/docs/core/extending-jsonld-context/#hydra - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string[] - */ - private $hydraContext; - - /** - * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string|false - */ - private $input; - - /** - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var int - * - * @deprecated - Use $paginationMaximumItemsPerPage instead - */ - private $maximumItemsPerPage; - - /** - * @see https://api-platform.com/docs/core/mercure - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - */ - private $mercure; - - /** - * @see https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool|string - */ - private $messenger; - - /** - * @see https://api-platform.com/docs/core/serialization/#using-serialization-groups - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $normalizationContext; - - /** - * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $openapiContext; - - /** - * @see https://api-platform.com/docs/core/default-order/#overriding-default-order - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $order; - - /** - * @see https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string|false - */ - private $output; - - /** - * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1 - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationClientEnabled; - - /** - * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-3 - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationClientItemsPerPage; - - /** - * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource-6 - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationClientPartial; - - /** - * @see https://api-platform.com/docs/core/pagination/#cursor-based-pagination - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $paginationViaCursor; - - /** - * @see https://api-platform.com/docs/core/pagination/#for-a-specific-resource - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationEnabled; - - /** - * @see https://api-platform.com/docs/core/pagination/#controlling-the-behavior-of-the-doctrine-orm-paginator - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationFetchJoinCollection; - - /** - * @see https://api-platform.com/docs/core/pagination/#changing-the-number-of-items-per-page - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var int - */ - private $paginationItemsPerPage; - - /** - * @see https://api-platform.com/docs/core/pagination/#changing-maximum-items-per-page - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var int - */ - private $paginationMaximumItemsPerPage; - - /** - * @see https://api-platform.com/docs/core/performance/#partial-pagination - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var bool - */ - private $paginationPartial; - - /** - * @see https://api-platform.com/docs/core/operations/#prefixing-all-routes-of-all-operations - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $routePrefix; - - /** - * @see https://api-platform.com/docs/core/security - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $security; - - /** - * @see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $securityMessage; - - /** - * @see https://api-platform.com/docs/core/security/#executing-access-control-rules-after-denormalization - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $securityPostDenormalize; - - /** - * @see https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $securityPostDenormalizeMessage; - - /** - * @see https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var string - */ - private $sunset; - - /** - * @see https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - * - * @var array - */ - private $swaggerContext; - - /** - * @see https://api-platform.com/docs/core/validation/#using-validation-groups - * @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112 - */ - private $validationGroups; - /** * @throws InvalidArgumentException */ diff --git a/src/Annotation/AttributesHydratorTrait.php b/src/Annotation/AttributesHydratorTrait.php index 1211f73b6a1..19822977e31 100644 --- a/src/Annotation/AttributesHydratorTrait.php +++ b/src/Annotation/AttributesHydratorTrait.php @@ -54,11 +54,7 @@ private function hydrateAttributes(array $values): void foreach ($values as $key => $value) { $key = (string) $key; - if (!property_exists($this, $key)) { - throw new InvalidArgumentException(sprintf('Unknown property "%s" on annotation "%s".', $key, self::class)); - } - - if ((new \ReflectionProperty($this, $key))->isPublic()) { + if (property_exists($this, $key) && (new \ReflectionProperty($this, $key))->isPublic()) { $this->{$key} = $value; continue; } diff --git a/tests/Annotation/ApiResourceTest.php b/tests/Annotation/ApiResourceTest.php index 5f24c6aacca..f3f2a21fbe7 100644 --- a/tests/Annotation/ApiResourceTest.php +++ b/tests/Annotation/ApiResourceTest.php @@ -14,7 +14,6 @@ namespace ApiPlatform\Core\Tests\Annotation; use ApiPlatform\Core\Annotation\ApiResource; -use ApiPlatform\Core\Exception\InvalidArgumentException; use ApiPlatform\Core\Tests\Fixtures\AnnotatedClass; use Doctrine\Common\Annotations\AnnotationReader; use PHPUnit\Framework\TestCase; @@ -132,18 +131,6 @@ public function testApiResourceAnnotation() ], $resource->attributes); } - public function testConstructWithInvalidAttribute() - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Unknown property "invalidAttribute" on annotation "ApiPlatform\\Core\\Annotation\\ApiResource".'); - - new ApiResource([ - 'shortName' => 'shortName', - 'routePrefix' => '/foo', - 'invalidAttribute' => 'exception', - ]); - } - /** * @group legacy * @expectedDeprecation Attribute "accessControl" is deprecated in annotation since API Platform 2.5, prefer using "security" attribute instead