From 92f9c1561b89b5bb2754257b41a5fa28f32ab990 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 25 Apr 2012 03:25:08 +0200 Subject: [PATCH] [Routing] changed CompiledRoute signature to be more consistent --- src/Symfony/Component/Routing/CompiledRoute.php | 10 +++++----- src/Symfony/Component/Routing/RouteCompiler.php | 6 +++--- .../Component/Routing/Tests/CompiledRouteTest.php | 10 +++++----- .../Component/Routing/Tests/RouteCompilerTest.php | 2 -- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index b6a7995566..62d21c37bd 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -33,22 +33,22 @@ class CompiledRoute * @param string $staticPrefix The static prefix of the compiled route * @param string $regex The regular expression to use to match this route * @param array $tokens An array of tokens to use to generate URL for this route - * @param array $variables An array of variables (variables defined in the path and in the hostname patterns) * @param array $pathVariables An array of path variables - * @param array $hostnameVariables An array of hostname variables * @param array $hostnameRegex Hostname regex * @param array $hostnameTokens Hostname tokens + * @param array $hostnameVariables An array of hostname variables + * @param array $variables An array of variables (variables defined in the path and in the hostname patterns) */ - public function __construct($staticPrefix, $regex, array $tokens, array $variables, array $pathVariables = array(), array $hostnameVariables = array(), $hostnameRegex = null, array $hostnameTokens = array()) + public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostnameRegex = null, array $hostnameTokens = array(), array $hostnameVariables = array(), array $variables = array()) { $this->staticPrefix = $staticPrefix; $this->regex = $regex; $this->tokens = $tokens; - $this->variables = $variables; $this->pathVariables = $pathVariables; - $this->hostnameVariables = $hostnameVariables; $this->hostnameRegex = $hostnameRegex; $this->hostnameTokens = $hostnameTokens; + $this->hostnameVariables = $hostnameVariables; + $this->variables = $variables; } /** diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index 418303d138..b57e0ed657 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -73,11 +73,11 @@ class RouteCompiler implements RouteCompilerInterface $staticPrefix, $regex, $tokens, - array_unique($variables), $pathVariables, - $hostnameVariables, $hostnameRegex, - $hostnameTokens + $hostnameTokens, + $hostnameVariables, + array_unique($variables) ); } diff --git a/src/Symfony/Component/Routing/Tests/CompiledRouteTest.php b/src/Symfony/Component/Routing/Tests/CompiledRouteTest.php index c65da0c6f2..215ebb707b 100644 --- a/src/Symfony/Component/Routing/Tests/CompiledRouteTest.php +++ b/src/Symfony/Component/Routing/Tests/CompiledRouteTest.php @@ -17,10 +17,10 @@ class CompiledRouteTest extends \PHPUnit_Framework_TestCase { public function testAccessors() { - $compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array('variables')); - $this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its first argument'); - $this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its second argument'); - $this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its third argument'); - $this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its forth argument'); + $compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), array(), array(), array(), array('variables')); + $this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument'); + $this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument'); + $this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument'); + $this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its ninth argument'); } } diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index d8827df58b..cb89265b68 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -194,8 +194,6 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($variables, $compiled->getVariables(), $name.' (variables)'); $this->assertEquals($pathVariables, $compiled->getPathVariables(), $name.' (path variables)'); $this->assertEquals($tokens, $compiled->getTokens(), $name.' (tokens)'); - - $this->assertEquals($hostnameRegex, str_replace(array("\n", ' '), '', $compiled->getHostnameRegex()), $name.' (hostname regex)'); $this->assertEquals($hostnameVariables, $compiled->getHostnameVariables(), $name.' (hostname variables)'); $this->assertEquals($hostnameTokens, $compiled->getHostnameTokens(), $name.' (hostname tokens)');