10000 merged branch Tobion/named-variables (PR #3884) · hostingnuggets/symfony@bc0c7ba · GitHub
[go: up one dir, main page]

Skip to content

Commit bc0c7ba

Browse files
committed
merged branch Tobion/named-variables (PR symfony#3884)
Commits ------- f666836 [Routing] simplified regex with named variables Discussion ---------- [Routing] simplified regex with named variables Test pass: yes BC break: no Since PHP 5.2.2 subpatterns in regex can be simplified from `?P<name>` to `?<name>` (see http://www.php.net/manual/en/regexp.reference.subpatterns.php). This enhances readability.
2 parents 05842c5 + f666836 commit bc0c7ba

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function dump(array $options = array())
5656
if (strlen($regex) < 2 || 0 === $regexPatternEnd) {
5757
throw new \LogicException('The "%s" route regex "%s" is invalid', $name, $regex);
5858
}
59-
$regex = preg_replace('/\?P<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1));
59+
$regex = preg_replace('/\?<.+?>/', '', substr($regex, 1, $regexPatternEnd - 1));
6060
$regex = '^'.self::escape(preg_quote($options['base_uri']).substr($regex, 1), ' ', '\\');
6161

6262
$methods = array();

src/Symfony/Component/Routing/Matcher/Dum F438 per/PhpMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
191191

192192
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
193193

194-
if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
194+
if (!count($compiledRoute->getVariables()) && false !== preg_match('#^(.)\^(?<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
195195
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
196196
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
197197
$hasTrailingSlash = true;

src/Symfony/Component/Routing/RouteCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ private function computeRegexp(array $tokens, $index, $firstOptional)
108108
// Variable tokens
109109
if (0 === $index && 0 === $firstOptional && 1 == count($tokens)) {
110110
// When the only token is an optional variable token, the separator is required
111-
return sprintf('%s(?P<%s>%s)?', preg_quote($token[1], '#'), $token[3], $token[2]);
111+
return sprintf('%s(?<%s>%s)?', preg_quote($token[1], '#'), $token[3], $token[2]);
112112
} else {
113113
$nbTokens = count($tokens);
114-
$regexp = sprintf('%s(?P<%s>%s)', preg_quote($token[1], '#'), $token[3], $token[2]);
114+
$regexp = sprintf('%s(?<%s>%s)', preg_quote($token[1], '#'), $token[3], $token[2]);
115115
if ($index >= $firstOptional) {
116116
// Enclose each optional tokens in a subpattern to make it optional
117117
$regexp = "(?:$regexp";

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function match($pathinfo)
2626
$pathinfo = rawurldecode($pathinfo);
2727

2828
// foo
29-
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
29+
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) {
3030
return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
3131
}
3232

3333
// bar
34-
if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
34+
if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
3535
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
3636
$allow = array_merge($allow, array('GET', 'HEAD'));
3737
goto not_bar;
@@ -42,7 +42,7 @@ public function match($pathinfo)
4242
not_bar:
4343

4444
// barhead
45-
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
45+
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
4646
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
4747
$allow = array_merge($allow, array('GET', 'HEAD'));
4848
goto not_barhead;
@@ -68,13 +68,13 @@ public function match($pathinfo)
6868
}
6969

7070
// baz4
71-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
71+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
7272
$matches['_route'] = 'baz4';
7373
return $matches;
7474
}
7575

7676
// baz5
77-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
77+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
7878
if ($this->context->getMethod() != 'POST') {
7979
$allow[] = 'POST';
8080
goto not_baz5;
@@ -85,7 +85,7 @@ public function match($pathinfo)
8585
not_baz5:
8686

8787
// baz.baz6
88-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
88+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
8989
if ($this->context->getMethod() != 'PUT') {
9090
$allow[] = 'PUT';
9191
goto not_bazbaz6;
@@ -101,7 +101,7 @@ public function match($pathinfo)
101101
}
102102

103103
// quoter
104-
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
104+
if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
105105
$matches['_route'] = 'quoter';
106106
return $matches;
107107
}
@@ -114,34 +114,34 @@ public function match($pathinfo)
114114
if (0 === strpos($pathinfo, '/a')) {
115115
if (0 === strpos($pathinfo, '/a/b\'b')) {
116116
// foo1
117-
if (preg_match('#^/a/b\'b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
117+
if (preg_match('#^/a/b\'b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
118118
$matches['_route'] = 'foo1';
119119
return $matches;
120120
}
121121

122122
// bar1
123-
if (preg_match('#^/a/b\'b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
123+
if (preg_match('#^/a/b\'b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
124124
$matches['_route'] = 'bar1';
125125
return $matches;
126126
}
127127

128128
}
129129

130130
// overriden
131-
if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
131+
if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
132132
$matches['_route'] = 'overriden';
133133
return $matches;
134134
}
135135

136136
if (0 === strpos($pathinfo, '/a/b\'b')) {
137137
// foo2
138-
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
138+
if (preg_match('#^/a/b\'b/(?<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
139139
$matches['_route'] = 'foo2';
140140
return $matches;
141141
}
142142

143143
// bar2
144-
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]+?)$#s', $pathinfo, $matches 97AE )) {
144+
if (preg_match('#^/a/b\'b/(?<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
145145
$matches['_route'] = 'bar2';
146146
return $matches;
147147
}
@@ -152,7 +152,7 @@ public function match($pathinfo)
152152

153153
if (0 === strpos($pathinfo, '/multi')) {
154154
// helloWorld
155-
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]+?))?$#s', $pathinfo, $matches)) {
155+
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]+?))?$#s', $pathinfo, $matches)) {
156156
return array_merge($this->mergeDefaults($matches, array ( 'who' => 'World!',)), array('_route' => 'helloWorld'));
157157
}
158158

@@ -169,13 +169,13 @@ public function match($pathinfo)
169169
}
170170

171171
// foo3
172-
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
172+
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
173173
$matches['_route'] = 'foo3';
174174
return $matches;
175175
}
176176

177177
// bar3
178-
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
178+
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
179179
$matches['_route'] = 'bar3';
180180
return $matches;
181181
}
@@ -186,7 +186,7 @@ public function match($pathinfo)
186186
}
187187

188188
// foo4
189-
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
189+
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
190190
$matches['_route'] = 'foo4';
191191
return $matches;
192192
}
@@ -199,13 +199,13 @@ public function match($pathinfo)
199199

200200
if (0 === strpos($pathinfo, '/a/b')) {
201201
// b
202-
if (preg_match('#^/a/b/(?P<var>[^/]+?)$#s', $pathinfo, $matches)) {
202+
if (preg_match('#^/a/b/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
203203
$matches['_route'] = 'b';
204204
return $matches;
205205
}
206206

207207
// c
208-
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]+?)$#s', $pathinfo, $matches)) {
208+
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
209209
$matches['_route'] = 'c';
210210
return $matches;
211211
}

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php

Lines changed: 18 additions & 18 deletions
< 10000 td data-grid-cell-id="diff-409f704f7cb7922025e30c810d76776d744bb5f088e2c3e1fbdf01292e594b60-74-73-2" data-line-anchor="diff-409f704f7cb7922025e30c810d76776d744bb5f088e2c3e1fbdf01292e594b60L74" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionLine-bgColor, var(--diffBlob-deletion-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell left-side-diff-cell border-right left-side">-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/?$#s', $pathinfo, $matches)) {
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function match($pathinfo)
2626
$pathinfo = rawurldecode($pathinfo);
2727

2828
// foo
29-
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
29+
if (0 === strpos($pathinfo, '/foo') && preg_match('#^/foo/(?<bar>baz|symfony)$#s', $pathinfo, $matches)) {
3030
return array_merge($this->mergeDefaults($matches, array ( 'def' => 'test',)), array('_route' => 'foo'));
3131
}
3232

3333
// bar
34-
if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
34+
if (0 === strpos($pathinfo, '/bar') && preg_match('#^/bar/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
3535
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
3636
$allow = array_merge($allow, array('GET', 'HEAD'));
3737
goto not_bar;
@@ -42,7 +42,7 @@ public function match($pathinfo)
4242
not_bar:
4343

4444
// barhead
45-
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
45+
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
4646
if (!in_array($this->context->getMethod(), array('GET', 'HEAD'))) {
4747
$allow = array_merge($allow, array('GET', 'HEAD'));
4848
goto not_barhead;
@@ -71,7 +71,7 @@ public function match($pathinfo)
7171
}
7272

7373
// baz4
74
74+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/?$#s', $pathinfo, $matches)) {
7575
if (substr($pathinfo, -1) !== '/') {
7676
return $this->redirect($pathinfo.'/', 'baz4');
7777
}
@@ -80,7 +80,7 @@ public function match($pathinfo)
8080
}
8181

8282
// baz5
83-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
83+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
8484
if ($this->context->getMethod() != 'POST') {
8585
$allow[] = 'POST';
8686
goto not_baz5;
@@ -91,7 +91,7 @@ public function match($pathinfo)
9191
not_baz5:
9292

9393
// baz.baz6
94-
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?P<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
94+
if (0 === strpos($pathinfo, '/test') && preg_match('#^/test/(?<foo>[^/]+?)/$#s', $pathinfo, $matches)) {
9595
if ($this->context->getMethod() != 'PUT') {
9696
$allow[] = 'PUT';
9797
goto not_bazbaz6;
@@ -107,7 +107,7 @@ public function match($pathinfo)
107107
}
108108

109109
// quoter
110-
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
110+
if (preg_match('#^/(?<quoter>[\']+)$#s', $pathinfo, $matches)) {
111111
$matches['_route'] = 'quoter';
112112
return $matches;
113113
}
@@ -120,34 +120,34 @@ public function match($pathinfo)
120120
if (0 === strpos($pathinfo, '/a')) {
121121
if (0 === strpos($pathinfo, '/a/b\'b')) {
122122
// foo1
123-
if (preg_match('#^/a/b\'b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
123+
if (preg_match('#^/a/b\'b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
124124
$matches['_route'] = 'foo1';
125125
return $matches;
126126
}
127127

128128
// bar1
129-
if (preg_match('#^/a/b\'b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
129+
if (preg_match('#^/a/b\'b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
130130
$matches['_route'] = 'bar1';
131131
return $matches;
132132
}
133133

134134
}
135135

136136
// overriden
137-
if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
137+
if (preg_match('#^/a/(?<var>.*)$#s', $pathinfo, $matches)) {
138138
$matches['_route'] = 'overriden';
139139
return $matches;
140140
}
141141

142142
if (0 === strpos($pathinfo, '/a/b\'b')) {
143143
// foo2
144-
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
144+
if (preg_match('#^/a/b\'b/(?<foo1>[^/]+?)$#s', $pathinfo, $matches)) {
145145
$matches['_route'] = 'foo2';
146146
return $matches;
147147
}
148148

149149
// bar2
150-
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
150+
if (preg_match('#^/a/b\'b/(?<bar1>[^/]+?)$#s', $pathinfo, $matches)) {
151151
$matches['_route'] = 'bar2';
152152
return $matches;
153153
}
@@ -158,7 +158,7 @@ public function match($pathinfo)
158158

159159
if (0 === strpos($pathinfo, '/multi')) {
160160
// helloWorld
161-
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]+?))?$#s', $pathinfo, $matches)) {
161+
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?<who>[^/]+?))?$#s', $pathinfo, $matches)) {
162162
return array_merge($this->mergeDefaults($matches, array ( 'who' => 'World!',)), array('_route' => 'helloWorld'));
163163
}
164164

@@ -178,13 +178,13 @@ public function match($pathinfo)
178178
}
179179

180180
// foo3
181-
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
181+
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
182182
$matches['_route'] = 'foo3';
183183
return $matches;
184184
}
185185

186186
// bar3
187-
if (preg_match('#^/(?P<_locale>[^/]+?)/b/(?P<bar>[^/]+?)$#s', $pathinfo, $matches)) {
187+
if (preg_match('#^/(?<_locale>[^/]+?)/b/(?<bar>[^/]+?)$#s', $pathinfo, $matches)) {
188188
$matches['_route'] = 'bar3';
189189
return $matches;
190190
}
@@ -195,7 +195,7 @@ public function match($pathinfo)
195195
}
196196

197197
// foo4
198-
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?P<foo>[^/]+?)$#s', $pathinfo, $matches)) {
198+
if (0 === strpos($pathinfo, '/aba') && preg_match('#^/aba/(?<foo>[^/]+?)$#s', $pathinfo, $matches)) {
199199
$matches['_route'] = 'foo4';
200200
return $matches;
201201
}
@@ -208,13 +208,13 @@ public function match($pathinfo)
208208

209209
if (0 === strpos($pathinfo, '/a/b')) {
210210
// b
211-
if (preg_match('#^/a/b/(?P<var>[^/]+?)$#s', $pathinfo, $matches)) {
211+
if (preg_match('#^/a/b/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
212212
$matches['_route'] = 'b';
213213
return $matches;
214214
}
215215

216216
// c
217-
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]+?)$#s', $pathinfo, $matches)) {
217+
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
218218
$matches['_route'] = 'c';
219219
return $matches;
220220
}

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function match($pathinfo)
3232
}
3333

3434
// dynamic
35-
if (preg_match('#^/rootprefix/(?P<var>[^/]+?)$#s', $pathinfo, $matches)) {
35+
if (preg_match('#^/rootprefix/(?<var>[^/]+?)$#s', $pathinfo, $matches)) {
3636
$matches['_route'] = 'dynamic';
3737
return $matches;
3838
}

src/Symfony/Component/Routing/Tests/RouteCompilerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ public function provideCompileData()
4343
array(
4444
'Route with a variable',
4545
array('/foo/{bar}'),
46-
'/foo', '#^/foo/(?P<bar>[^/]+?)$#s', array('bar'), array(
46+
'/foo', '#^/foo/(?<bar>[^/]+?)$#s', array('bar'), array(
4747
array('variable', '/', '[^/]+?', 'bar'),
4848
array('text', '/foo'),
4949
)),
5050

5151
array(
5252
'Route with a variable that has a default value',
5353
array('/foo/{bar}', array('bar' => 'bar')),
54-
'/foo', '#^/foo(?:/(?P<bar>[^/]+?))?$#s', array('bar'), array(
54+
'/foo', '#^/foo(?:/(?<bar>[^/]+?))?$#s', array('bar'), array(
5555
array('variable', '/', '[^/]+?', 'bar'),
5656
array('text', '/foo'),
5757
)),
5858

5959
array(
6060
'Route with several variables',
6161
array('/foo/{bar}/{foobar}'),
62-
'/foo', '#^/foo/(?P<bar>[^/]+?)/(?P<foobar>[^/]+?)$#s', array('bar', 'foobar'), array(
62+
'/foo', '#^/foo/(?<bar>[^/]+?)/(?<foobar>[^/]+?)$#s', array('bar', 'foobar'), array(
6363
array('variable', '/', '[^/]+?', 'foobar'),
6464
array('variable', '/', '[^/]+?', 'bar'),
6565
array('text', '/foo'),
@@ -68,7 +68,7 @@ public function provideCompileData()
6868
array(
6969
'Route with several variables that have default values',
7070
array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')),
71-
'/foo', '#^/foo(?:/(?P<bar>[^/]+?)(?:/(?P<foobar>[^/]+?))?)?$#s', array('bar', 'foobar'), array(
71+
'/foo', '#^/foo(?:/(?<bar>[^/]+?)(?:/(?<foobar>[^/]+?))?)?$#s', array('bar', 'foobar'), array(
7272
array('variable', '/', '[^/]+?', 'foobar'),
7373
array('variable', '/', '[^/]+?', 'bar'),
7474
array('text', '/foo'),
@@ -77,7 +77,7 @@ public function provideCompileData()
7777
array(
7878
'Route with several variables but some of them have no default values',
7979
array('/foo/{bar}/{foobar}', array('bar' => 'bar')),
80-
'/foo', '#^/foo/(?P<bar>[^/]+?)/(?P<foobar>[^/]+?)$#s', array('bar', 'foobar'), array(
80+
'/foo', '#^/foo/(?<bar>[^/]+?)/(?<foobar>[^/]+?)$#s', array('bar', 'foobar'), array(
8181
array('variable', '/', '[^/]+?', 'foobar'),
8282
array('variable', '/', '[^/]+?', 'bar'),
8383
array('text', '/foo'),
@@ -86,14 +86,14 @@ public function provideCompileData()
8686
array(
8787
'Route with an optional variable as the first segment',
8888
array('/{bar}', array('bar' => 'bar')),
89-
'', '#^/(?P<bar>[^/]+?)?$#s', array('bar'), array(
89+
'', '#^/(?<bar>[^/]+?)?$#s', array('bar'), array(
9090
array('variable', '/', '[^/]+?', 'bar'),
9191
)),
9292

9393
array(
9494
'Route with an optional variable as the first segment with requirements',
9595
array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')),
96-
'', '#^/(?P<bar>(foo|bar))?$#s', array('bar'), array(
96+
'', '#^/(?<bar>(foo|bar))?$#s', array('bar'), array(
9797
array('variable', '/', '(foo|bar)', 'bar'),
9898
)),
9999
);

0 commit comments

Comments
 (0)
0