Skip to content

Commit b01b78c

Browse files
Turn @method annotations into real method declarations
1 parent 351349c commit b01b78c

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

Kernel/MicroKernelTrait.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2121
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
2222
use Symfony\Component\Routing\RouteCollection;
23-
use Symfony\Component\Routing\RouteCollectionBuilder;
2423

2524
/**
2625
* A Kernel that provides configuration hooks.
2726
*
2827
* @author Ryan Weaver <[email protected]>
2928
* @author Fabien Potencier <[email protected]>
3029
*
31-
* @method void configureRoutes(RoutingConfigurator $routes)
3230
* @method void configureContainer(ContainerConfigurator $container)
3331
*/
3432
trait MicroKernelTrait
@@ -42,7 +40,7 @@ trait MicroKernelTrait
4240
* ->controller('App\Controller\AdminController::dashboard')
4341
* ;
4442
*/
45-
//abstract protected function configureRoutes(RoutingConfigurator $routes): void;
43+
abstract protected function configureRoutes(RoutingConfigurator $routes): void;
4644

4745
/**
4846
* Configures the container.
@@ -174,23 +172,6 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection
174172
$kernelLoader->setCurrentDir(\dirname($file));
175173
$collection = new RouteCollection();
176174

177-
try {
178-
$configureRoutes = new \ReflectionMethod($this, 'configureRoutes');
179-
} catch (\ReflectionException $e) {
180-
throw new \LogicException(sprintf('"%s" uses "%s", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".', get_debug_type($this), MicroKernelTrait::class), 0, $e);
181-
}
182-
183-
$configuratorClass = $configureRoutes->getNumberOfParameters() > 0 && ($type = $configureRoutes->getParameters()[0]->getType()) instanceof \ReflectionNamedType && !$type->isBuiltin() ? $type->getName() : null;
184-
185-
if ($configuratorClass && !is_a(RoutingConfigurator::class, $configuratorClass, true)) {
186-
trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class);
187-
188-
$routes = new RouteCollectionBuilder($loader);
189-
$this->configureRoutes($routes);
190-
191-
return $routes->build();
192-
}
193-
194175
$this->configureRoutes(new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment()));
195176

196177
foreach ($collection as $route) {

Tests/Kernel/MicroKernelTraitTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,6 @@ protected function configureRoutes(RoutingConfigurator $routes): void
140140

141141
$kernel->boot();
142142
}
143-
144-
public function testMissingConfigureRoutes()
145-
{
146-
$kernel = new class('missing_configure_routes') extends MinimalKernel {
147-
protected function configureContainer(ContainerConfigurator $c): void
148-
{
149-
$c->extension('framework', [
150-
'router' => ['utf8' => true],
151-
]);
152-
}
153-
};
154-
155-
$this->expectException(\LogicException::class);
156-
$this->expectExceptionMessage('"Symfony\Bundle\FrameworkBundle\Tests\Kernel\MinimalKernel@anonymous" uses "Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".');
157-
158-
$request = Request::create('/');
159-
$kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, false);
160-
}
161143
}
162144

163145
abstract class MinimalKernel extends Kernel

0 commit comments

Comments
 (0)