Skip to content

Commit

Permalink
minor #34299 [Routing] revert the return type for UrlGeneratorInterfa…
Browse files Browse the repository at this point in the history
…ce::generate to remove null (shieldo)

This PR was merged into the 3.4 branch.

Discussion
----------

[Routing] revert the return type for UrlGeneratorInterface::generate to remove null

…to remove null

| Q             | A
| ------------- | ---
| Branch?       | 3.4 (only)
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| License       | MIT

Bit of a casualty of commit tennis this:

A change to add `null` here as an option for how `UrlGeneratorInterface::generate()` (rather than the concrete `UrlGenerator`) was merged in #28321, but then [reverted](90494c2) for the reason [that this could be seen as a BC break](#28321 (comment)), as the `null` return had not previously been documented (and is still not as part of the interface method docs).

However, in a subsequent change (#33252) with a wider scope, this doc change was added _back_ in order to reflect the underlying implementation as a result of a PHPStorm plugin complaining. There's no indication though of what a `null` return here though would mean, and for the same reason as the first revert (that this should be seen as a BC break), I'd like to submit this to be reverted for the 3.4 branch. (In 4.4 the `null` has already been removed.)

Having the interface indicating that this method can return `null` necessitates introducing a lot of actually redundant null checks in code that is covered by static analysis tools such as PHPStan.

Commits
-------

9f853f3 [Routing] revert the return type for UrlGeneratorInterface::generate to remove null
  • Loading branch information
fabpot committed Nov 9, 2019
2 parents 98e9fc8 + 9f853f3 commit 4463791
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -75,7 +75,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
* @param mixed[] $parameters An array of parameters
* @param int $referenceType The type of reference to be generated (one of the constants)
*
* @return string|null The generated URL
* @return string The generated URL
*
* @throws RouteNotFoundException If the named route doesn't exist
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
Expand Down

0 comments on commit 4463791

Please sign in to comment.