schmittjoh / JMSI18nRoutingBundle

Allows you to internationalize your routing
http://jmsyst.com/bundles/JMSI18nRoutingBundle
358 stars 159 forks source link

Compatibility issues with Symfony\Component\Routing\Router functions #253

Open atjsd opened 2 years ago

atjsd commented 2 years ago

In an effort to try and fix deprecation warnings after upgrading my project to Symfony 5.4, I was able to replace the deprecated Router Annotations from the FrameworkExtraBundle with the Symfony\Component\Routing\Annotation\Route from the sensio/framework-bundle.

However, doing so causes issues with this bundle:

PHP Fatal error: Declaration of JMS\I18nRoutingBundle\Router\I18nRouter::generate(string $name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) must be compatible with Symfony\Component\Routing\Router::generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string in /var/www/atjwp/vendor/jms/i18n-routing-bundle/JMS/I18nRoutingBundle/Router/I18nRouter.php on line 100 Symfony\Component\ErrorHandler\Error\FatalError

Declaration of JMS\I18nRoutingBundle\Router\I18nRouter::match($url) must be compatible with Symfony\Component\Routing\Router::match(string $pathinfo): array

Declaration of JMS\I18nRoutingBundle\Router\I18nRouter::matchRequest(Symfony\Component\HttpFoundation\Request $request) must be compatible with Symfony\Component\Routing\Router::matchRequest(Symfony\Component\HttpFoundation\Request $request): array

The fix is relatively straightforward, and I have managed to get it to work locally. The fix involves adding return types and types for the function arguments to the generate(), match() and matchRequest() functions.

However, I am not sure if there might be a valid reason why these fixes weren't implemented yet? If not, I have created a PR (https://github.com/schmittjoh/JMSI18nRoutingBundle/pull/254), but I can't seem to find a way to link it to this issue.