Skip to content

Commit

Permalink
Allow null as return type
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Mar 29, 2021
1 parent a3044b7 commit ad8dae7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/FieldDescription/TypeGuesserChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(array $guessers)
$this->guessers = array_merge(...$allGuessers);
}

public function guess(FieldDescriptionInterface $fieldDescription): TypeGuess
public function guess(FieldDescriptionInterface $fieldDescription): ?TypeGuess
{
$guesses = [];

Expand All @@ -69,7 +69,10 @@ public function guess(FieldDescriptionInterface $fieldDescription): TypeGuess
));
}

$guesses[] = $guesser->guess($fieldDescription);
$guess = $guesser->guess($fieldDescription);
if (null !== $guess) {
$guesses[] = $guess;
}
}

return TypeGuess::getBestGuess($guesses);
Expand Down
2 changes: 1 addition & 1 deletion src/FieldDescription/TypeGuesserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

interface TypeGuesserInterface
{
public function guess(FieldDescriptionInterface $fieldDescription): TypeGuess;
public function guess(FieldDescriptionInterface $fieldDescription): ?TypeGuess;
}

0 comments on commit ad8dae7

Please sign in to comment.