[Routing] changed CompiledRoute signature to be more consistent

This commit is contained in:
Fabien Potencier 2012-04-25 03:25:08 +02:00 committed by Arnaud Le Blanc
parent d91e5a26a2
commit 92f9c1561b
4 changed files with 13 additions and 15 deletions

View File

@ -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;
}
/**

View File

@ -73,11 +73,11 @@ class RouteCompiler implements RouteCompilerInterface
$staticPrefix,
$regex,
$tokens,
array_unique($variables),
$pathVariables,
$hostnameVariables,
$hostnameRegex,
$hostnameTokens
$hostnameTokens,
$hostnameVariables,
array_unique($variables)
);
}

View File

@ -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');
}
}

View File

@ -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)');