Skip to content

Commit fed7aac

Browse files
Merge branch '2.7' into 2.8
* 2.7: [CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_method, semicolon_after_instruction
2 parents 1c6b4e2 + dd32931 commit fed7aac

File tree

5 files changed

+44
-44
lines changed

5 files changed

+44
-44
lines changed

Loader/ObjectRouteLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract protected function getServiceObject($id);
4545
public function load($resource, $type = null)
4646
{
4747
$parts = explode(':', $resource);
48-
if (count($parts) != 2) {
48+
if (2 != count($parts)) {
4949
throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service_name:methodName"', $resource));
5050
}
5151

Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren
225225
$supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods));
226226

227227
if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\^(?P<url>.*?)\$\1#', $compiledRoute->getRegex(), $m)) {
228-
if ($supportsTrailingSlash && substr($m['url'], -1) === '/') {
229-
$conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
228+
if ($supportsTrailingSlash && '/' === substr($m['url'], -1)) {
229+
$conditions[] = sprintf("%s === rtrim(\$pathinfo, '/')", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true));
230230
$hasTrailingSlash = true;
231231
} else {
232-
$conditions[] = sprintf('$pathinfo === %s', var_export(str_replace('\\', '', $m['url']), true));
232+
$conditions[] = sprintf('%s === $pathinfo', var_export(str_replace('\\', '', $m['url']), true));
233233
}
234234
} else {
235235
if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) {

Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ public function match($pathinfo)
6060
if (0 === strpos($pathinfo, '/test')) {
6161
if (0 === strpos($pathinfo, '/test/baz')) {
6262
// baz
63-
if ($pathinfo === '/test/baz') {
63+
if ('/test/baz' === $pathinfo) {
6464
return array('_route' => 'baz');
6565
}
6666

6767
// baz2
68-
if ($pathinfo === '/test/baz.html') {
68+
if ('/test/baz.html' === $pathinfo) {
6969
return array('_route' => 'baz2');
7070
}
7171

7272
// baz3
73-
if ($pathinfo === '/test/baz3/') {
73+
if ('/test/baz3/' === $pathinfo) {
7474
return array('_route' => 'baz3');
7575
}
7676

@@ -106,7 +106,7 @@ public function match($pathinfo)
106106
}
107107

108108
// foofoo
109-
if ($pathinfo === '/foofoo') {
109+
if ('/foofoo' === $pathinfo) {
110110
return array ( 'def' => 'test', '_route' => 'foofoo',);
111111
}
112112

@@ -116,7 +116,7 @@ public function match($pathinfo)
116116
}
117117

118118
// space
119-
if ($pathinfo === '/spa ce') {
119+
if ('/spa ce' === $pathinfo) {
120120
return array('_route' => 'space');
121121
}
122122

@@ -161,12 +161,12 @@ public function match($pathinfo)
161161
}
162162

163163
// overridden2
164-
if ($pathinfo === '/multi/new') {
164+
if ('/multi/new' === $pathinfo) {
165165
return array('_route' => 'overridden2');
166166
}
167167

168168
// hey
169-
if ($pathinfo === '/multi/hey/') {
169+
if ('/multi/hey/' === $pathinfo) {
170170
return array('_route' => 'hey');
171171
}
172172

@@ -184,7 +184,7 @@ public function match($pathinfo)
184184

185185
if (0 === strpos($pathinfo, '/aba')) {
186186
// ababa
187-
if ($pathinfo === '/ababa') {
187+
if ('/ababa' === $pathinfo) {
188188
return array('_route' => 'ababa');
189189
}
190190

@@ -199,55 +199,55 @@ public function match($pathinfo)
199199

200200
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
201201
// route1
202-
if ($pathinfo === '/route1') {
202+
if ('/route1' === $pathinfo) {
203203
return array('_route' => 'route1');
204204
}
205205

206206
// route2
207-
if ($pathinfo === '/c2/route2') {
207+
if ('/c2/route2' === $pathinfo) {
208208
return array('_route' => 'route2');
209209
}
210210

211211
}
212212

213213
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
214214
// route3
215-
if ($pathinfo === '/c2/route3') {
215+
if ('/c2/route3' === $pathinfo) {
216216
return array('_route' => 'route3');
217217
}
218218

219219
}
220220

221221
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
222222
// route4
223-
if ($pathinfo === '/route4') {
223+
if ('/route4' === $pathinfo) {
224224
return array('_route' => 'route4');
225225
}
226226

227227
}
228228

229229
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
230230
// route5
231-
if ($pathinfo === '/route5') {
231+
if ('/route5' === $pathinfo) {
232232
return array('_route' => 'route5');
233233
}
234234

235235
}
236236

237237
// route6
238-
if ($pathinfo === '/route6') {
238+
if ('/route6' === $pathinfo) {
239239
return array('_route' => 'route6');
240240
}
241241

242242
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
243243
if (0 === strpos($pathinfo, '/route1')) {
244244
// route11
245-
if ($pathinfo === '/route11') {
245+
if ('/route11' === $pathinfo) {
246246
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
247247
}
248248

249249
// route12
250-
if ($pathinfo === '/route12') {
250+
if ('/route12' === $pathinfo) {
251251
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
252252
}
253253

@@ -280,15 +280,15 @@ public function match($pathinfo)
280280
}
281281

282282
// route17
283-
if ($pathinfo === '/route17') {
283+
if ('/route17' === $pathinfo) {
284284
return array('_route' => 'route17');
285285
}
286286

287287
}
288288

289289
if (0 === strpos($pathinfo, '/a')) {
290290
// a
291-
if ($pathinfo === '/a/a...') {
291+
if ('/a/a...' === $pathinfo) {
292292
return array('_route' => 'a');
293293
}
294294

Tests/Fixtures/dumper/url_matcher2.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ public function match($pathinfo)
6060
if (0 === strpos($pathinfo, '/test')) {
6161
if (0 === strpos($pathinfo, '/test/baz')) {
6262
// baz
63-
if ($pathinfo === '/test/baz') {
63+
if ('/test/baz' === $pathinfo) {
6464
return array('_route' => 'baz');
6565
}
6666

6767
// baz2
68-
if ($pathinfo === '/test/baz.html') {
68+
if ('/test/baz.html' === $pathinfo) {
6969
return array('_route' => 'baz2');
7070
}
7171

7272
// baz3
73-
if (rtrim($pathinfo, '/') === '/test/baz3') {
73+
if ('/test/baz3' === rtrim($pathinfo, '/')) {
7474
if (substr($pathinfo, -1) !== '/') {
7575
return $this->redirect($pathinfo.'/', 'baz3');
7676
}
@@ -114,7 +114,7 @@ public function match($pathinfo)
114114
}
115115

116116
// foofoo
117-
if ($pathinfo === '/foofoo') {
117+
if ('/foofoo' === $pathinfo) {
118118
return array ( 'def' => 'test', '_route' => 'foofoo',);
119119
}
120120

@@ -124,7 +124,7 @@ public function match($pathinfo)
124124
}
125125

126126
// space
127-
if ($pathinfo === '/spa ce') {
127+
if ('/spa ce' === $pathinfo) {
128128
return array('_route' => 'space');
129129
}
130130

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

171171
// overridden2
172-
if ($pathinfo === '/multi/new') {
172+
if ('/multi/new' === $pathinfo) {
173173
return array('_route' => 'overridden2');
174174
}
175175

176176
// hey
177-
if (rtrim($pathinfo, '/') === '/multi/hey') {
177+
if ('/multi/hey' === rtrim($pathinfo, '/')) {
178178
if (substr($pathinfo, -1) !== '/') {
179179
return $this->redirect($pathinfo.'/', 'hey');
180180
}
@@ -196,7 +196,7 @@ public function match($pathinfo)
196196

197197
if (0 === strpos($pathinfo, '/aba')) {
198198
// ababa
199-
if ($pathinfo === '/ababa') {
199+
if ('/ababa' === $pathinfo) {
200200
return array('_route' => 'ababa');
201201
}
202202

@@ -211,55 +211,55 @@ public function match($pathinfo)
211211

212212
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
213213
// route1
214-
if ($pathinfo === '/route1') {
214+
if ('/route1' === $pathinfo) {
215215
return array('_route' => 'route1');
216216
}
217217

218218
// route2
219-
if ($pathinfo === '/c2/route2') {
219+
if ('/c2/route2' === $pathinfo) {
220220
return array('_route' => 'route2');
221221
}
222222

223223
}
224224

225225
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
226226
// route3
227-
if ($pathinfo === '/c2/route3') {
227+
if ('/c2/route3' === $pathinfo) {
228228
return array('_route' => 'route3');
229229
}
230230

231231
}
232232

233233
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
234234
// route4
235-
if ($pathinfo === '/route4') {
235+
if ('/route4' === $pathinfo) {
236236
return array('_route' => 'route4');
237237
}
238238

239239
}
240240

241241
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
242242
// route5
243-
if ($pathinfo === '/route5') {
243+
if ('/route5' === $pathinfo) {
244244
return array('_route' => 'route5');
245245
}
246246

247247
}
248248

249249
// route6
250-
if ($pathinfo === '/route6') {
250+
if ('/route6' === $pathinfo) {
251251
return array('_route' => 'route6');
252252
}
253253

254254
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
255255
if (0 === strpos($pathinfo, '/route1')) {
256256
// route11
257-
if ($pathinfo === '/route11') {
257+
if ('/route11' === $pathinfo) {
258258
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
259259
}
260260

261261
// route12
262-
if ($pathinfo === '/route12') {
262+
if ('/route12' === $pathinfo) {
263263
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
264264
}
265265

@@ -292,15 +292,15 @@ public function match($pathinfo)
292292
}
293293

294294
// route17
295-
if ($pathinfo === '/route17') {
295+
if ('/route17' === $pathinfo) {
296296
return array('_route' => 'route17');
297297
}
298298

299299
}
300300

301301
if (0 === strpos($pathinfo, '/a')) {
302302
// a
303-
if ($pathinfo === '/a/a...') {
303+
if ('/a/a...' === $pathinfo) {
304304
return array('_route' => 'a');
305305
}
306306

@@ -320,7 +320,7 @@ public function match($pathinfo)
320320
}
321321

322322
// secure
323-
if ($pathinfo === '/secure') {
323+
if ('/secure' === $pathinfo) {
324324
$requiredSchemes = array ( 'https' => 0,);
325325
if (!isset($requiredSchemes[$this->context->getScheme()])) {
326326
return $this->redirect($pathinfo, 'secure', key($requiredSchemes));
@@ -330,7 +330,7 @@ public function match($pathinfo)
330330
}
331331

332332
// nonsecure
333-
if ($pathinfo === '/nonsecure') {
333+
if ('/nonsecure' === $pathinfo) {
334334
$requiredSchemes = array ( 'http' => 0,);
335335
if (!isset($requiredSchemes[$this->context->getScheme()])) {
336336
return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes));

Tests/Fixtures/dumper/url_matcher3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function match($pathinfo)
2929

3030
if (0 === strpos($pathinfo, '/rootprefix')) {
3131
// static
32-
if ($pathinfo === '/rootprefix/test') {
32+
if ('/rootprefix/test' === $pathinfo) {
3333
return array('_route' => 'static');
3434
}
3535

@@ -41,7 +41,7 @@ public function match($pathinfo)
4141
}
4242

4343
// with-condition
44-
if ($pathinfo === '/with-condition' && ($context->getMethod() == "GET")) {
44+
if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
4545
return array('_route' => 'with-condition');
4646
}
4747

0 commit comments

Comments
 (0)