Skip to content

Commit

Permalink
minor #30869 [Validator] Define null return type for Constraint::getD…
Browse files Browse the repository at this point in the history
…efaultOption() (jaikdean)

This PR was submitted for the 4.2 branch but it was merged into the 3.4 branch instead (closes #30869).

Discussion
----------

[Validator] Define null return type for Constraint::getDefaultOption()

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The `Constraint::getDefaultOption()` method is documented with a return type of `string`, but has no `return` statement. This behaviour is expected, as the return value is compared against `null` elsewhere in the code, but the docblock causes problems with static analysis when extending this class.

This PR corrects the documented return type to `string|null` and adds an explicit `return null`.

Commits
-------

03987f2 Define null return type for Constraint::getDefaultOption()
  • Loading branch information
fabpot committed Apr 5, 2019
2 parents 69058e3 + 03987f2 commit d45ecef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Symfony/Component/Validator/Constraint.php
Expand Up @@ -232,12 +232,13 @@ public function addImplicitGroupName($group)
*
* Override this method to define a default option.
*
* @return string
* @return string|null
*
* @see __construct()
*/
public function getDefaultOption()
{
return null;
}

/**
Expand Down

0 comments on commit d45ecef

Please sign in to comment.