symfony-cmf / Routing

Routing component building on the Symfony Routing component
Other
289 stars 70 forks source link

Wrong type hint for ChainRouter::generate #236

Closed korsarNek closed 4 years ago

korsarNek commented 5 years ago

symfony-cmf/routing 2.1.0

Problem

The ChainRouter::generate function uses inheritdoc for the base PHPDoc, but UrlGeneratorInterace::generate says that name must be a string. While with ChainRouter::generate it could be anything.

That is a problem if tools are used that check the PHPDoc types too to validate code, like PHPStan.

Steps to reproduce

I don't have an example project right now, but having a project with PHPStan enabled and using the ChainRouter::generate function from anywhere should show the same error.

Expected results

The ChainRouter::generate function should change the $name parameter type to mixed.

Actual results

PHPStan shows this error:

Parameter #1 $name of method eZ\Publish\Core\MVC\Symfony\Routing\ChainRouter::generate() expects string, eZ\Publish\API\Repository\Values\Content\Location given.

The eZ\Publish ChainRouter itself has no PHPDoc, it is taken from the UrlGeneratorInterface.

dbu commented 5 years ago

please do a pull request to change the UrlGeneratorInterface phpdoc (and try it out in your project to be sure it works correctly). i am not sure how well phpstan solves such disagreements between phpdoc for the same method, but i guess it should work.

korsarNek commented 5 years ago

I've created the pull request, unfortunately PHPStan can not handle merging of PHPDocs, so I copied the PHPDoc from the UrlGeneratorInterface and modified it a bit.

dbu commented 4 years ago

i fixed this in #252