Skip to content
Browse files

merged branch Tobion/routing-pcre (PR #6064)

This PR was merged into the master branch.

Commits
-------

824a0f3 [Routing] compatibility with older PCRE (pre 8)

Discussion
----------

[Routing] compatibility with older PCRE (pre 8)

#6062 for master
  • Loading branch information...
2 parents cec11fa + 824a0f3 commit 077bd35f7b9f04cabd9dcbbf4cfd6e236a2ffe5d @fabpot fabpot committed
View
2 src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php
@@ -215,7 +215,7 @@ private function regexToApacheRegex($regex)
{
$regexPatternEnd = strrpos($regex, $regex[0]);
- return preg_replace('/\?<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1));
+ return preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1));
}
/**
View
2 src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
@@ -210,7 +210,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
- if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
+ if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
$hasTrailingSlash = true;
View
3 src/Symfony/Component/Routing/RouteCompiler.php
@@ -33,7 +33,7 @@ class RouteCompiler implements RouteCompilerInterface
*
* @throws \LogicException If a variable is referenced more than once
* @throws \DomainException If a variable name is numeric because PHP raises an error for such
- * subpatterns in PCRE and thus would break matching, e.g. "(?<123>.+)".
+ * subpatterns in PCRE and thus would break matching, e.g. "(?P<123>.+)".
*/
public function compile(Route $route)
{
@@ -82,7 +82,6 @@ public function compile(Route $route)
private function compilePattern(Route $route, $pattern, $isHostname)
{
- $len = strlen($pattern);
$tokens = array();
$variables = array();
$matches = array();
View
46 src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php
@@ -26,13 +26,13 @@ public function match($pathinfo)
$pathinfo = rawurldecode($pathinfo);
// foo
- if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
}
if (0 === strpos($pathinfo, '/bar')) {
// bar
- if (preg_match('#^/bar/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_bar;
@@ -43,7 +43,7 @@ public function match($pathinfo)
not_bar:
// barhead
- if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_barhead;
@@ -74,12 +74,12 @@ public function match($pathinfo)
}
// baz4
- if (preg_match('#^/test/(?<foo>[^/]++)/$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
}
// baz5
- if (preg_match('#^/test/(?<foo>[^/]++)/$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_baz5;
@@ -90,7 +90,7 @@ public function match($pathinfo)
not_baz5:
// baz.baz6
- if (preg_match('#^/test/(?<foo>[^/]++)/$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
if ($this->context->getMethod() != 'PUT') {
$allow[] = 'PUT';
goto not_bazbaz6;
@@ -108,7 +108,7 @@ public function match($pathinfo)
}
// quoter
- if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
}
@@ -120,30 +120,30 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/a')) {
if (0 === strpos($pathinfo, '/a/b\'b')) {
// foo1
- if (preg_match('#^/a/b\'b/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
}
// bar1
- if (preg_match('#^/a/b\'b/(?<bar>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
}
}
// overridden
- if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
}
if (0 === strpos($pathinfo, '/a/b\'b')) {
// foo2
- if (preg_match('#^/a/b\'b/(?<foo1>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
}
// bar2
- if (preg_match('#^/a/b\'b/(?<bar1>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
}
@@ -153,7 +153,7 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/multi')) {
// helloWorld
- if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]++))?$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
}
@@ -170,12 +170,12 @@ public function match($pathinfo)
}
// foo3
- if (preg_match('#^/(?<_locale>[^/]++)/b/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
}
// bar3
- if (preg_match('#^/(?<_locale>[^/]++)/b/(?<bar>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
}
@@ -186,7 +186,7 @@ public function match($pathinfo)
}
// foo4
- if (preg_match('#^/aba/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
}
@@ -236,7 +236,7 @@ public function match($pathinfo)
return array('_route' => 'route6');
}
- if (preg_match('#^(?<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
+ if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (0 === strpos($pathinfo, '/route1')) {
// route11
if ($pathinfo === '/route11') {
@@ -249,12 +249,12 @@ public function match($pathinfo)
}
// route13
- if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ());
}
// route14
- if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
}
@@ -264,7 +264,7 @@ public function match($pathinfo)
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
// route15
- if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
}
@@ -272,7 +272,7 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/route1')) {
// route16
- if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
}
@@ -291,12 +291,12 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/a/b')) {
// b
- if (preg_match('#^/a/b/(?<var>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
}
// c
- if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
}
View
46 src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php
@@ -26,13 +26,13 @@ public function match($pathinfo)
$pathinfo = rawurldecode($pathinfo);
// foo
- if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
}
if (0 === strpos($pathinfo, '/bar')) {
// bar
- if (preg_match('#^/bar/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_bar;
@@ -43,7 +43,7 @@ public function match($pathinfo)
not_bar:
// barhead
- if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
$allow = array_merge($allow, array('GET', 'HEAD'));
goto not_barhead;
@@ -79,7 +79,7 @@ public function match($pathinfo)
}
// baz4
- if (preg_match('#^/test/(?<foo>[^/]++)/?$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/?$#s', $pathinfo, $matches)) {
if (substr($pathinfo, -1) !== '/') {
return $this->redirect($pathinfo.'/', 'baz4');
}
@@ -88,7 +88,7 @@ public function match($pathinfo)
}
// baz5
- if (preg_match('#^/test/(?<foo>[^/]++)/$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
if ($this->context->getMethod() != 'POST') {
$allow[] = 'POST';
goto not_baz5;
@@ -99,7 +99,7 @@ public function match($pathinfo)
not_baz5:
// baz.baz6
- if (preg_match('#^/test/(?<foo>[^/]++)/$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
if ($this->context->getMethod() != 'PUT') {
$allow[] = 'PUT';
goto not_bazbaz6;
@@ -117,7 +117,7 @@ public function match($pathinfo)
}
// quoter
- if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
}
@@ -129,30 +129,30 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/a')) {
if (0 === strpos($pathinfo, '/a/b\'b')) {
// foo1
- if (preg_match('#^/a/b\'b/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
}
// bar1
- if (preg_match('#^/a/b\'b/(?<bar>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
}
}
// overridden
- if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
}
if (0 === strpos($pathinfo, '/a/b\'b')) {
// foo2
- if (preg_match('#^/a/b\'b/(?<foo1>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
}
// bar2
- if (preg_match('#^/a/b\'b/(?<bar1>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
}
@@ -162,7 +162,7 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/multi')) {
// helloWorld
- if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]++))?$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
}
@@ -183,12 +183,12 @@ public function match($pathinfo)
}
// foo3
- if (preg_match('#^/(?<_locale>[^/]++)/b/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
}
// bar3
- if (preg_match('#^/(?<_locale>[^/]++)/b/(?<bar>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
}
@@ -199,7 +199,7 @@ public function match($pathinfo)
}
// foo4
- if (preg_match('#^/aba/(?<foo>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
}
@@ -249,7 +249,7 @@ public function match($pathinfo)
return array('_route' => 'route6');
}
- if (preg_match('#^(?<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
+ if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#s', $hostname, $hostnameMatches)) {
if (0 === strpos($pathinfo, '/route1')) {
// route11
if ($pathinfo === '/route11') {
@@ -262,12 +262,12 @@ public function match($pathinfo)
}
// route13
- if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route13')), array ());
}
// route14
- if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($hostnameMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
}
@@ -277,7 +277,7 @@ public function match($pathinfo)
if (preg_match('#^c\\.example\\.com$#s', $hostname, $hostnameMatches)) {
// route15
- if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
}
@@ -285,7 +285,7 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/route1')) {
// route16
- if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?<name>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
}
@@ -304,12 +304,12 @@ public function match($pathinfo)
if (0 === strpos($pathinfo, '/a/b')) {
// b
- if (preg_match('#^/a/b/(?<var>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
}
// c
- if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]++)$#s', $pathinfo, $matches)) {
+ if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
}
View
2 src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php
@@ -32,7 +32,7 @@ public function match($pathinfo)
}
// dynamic
- if (preg_match('#^/rootprefix/(?<var>[^/]++)$#s', $pathinfo, $matches)) {
+ if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
}
View
32 src/Symfony/Component/Routing/Tests/RouteCompilerTest.php
@@ -43,7 +43,7 @@ public function provideCompileData()
array(
'Route with a variable',
array('/foo/{bar}'),
- '/foo', '#^/foo/(?<bar>[^/]++)$#s', array('bar'), array(
+ '/foo', '#^/foo/(?P<bar>[^/]++)$#s', array('bar'), array(
array('variable', '/', '[^/]++', 'bar'),
array('text', '/foo'),
)),
@@ -51,7 +51,7 @@ public function provideCompileData()
array(
'Route with a variable that has a default value',
array('/foo/{bar}', array('bar' => 'bar')),
- '/foo', '#^/foo(?:/(?<bar>[^/]++))?$#s', array('bar'), array(
+ '/foo', '#^/foo(?:/(?P<bar>[^/]++))?$#s', array('bar'), array(
array('variable', '/', '[^/]++', 'bar'),
array('text', '/foo'),
)),
@@ -59,7 +59,7 @@ public function provideCompileData()
array(
'Route with several variables',
array('/foo/{bar}/{foobar}'),
- '/foo', '#^/foo/(?<bar>[^/]++)/(?<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
+ '/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
array('variable', '/', '[^/]++', 'foobar'),
array('variable', '/', '[^/]++', 'bar'),
array('text', '/foo'),
@@ -68,7 +68,7 @@ public function provideCompileData()
array(
'Route with several variables that have default values',
array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')),
- '/foo', '#^/foo(?:/(?<bar>[^/]++)(?:/(?<foobar>[^/]++))?)?$#s', array('bar', 'foobar'), array(
+ '/foo', '#^/foo(?:/(?P<bar>[^/]++)(?:/(?P<foobar>[^/]++))?)?$#s', array('bar', 'foobar'), array(
array('variable', '/', '[^/]++', 'foobar'),
array('variable', '/', '[^/]++', 'bar'),
array('text', '/foo'),
@@ -77,7 +77,7 @@ public function provideCompileData()
array(
'Route with several variables but some of them have no default values',
array('/foo/{bar}/{foobar}', array('bar' => 'bar')),
- '/foo', '#^/foo/(?<bar>[^/]++)/(?<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
+ '/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
array('variable', '/', '[^/]++', 'foobar'),
array('variable', '/', '[^/]++', 'bar'),
array('text', '/foo'),
@@ -86,14 +86,14 @@ public function provideCompileData()
array(
'Route with an optional variable as the first segment',
array('/{bar}', array('bar' => 'bar')),
- '', '#^/(?<bar>[^/]++)?$#s', array('bar'), array(
+ '', '#^/(?P<bar>[^/]++)?$#s', array('bar'), array(
array('variable', '/', '[^/]++', 'bar'),
)),
array(
'Route with a requirement of 0',
array('/{bar}', array('bar' => null), array('bar' => '0')),
- '', '#^/(?<bar>0)?$#s', array('bar'), array(
+ '', '#^/(?P<bar>0)?$#s', array('bar'), array(
array('variable', '/', '0', 'bar'),
)),
@@ -107,7 +107,7 @@ public function provideCompileData()
array(
'Route with only optional variables',
array('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar')),
- '', '#^/(?<foo>[^/]++)?(?:/(?<bar>[^/]++))?$#s', array('foo', 'bar'), array(
+ '', '#^/(?P<foo>[^/]++)?(?:/(?P<bar>[^/]++))?$#s', array('foo', 'bar'), array(
array('variable', '/', '[^/]++', 'bar'),
array('variable', '/', '[^/]++', 'foo'),
)),
@@ -115,7 +115,7 @@ public function provideCompileData()
array(
'Route with a variable in last position',
array('/foo-{bar}'),
- '/foo', '#^/foo\-(?<bar>[^/]++)$#s', array('bar'), array(
+ '/foo', '#^/foo\-(?P<bar>[^/]++)$#s', array('bar'), array(
array('variable', '-', '[^/]++', 'bar'),
array('text', '/foo'),
)),
@@ -123,7 +123,7 @@ public function provideCompileData()
array(
'Route with nested placeholders',
array('/{static{var}static}'),
- '/{static', '#^/\{static(?<var>[^/]+)static\}$#s', array('var'), array(
+ '/{static', '#^/\{static(?P<var>[^/]+)static\}$#s', array('var'), array(
array('text', 'static}'),
array('variable', '', '[^/]+', 'var'),
array('text', '/{static'),
@@ -132,7 +132,7 @@ public function provideCompileData()
array(
'Route without separator between variables',
array('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '(y|Y)')),
- '', '#^/(?<w>[^/\.]+)(?<x>[^/\.]+)(?<y>(y|Y))(?:(?<z>[^/\.]++)(?:\.(?<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array(
+ '', '#^/(?P<w>[^/\.]+)(?P<x>[^/\.]+)(?P<y>(y|Y))(?:(?P<z>[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array(
array('variable', '.', '[^/]++', '_format'),
array('variable', '', '[^/\.]++', 'z'),
array('variable', '', '(y|Y)', 'y'),
@@ -143,7 +143,7 @@ public function provideCompileData()
array(
'Route with a format',
array('/foo/{bar}.{_format}'),
- '/foo', '#^/foo/(?<bar>[^/\.]++)\.(?<_format>[^/]++)$#s', array('bar', '_format'), array(
+ '/foo', '#^/foo/(?P<bar>[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array(
array('variable', '.', '[^/]++', '_format'),
array('variable', '/', '[^/\.]++', 'bar'),
array('text', '/foo'),
@@ -215,11 +215,11 @@ public function provideCompileWithHostnameData()
array(
'Route with hostname pattern and some variables',
array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'),
- '/hello', '#^/hello/(?<name>[^/]++)$#s', array('tld', 'name'), array('name'), array(
+ '/hello', '#^/hello/(?P<name>[^/]++)$#s', array('tld', 'name'), array('name'), array(
array('variable', '/', '[^/]++', 'name'),
array('text', '/hello'),
),
- '#^www\.example\.(?<tld>[^\.]++)$#s', array('tld'), array(
+ '#^www\.example\.(?P<tld>[^\.]++)$#s', array('tld'), array(
array('variable', '.', '[^\.]++', 'tld'),
array('text', 'www.example'),
),
@@ -230,7 +230,7 @@ public function provideCompileWithHostnameData()
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
array('text', '/hello'),
),
- '#^(?<locale>[^\.]++)\.example\.(?<tld>[^\.]++)$#s', array('locale', 'tld'), array(
+ '#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#s', array('locale', 'tld'), array(
array('variable', '.', '[^\.]++', 'tld'),
array('text', '.example'),
array('variable', '', '[^\.]++', 'locale'),
@@ -242,7 +242,7 @@ public function provideCompileWithHostnameData()
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
array('text', '/hello'),
),
- '#^(?<locale>[^\.]++)\.example\.(?<tld>[^\.]++)$#s', array('locale', 'tld'), array(
+ '#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#s', array('locale', 'tld'), array(
array('variable', '.', '[^\.]++', 'tld'),
array('text', '.example'),
array('variable', '', '[^\.]++', 'locale'),

0 comments on commit 077bd35

Please sign in to comment.
Something went wrong with that request. Please try again.