Commit 6d6f97e9 authored by Fabien Potencier's avatar Fabien Potencier

Merge branch '1.3'

* 1.3:
  Phpdocs
  Have `Controller::generateRouteName()` always put the method first.

Conflicts:
	src/Silex/ControllerCollection.php
	src/Silex/EventListener/LogListener.php
	src/Silex/ExceptionListenerWrapper.php
	src/Silex/Provider/SerializerServiceProvider.php
	tests/Silex/Tests/LazyUrlMatcherTest.php
parents 306eea94 fde7db80
......@@ -107,12 +107,15 @@ class Controller
public function generateRouteName($prefix)
{
$methods = implode('_', $this->route->getMethods());
$methods = implode('_', $this->route->getMethods()).'_';
$routeName = $prefix.$methods.$this->route->getPath();
$routeName = $methods.$prefix.$this->route->getPath();
$routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName);
$routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName);
// Collapse consecutive underscores down into a single underscore.
$routeName = preg_replace('/_+/', '_', $routeName);
return $routeName;
}
}
......@@ -43,10 +43,6 @@ class ControllerCollection
protected $defaultController;
protected $prefix;
/**
* Constructor.
* @param Route $defaultRoute
*/
public function __construct(Route $defaultRoute)
{
$this->defaultRoute = $defaultRoute;
......
......@@ -111,6 +111,9 @@ class LogListener implements EventSubscriberInterface
$this->logger->log(LogLevel::DEBUG, $message);
}
/**
* Logs an exception.
*/
protected function logException(\Exception $e)
{
$this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), array('exception' => $e));
......
......@@ -30,8 +30,8 @@ class ExceptionListenerWrapper
/**
* Constructor.
*
* @param Application $app An Application instance
* @param callable $callback
* @param Application $app An Application instance
* @param callable $callback
*/
public function __construct(Application $app, $callback)
{
......
......@@ -22,7 +22,7 @@ use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseRedirectable
class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
{
/**
* @see RedirectableUrlMatcherInterface::match()
* {@inheritdoc}
*/
public function redirect($path, $route, $scheme = null)
{
......
......@@ -28,12 +28,10 @@ use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
class SerializerServiceProvider implements ServiceProviderInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*
* This method registers a serializer service. {@link http://api.symfony.com/master/Symfony/Component/Serializer/Serializer.html
* The service is provided by the Symfony Serializer component}.
*
* @param Pimple $app
*/
public function register(Container $app)
{
......
......@@ -40,7 +40,7 @@ class CallbackResolverTest extends \PHPUnit_Framework_Testcase
}
/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Service "some_service" does not exist.
*/
public function testShouldThrowAnExceptionIfServiceIsMissing()
......
......@@ -64,7 +64,7 @@ class CallbackServicesTest extends \PHPUnit_Framework_TestCase
public function controller(Application $app)
{
return $app->abort(404);
$app->abort(404);
}
public function before()
......
......@@ -31,7 +31,7 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException Silex\Exception\ControllerFrozenException
* @expectedException \Silex\Exception\ControllerFrozenException
*/
public function testBindOnFrozenControllerShouldThrowException()
{
......@@ -80,10 +80,10 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provideRouteAndExpectedRouteName
*/
public function testDefaultRouteNameGeneration(Route $route, $expectedRouteName)
public function testDefaultRouteNameGeneration(Route $route, $prefix, $expectedRouteName)
{
$controller = new Controller($route);
$controller->bind($controller->generateRouteName(''));
$controller->bind($controller->generateRouteName($prefix));
$this->assertEquals($expectedRouteName, $controller->getRouteName());
}
......@@ -91,10 +91,11 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
public function provideRouteAndExpectedRouteName()
{
return array(
array(new Route('/Invalid%Symbols#Stripped', array(), array(), array(), '', array(), array('POST')), 'POST_InvalidSymbolsStripped'),
array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), 'GET_post_id'),
array(new Route('/colon:pipe|dashes-escaped'), '_colon_pipe_dashes_escaped'),
array(new Route('/underscores_and.periods'), '_underscores_and.periods'),
array(new Route('/Invalid%Symbols#Stripped', array(), array(), array(), '', array(), array('POST')), '', 'POST_InvalidSymbolsStripped'),
array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), '', 'GET_post_id'),
array(new Route('/colon:pipe|dashes-escaped'), '', '_colon_pipe_dashes_escaped'),
array(new Route('/underscores_and.periods'), '', '_underscores_and.periods'),
array(new Route('/post/{id}', array(), array(), array(), '', array(), array('GET')), 'prefix', 'GET_prefix_post_id'),
);
}
......
......@@ -159,7 +159,7 @@ class MonologServiceProviderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Provided logging level 'foo' does not exist. Must be a valid monolog logging level.
*/
public function testNonExistentStringErrorLevel()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment