diff --git a/src/Annotation/Property.php b/src/Annotation/ApiProperty.php similarity index 97% rename from src/Annotation/Property.php rename to src/Annotation/ApiProperty.php index 98961851b35..d3278b047da 100644 --- a/src/Annotation/Property.php +++ b/src/Annotation/ApiProperty.php @@ -19,7 +19,7 @@ * @Annotation * @Target({"METHOD", "PROPERTY"}) */ -final class Property +final class ApiProperty { /** * @var string diff --git a/src/Metadata/Property/Factory/AnnotationPropertyMetadataFactory.php b/src/Metadata/Property/Factory/AnnotationPropertyMetadataFactory.php index 3f4eb63fae5..0ddd06613cb 100644 --- a/src/Metadata/Property/Factory/AnnotationPropertyMetadataFactory.php +++ b/src/Metadata/Property/Factory/AnnotationPropertyMetadataFactory.php @@ -11,7 +11,7 @@ namespace ApiPlatform\Core\Metadata\Property\Factory; -use ApiPlatform\Core\Annotation\Property; +use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Exception\PropertyNotFoundException; use ApiPlatform\Core\Metadata\Property\PropertyMetadata; use ApiPlatform\Core\Util\Reflection; @@ -54,7 +54,7 @@ public function create(string $resourceClass, string $property, array $options = } if ($reflectionClass->hasProperty($property)) { - $annotation = $this->reader->getPropertyAnnotation($reflectionClass->getProperty($property), Property::class); + $annotation = $this->reader->getPropertyAnnotation($reflectionClass->getProperty($property), ApiProperty::class); if (null !== $annotation) { return $this->createMetadata($annotation, $parentPropertyMetadata); @@ -74,7 +74,7 @@ public function create(string $resourceClass, string $property, array $options = continue; } - $annotation = $this->reader->getMethodAnnotation($reflectionMethod, Property::class); + $annotation = $this->reader->getMethodAnnotation($reflectionMethod, ApiProperty::class); if (null !== $annotation) { return $this->createMetadata($annotation, $parentPropertyMetadata); } @@ -103,7 +103,7 @@ private function handleNotFound(PropertyMetadata $parentPropertyMetadata = null, throw new PropertyNotFoundException(sprintf('Property "%s" of class "%s" not found.', $property, $resourceClass)); } - private function createMetadata(Property $annotation, PropertyMetadata $parentPropertyMetadata = null) : PropertyMetadata + private function createMetadata(ApiProperty $annotation, PropertyMetadata $parentPropertyMetadata = null) : PropertyMetadata { if (!$parentPropertyMetadata) { return new PropertyMetadata( diff --git a/src/Metadata/Property/Factory/AnnotationPropertyNameCollectionFactory.php b/src/Metadata/Property/Factory/AnnotationPropertyNameCollectionFactory.php index 09337a8e6f1..825218bf46e 100644 --- a/src/Metadata/Property/Factory/AnnotationPropertyNameCollectionFactory.php +++ b/src/Metadata/Property/Factory/AnnotationPropertyNameCollectionFactory.php @@ -11,7 +11,7 @@ namespace ApiPlatform\Core\Metadata\Property\Factory; -use ApiPlatform\Core\Annotation\Property; +use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Exception\ResourceClassNotFoundException; use ApiPlatform\Core\Metadata\Property\PropertyNameCollection; use ApiPlatform\Core\Util\Reflection; @@ -62,7 +62,7 @@ public function create(string $resourceClass, array $options = []) : PropertyNam // Properties foreach ($reflectionClass->getProperties() as $reflectionProperty) { - if ($this->reader->getPropertyAnnotation($reflectionProperty, Property::class)) { + if ($this->reader->getPropertyAnnotation($reflectionProperty, ApiProperty::class)) { $propertyNames[$reflectionProperty->name] = true; } } @@ -71,7 +71,7 @@ public function create(string $resourceClass, array $options = []) : PropertyNam foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { $propertyName = $this->reflection->getProperty($reflectionMethod->name); - if ($propertyName && $this->reader->getMethodAnnotation($reflectionMethod, Property::class)) { + if ($propertyName && $this->reader->getMethodAnnotation($reflectionMethod, ApiProperty::class)) { $propertyNames[$propertyName] = true; } } diff --git a/tests/Annotation/PropertyTest.php b/tests/Annotation/PropertyTest.php index 5a358a3bdc6..b2f3be01a55 100644 --- a/tests/Annotation/PropertyTest.php +++ b/tests/Annotation/PropertyTest.php @@ -11,7 +11,7 @@ namespace ApiPlatform\Core\Tests\Annotation; -use ApiPlatform\Core\Annotation\Property; +use ApiPlatform\Core\Annotation\ApiProperty; /** * @author Kévin Dunglas @@ -20,7 +20,7 @@ class PropertyTest extends \PHPUnit_Framework_TestCase { public function testAssignation() { - $property = new Property(); + $property = new ApiProperty(); $property->description = 'description'; $property->readable = true; $property->writable = true; diff --git a/tests/Fixtures/TestBundle/Entity/AbstractDummy.php b/tests/Fixtures/TestBundle/Entity/AbstractDummy.php index 4ca50f61c4c..9c975e83d6d 100644 --- a/tests/Fixtures/TestBundle/Entity/AbstractDummy.php +++ b/tests/Fixtures/TestBundle/Entity/AbstractDummy.php @@ -11,9 +11,9 @@ namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; +use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Annotation\Iri; -use ApiPlatform\Core\Annotation\Property; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -44,7 +44,7 @@ abstract class AbstractDummy * * @ORM\Column * @Assert\NotBlank - * @Property(iri="http://schema.org/name") + * @ApiProperty(iri="http://schema.org/name") */ private $name; diff --git a/tests/Fixtures/TestBundle/Entity/CustomNormalizedDummy.php b/tests/Fixtures/TestBundle/Entity/CustomNormalizedDummy.php index 9214be95fbb..df508b049fc 100644 --- a/tests/Fixtures/TestBundle/Entity/CustomNormalizedDummy.php +++ b/tests/Fixtures/TestBundle/Entity/CustomNormalizedDummy.php @@ -11,8 +11,8 @@ namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; +use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiResource; -use ApiPlatform\Core\Annotation\Property; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -44,7 +44,7 @@ class CustomNormalizedDummy * * @ORM\Column * @Assert\NotBlank - * @Property(iri="http://schema.org/name") + * @ApiProperty(iri="http://schema.org/name") * @Groups({"input", "output"}) */ private $name; @@ -53,7 +53,7 @@ class CustomNormalizedDummy * @var string The dummy name alias. * * @ORM\Column(nullable=true) - * @Property(iri="https://schema.org/alternateName") + * @ApiProperty(iri="https://schema.org/alternateName") * @Groups({"input", "output"}) */ private $alias; diff --git a/tests/Fixtures/TestBundle/Entity/Dummy.php b/tests/Fixtures/TestBundle/Entity/Dummy.php index f5d76c1ba3a..4812a7486b2 100644 --- a/tests/Fixtures/TestBundle/Entity/Dummy.php +++ b/tests/Fixtures/TestBundle/Entity/Dummy.php @@ -11,8 +11,8 @@ namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; +use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiResource; -use ApiPlatform\Core\Annotation\Property; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -41,7 +41,7 @@ class Dummy * * @ORM\Column * @Assert\NotBlank - * @Property(iri="http://schema.org/name") + * @ApiProperty(iri="http://schema.org/name") */ private $name; @@ -49,7 +49,7 @@ class Dummy * @var string The dummy name alias. * * @ORM\Column(nullable=true) - * @Property(iri="https://schema.org/alternateName") + * @ApiProperty(iri="https://schema.org/alternateName") */ private $alias; @@ -62,7 +62,7 @@ class Dummy * @var string A short description of the item. * * @ORM\Column(nullable=true) - * @Property(iri="https://schema.org/description") + * @ApiProperty(iri="https://schema.org/description") */ public $description;