Skip to content

Commit

Permalink
Add more types/type-hints (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Sep 15, 2022
1 parent ba59b04 commit 01c25b9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Analysers/ComposerAutoloaderScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
class ComposerAutoloaderScanner
{
/**
* Collect all classes/interfaces/traits known by autoloaders.
* Collect all classes/interfaces/traits known by composer.
*
* @param array<string> $namespaces
*
* @return array<string>
*/
public function scan(array $namespaces): array
{
Expand Down
9 changes: 8 additions & 1 deletion src/Analysers/DocBlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace OpenApi\Analysers;

use Doctrine\Common\Annotations\DocParser;
use OpenApi\Annotations\AbstractAnnotation;
use OpenApi\Context;
use OpenApi\Generator;

Expand All @@ -20,6 +21,9 @@ class DocBlockParser
*/
protected $docParser;

/**
* @param array<string, class-string> $aliases
*/
public function __construct(array $aliases = [])
{
$docParser = new DocParser();
Expand All @@ -28,6 +32,9 @@ public function __construct(array $aliases = [])
$this->docParser = $docParser;
}

/**
* @param array<string, class-string> $aliases
*/
public function setAliases(array $aliases): void
{
$this->docParser->setImports($aliases);
Expand All @@ -39,7 +46,7 @@ public function setAliases(array $aliases): void
* @param string $comment a T_DOC_COMMENT
* @param Context $context
*
* @return array Annotations
* @return array<AbstractAnnotation>
*/
public function fromComment(string $comment, Context $context): array
{
Expand Down
3 changes: 3 additions & 0 deletions src/Analysers/ReflectionAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class ReflectionAnalyser implements AnalyserInterface
/** @var Generator|null */
protected $generator;

/**
* @param array<AnnotationFactoryInterface> $annotationFactories
*/
public function __construct(array $annotationFactories = [])
{
$this->annotationFactories = $annotationFactories;
Expand Down
3 changes: 3 additions & 0 deletions src/Analysers/TokenScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ protected function nextToken(array &$tokens)
return $token;
}

/**
* @return array<string>
*/
protected function resolveFQN(array $names, string $namespace, array $uses): array
{
$resolve = function ($name) use ($namespace, $uses) {
Expand Down
2 changes: 1 addition & 1 deletion src/Annotations/Attachable.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Attachable extends AbstractAnnotation
* Container to allow custom annotations that are limited to a subset of potential parent
* annotation classes.
*
* @return array List of valid parent annotation classes. If `null`` the default nesting rules apply.
* @return array<class-string>|null List of valid parent annotation classes. If `null`, the default nesting rules apply.
*/
public function allowedParents(): ?array
{
Expand Down
6 changes: 6 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public static function isDefault($value): bool
return $value === Generator::UNDEFINED;
}

/**
* @return array<string>
*/
public function getAliases(): array
{
return $this->aliases;
Expand All @@ -148,6 +151,9 @@ public function setAliases(array $aliases): Generator
return $this;
}

/**
* @return array<string>|null
*/
public function getNamespaces(): ?array
{
return $this->namespaces;
Expand Down

0 comments on commit 01c25b9

Please sign in to comment.