Skip to content

Commit

Permalink
minor #32233 [PropertyInfo] Add type-hints to public interfaces and c…
Browse files Browse the repository at this point in the history
…lasses (jschaedl)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[PropertyInfo] Add type-hints to public interfaces and classes

| Q             | A
| ------------- | ---
| Branch?       | master <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #32179  <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A <!-- required for new features -->

This PR adds type hints to public interfaces and classes of the PropertyInfo component. Some docblocks without valuable information got also removed.

Commits
-------

fe3b165 [PropertyInfo] Add type-hints to public interfaces and classes
  • Loading branch information
fabpot committed Jun 29, 2019
2 parents bac35b0 + fe3b165 commit f2b261d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 49 deletions.
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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 = []);
}
Expand Up @@ -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 = []);
}
Expand Up @@ -35,47 +35,47 @@ 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]);
}

/**
* {@inheritdoc}
*/
public function isWritable($class, $property, array $context = [])
public function isWritable(string $class, string $property, array $context = [])
{
return $this->extract('isWritable', [$class, $property, $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]);
}

/**
* {@inheritdoc}
*/
public function getLongDescription($class, $property, array $context = [])
public function getLongDescription(string $class, string $property, array $context = [])
{
return $this->extract('getLongDescription', [$class, $property, $context]);
}

/**
* {@inheritdoc}
*/
public function getProperties($class, array $context = [])
public function getProperties(string $class, array $context = [])
{
return $this->extract('getProperties', [$class, $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]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php
Expand Up @@ -45,47 +45,47 @@ 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]);
}

/**
* {@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]);
}

/**
* {@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]);
}

/**
* {@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]);
}

/**
* {@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]);
}

/**
* {@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]);
}
Expand Down
Expand Up @@ -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 = []);
}
Expand Up @@ -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 = []);
}

0 comments on commit f2b261d

Please sign in to comment.