Fix a type hint issue in RouteDescriber

This commit is contained in:
Guilhem N 2016-11-30 16:08:49 +01:00
parent fd6d9ac7a7
commit f6f91562d9
No known key found for this signature in database
GPG Key ID: 9E5D2DB67BF054DD
2 changed files with 48 additions and 1 deletions

View File

@ -48,7 +48,7 @@ final class RouteDescriber implements DescriberInterface
foreach ($this->routeCollection->all() as $route) {
// if able to resolve the controller
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
if ($method = $this->getReflectionMethod($route->getDefault('_controller') ?? '')) {
// Extract as many informations as possible about this route
foreach ($this->routeDescribers as $describer) {
$describer->describe($api, $route, $method);

View File

@ -0,0 +1,47 @@
<?php
/*
* This file is part of the ApiDocBundle package.
*
* (c) EXSyst
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace EXSyst\Bundle\ApiDocBundle\Tests\Describer;
use EXSyst\Bundle\ApiDocBundle\Describer\RouteDescriber;
use EXSyst\Bundle\ApiDocBundle\RouteDescriber\RouteDescriberInterface;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use EXSyst\Component\Swagger\Swagger;
class RouteDescriberTest extends AbstractDescriberTest
{
private $routes;
private $routeDescriber;
public function testIgnoreWhenNoController()
{
$this->routes->add('foo', new Route('foo'));
$this->routeDescriber->expects($this->never())
->method('describe');
$this->assertEquals((new Swagger())->toArray(), $this->getSwaggerDoc()->toArray());
}
protected function setUp()
{
$this->routeDescriber = $this->createMock(RouteDescriberInterface::class);
$this->routes = new RouteCollection();
$this->describer = new RouteDescriber(
new Container(),
$this->routes,
$this->createMock(ControllerNameParser::class),
[ $this->routeDescriber ]
);
}
}