[PP-1] Fix phpdoc return type for RouteProvider::getAllRoutes()

Created on 23 July 2020, over 4 years ago
Updated 7 May 2023, almost 2 years ago

Problem/Motivation

#3158708: RouteProvider::getAllRoutes no longer returns an iterable, breaking BC fixed a BC break introduced in #2917331: Decouple from Symfony CMF that changed the return type for RouteProvider::getAllRoutes().

It used to return an Iterator. Then #2917331 changed it to an array. Then #3158708 changed it back.

However, the PHPDoc comment says:

   * @return \Symfony\Component\Routing\Route[]
   *   An iterator of routes keyed by route name.

I thought [] meant an array, not an Iterator. How do you tell the difference in PHPDoc comments?

Related docs
- https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iter...
- https://psalm.dev/docs/annotating_code/templated_annotations/#builtin-te...
- https://github.com/JetBrains/phpstorm-stubs/commit/89f6911ddcc89dd6497ab...

Proposed resolution

Properly document RouteProvider::getAllRoutes() that it returns an Iterator, not an array.

The correct syntax would be:

@return \Iterator<string, \Symfony\Component\Routing\Route>

However, unfortunately core's coder sniffs don't understand that syntax (yet).

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Postponed

Version

10.1

Component
Routing 

Last updated 2 days ago

Created by

🇺🇸United States dww

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024