From fe3b165354acf709e0f9e34dceab43121fc360c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Thu, 27 Jun 2019 22:40:09 +0200 Subject: [PATCH] [PropertyInfo] Add type-hints to public interfaces and classes --- .../PropertyInfo/Extractor/PhpDocExtractor.php | 6 +++--- .../PropertyInfo/Extractor/ReflectionExtractor.php | 8 ++++---- .../PropertyInfo/Extractor/SerializerExtractor.php | 2 +- .../PropertyAccessExtractorInterface.php | 12 ++---------- .../PropertyDescriptionExtractorInterface.php | 12 ++---------- .../PropertyInfo/PropertyInfoCacheExtractor.php | 12 ++++++------ .../Component/PropertyInfo/PropertyInfoExtractor.php | 12 ++++++------ .../PropertyInfo/PropertyListExtractorInterface.php | 5 +---- .../PropertyInfo/PropertyTypeExtractorInterface.php | 6 +----- 9 files changed, 26 insertions(+), 49 deletions(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 4837d2200c85..69ee61a2ce28 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -68,7 +68,7 @@ public function __construct(DocBlockFactoryInterface $docBlockFactory = null, ar /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription(string $class, string $property, array $context = []) { /** @var $docBlock DocBlock */ list($docBlock) = $this->getDocBlock($class, $property); @@ -94,7 +94,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription(string $class, string $property, array $context = []) { /** @var $docBlock DocBlock */ list($docBlock) = $this->getDocBlock($class, $property); @@ -110,7 +110,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes(string $class, string $property, array $context = []) { /** @var $docBlock DocBlock */ list($docBlock, $source, $prefix) = $this->getDocBlock($class, $property); diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 3b0c01a2d97b..cc2f08e14326 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -75,7 +75,7 @@ public function __construct(array $mutatorPrefixes = null, array $accessorPrefix /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties(string $class, array $context = []) { try { $reflectionClass = new \ReflectionClass($class); @@ -131,7 +131,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes(string $class, $property, array $context = []) { if ($fromMutator = $this->extractFromMutator($class, $property)) { return $fromMutator; @@ -156,7 +156,7 @@ public function getTypes($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []): bool + public function isReadable(string $class, $property, array $context = []): bool { if ($this->isAllowedProperty($class, $property)) { return true; @@ -170,7 +170,7 @@ public function isReadable($class, $property, array $context = []): bool /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []): bool + public function isWritable(string $class, $property, array $context = []): bool { if ($this->isAllowedProperty($class, $property)) { return true; diff --git a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php index 98d75f0a9371..a126e37fbe6c 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php @@ -33,7 +33,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory) /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties(string $class, array $context = []) { if (!isset($context['serializer_groups']) || !\is_array($context['serializer_groups'])) { return; diff --git a/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php index 49d5afb032c4..f9ee787130c8 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyAccessExtractorInterface.php @@ -21,22 +21,14 @@ interface PropertyAccessExtractorInterface /** * Is the property readable? * - * @param string $class - * @param string $property - * @param array $context - * * @return bool|null */ - public function isReadable($class, $property, array $context = []); + public function isReadable(string $class, string $property, array $context = []); /** * Is the property writable? * - * @param string $class - * @param string $property - * @param array $context - * * @return bool|null */ - public function isWritable($class, $property, array $context = []); + public function isWritable(string $class, string $property, array $context = []); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php index 385e772b9f09..f37653753706 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyDescriptionExtractorInterface.php @@ -21,22 +21,14 @@ interface PropertyDescriptionExtractorInterface /** * Gets the short description of the property. * - * @param string $class - * @param string $property - * @param array $context - * * @return string|null */ - public function getShortDescription($class, $property, array $context = []); + public function getShortDescription(string $class, string $property, array $context = []); /** * Gets the long description of the property. * - * @param string $class - * @param string $property - * @param array $context - * * @return string|null */ - public function getLongDescription($class, $property, array $context = []); + public function getLongDescription(string $class, string $property, array $context = []); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index 0eb9f63a5485..1ac249e1b104 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -35,7 +35,7 @@ public function __construct(PropertyInfoExtractorInterface $propertyInfoExtracto /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []) + public function isReadable(string $class, string $property, array $context = []) { return $this->extract('isReadable', [$class, $property, $context]); } @@ -43,7 +43,7 @@ public function isReadable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []) + public function isWritable(string $class, string $property, array $context = []) { return $this->extract('isWritable', [$class, $property, $context]); } @@ -51,7 +51,7 @@ public function isWritable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription(string $class, string $property, array $context = []) { return $this->extract('getShortDescription', [$class, $property, $context]); } @@ -59,7 +59,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription(string $class, string $property, array $context = []) { return $this->extract('getLongDescription', [$class, $property, $context]); } @@ -67,7 +67,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties(string $class, array $context = []) { return $this->extract('getProperties', [$class, $context]); } @@ -75,7 +75,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes(string $class, string $property, array $context = []) { return $this->extract('getTypes', [$class, $property, $context]); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php index d7de8d2644a7..a6565c586748 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php @@ -45,7 +45,7 @@ public function __construct(iterable $listExtractors = [], iterable $typeExtract /** * {@inheritdoc} */ - public function getProperties($class, array $context = []) + public function getProperties(string $class, array $context = []) { return $this->extract($this->listExtractors, 'getProperties', [$class, $context]); } @@ -53,7 +53,7 @@ public function getProperties($class, array $context = []) /** * {@inheritdoc} */ - public function getShortDescription($class, $property, array $context = []) + public function getShortDescription(string $class, string $property, array $context = []) { return $this->extract($this->descriptionExtractors, 'getShortDescription', [$class, $property, $context]); } @@ -61,7 +61,7 @@ public function getShortDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getLongDescription($class, $property, array $context = []) + public function getLongDescription(string $class, string $property, array $context = []) { return $this->extract($this->descriptionExtractors, 'getLongDescription', [$class, $property, $context]); } @@ -69,7 +69,7 @@ public function getLongDescription($class, $property, array $context = []) /** * {@inheritdoc} */ - public function getTypes($class, $property, array $context = []) + public function getTypes(string $class, string $property, array $context = []) { return $this->extract($this->typeExtractors, 'getTypes', [$class, $property, $context]); } @@ -77,7 +77,7 @@ public function getTypes($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isReadable($class, $property, array $context = []) + public function isReadable(string $class, string $property, array $context = []) { return $this->extract($this->accessExtractors, 'isReadable', [$class, $property, $context]); } @@ -85,7 +85,7 @@ public function isReadable($class, $property, array $context = []) /** * {@inheritdoc} */ - public function isWritable($class, $property, array $context = []) + public function isWritable(string $class, string $property, array $context = []) { return $this->extract($this->accessExtractors, 'isWritable', [$class, $property, $context]); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php index 2c831731cf69..326e6cccb36a 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyListExtractorInterface.php @@ -21,10 +21,7 @@ interface PropertyListExtractorInterface /** * Gets the list of properties available for the given class. * - * @param string $class - * @param array $context - * * @return string[]|null */ - public function getProperties($class, array $context = []); + public function getProperties(string $class, array $context = []); } diff --git a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php index c970530f2e93..6da0bcb4c8a9 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php +++ b/src/Symfony/Component/PropertyInfo/PropertyTypeExtractorInterface.php @@ -21,11 +21,7 @@ interface PropertyTypeExtractorInterface /** * Gets types of a property. * - * @param string $class - * @param string $property - * @param array $context - * * @return Type[]|null */ - public function getTypes($class, $property, array $context = []); + public function getTypes(string $class, string $property, array $context = []); }