Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated integration test? #93

Open
StudioMaX opened this issue Jun 1, 2020 · 0 comments
Open

Outdated integration test? #93

StudioMaX opened this issue Jun 1, 2020 · 0 comments

Comments

@StudioMaX
Copy link

Hey!
I've tries to fix a few deprecations with MicroKernelTrait in my code after updating to Symfony 5.1 and tried to see how this was fixed in custom bundles.
Look here:

if (method_exists(AbstractWebpackEncoreIntegrationTestKernel::class, 'configureRouting')) {
class WebpackEncoreIntegrationTestKernel extends AbstractWebpackEncoreIntegrationTestKernel {
protected function configureRouting(RoutingConfigurator $routes): void
{
$routes->add('/foo', 'kernel:'.(parent::VERSION_ID >= 40100 ? ':' : '').'renderFoo');
}
}
} else {
class WebpackEncoreIntegrationTestKernel extends AbstractWebpackEncoreIntegrationTestKernel {
protected function configureRoutes(RouteCollectionBuilder $routes)
{
$routes->add('/foo', 'kernel:'.(parent::VERSION_ID >= 40100 ? ':' : '').'renderFoo');
}
}
}

configureRouting(RoutingConfigurator $routes) will be implemented when configureRouting will exist, or configureRoutes(RouteCollectionBuilder $routes) when it does not exist.

Looks like this configureRouting was implemented here (probably in some of 5.1-dev), but then it was reverted here (when Symfony 5.1 was released).

So, configureRouting will never actually exist, and method configureRoutes(RouteCollectionBuilder $routes) will always be implemented.

But RouteCollectionBuilder was deprecated since 5.1 and we must use some sort of

if (^5.1) {
    protected function configureRoutes(RoutingConfigurator $routes): void { ... }
} else {
    protected function configureRoutes(RouteCollectionBuilder $routes) { ... }
}

We cannot simply omit the type declaration (protected function configureRoutes($routes)), as it is checked by the BC layer:
https://github.com/symfony/symfony/blob/e5b5d9ea14ef8141c20b79bbeaae360f1afbdc55/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php#L168-L174

Do you have any ideas how to check this without using version comparison?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant