Skip to content

Commit

Permalink
Add return type hints to phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Oct 13, 2021
1 parent e62b760 commit 4bc1274
Show file tree
Hide file tree
Showing 36 changed files with 281 additions and 66 deletions.
5 changes: 5 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/AbstractBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ abstract protected function getExtraPipelineFields(): array;
*/
abstract protected function getStageName(): string;

/**
* @param array|mixed|string $expression
*
* @return array|mixed|string
*/
private function convertExpression($expression)
{
if (is_array($expression)) {
Expand Down
11 changes: 6 additions & 5 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ private function fromReference(string $fieldName): self
return $this;
}

/**
* @param array|mixed|string $expression
*
* @return array|mixed|string
*/
private function convertExpression($expression)
{
if (is_array($expression)) {
Expand All @@ -290,12 +295,8 @@ private function convertExpression($expression)
return Type::convertPHPToDatabaseValue(Expr::convertExpression($expression));
}

private function convertTargetFieldName($fieldName)
private function convertTargetFieldName(string $fieldName): string
{
if (is_array($fieldName)) {
return array_map([$this, 'convertTargetFieldName'], $fieldName);
}

if (! $this->targetClass) {
return $fieldName;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Stage/ReplaceRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public function getExpression(): array
];
}

/**
* @param array|string|mixed $expression
*
* @return array|string|mixed
*/
private function convertExpression($expression)
{
if (is_array($expression)) {
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Iterator/PrimingIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function toArray(): array
return iterator_to_array($this);
}

/**
* {@inheritDoc}
*/
public function current()
{
$this->primeReferences();
Expand All @@ -73,6 +76,9 @@ public function next(): void
$this->iterator->next();
}

/**
* {@inheritDoc}
*/
public function key()
{
return $this->iterator->key();
Expand Down
3 changes: 3 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
*/
class AnnotationDriver extends AbstractAnnotationDriver
{
/**
* {@inheritDoc}
*/
public function isTransient($className)
{
$classAnnotations = $this->reader->getClassAnnotations(new ReflectionClass($className));
Expand Down
9 changes: 9 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Mapping/Driver/AttributeReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function getClassAnnotations(ReflectionClass $class): array
return $this->convertToAttributeInstances($class->getAttributes());
}

/**
* {@inheritDoc}
*/
public function getClassAnnotation(ReflectionClass $class, $annotationName)
{
foreach ($this->getClassAnnotations($class) as $annotation) {
Expand All @@ -41,6 +44,9 @@ public function getMethodAnnotations(ReflectionMethod $method): array
return $this->convertToAttributeInstances($method->getAttributes());
}

/**
* {@inheritDoc}
*/
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
{
foreach ($this->getMethodAnnotations($method) as $annotation) {
Expand All @@ -57,6 +63,9 @@ public function getPropertyAnnotations(ReflectionProperty $property): array
return $this->convertToAttributeInstances($property->getAttributes());
}

/**
* {@inheritDoc}
*/
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
{
foreach ($this->getPropertyAnnotations($property) as $annotation) {
Expand Down
Loading

0 comments on commit 4bc1274

Please sign in to comment.