Skip to content

Commit 0f6c879

Browse files
Merge branch '7.4' into 8.0
* 7.4: (21 commits) [ObjectMapper] lazy loading [Filesystem] Unify logic for isAbsolute() in Path [DependencyInjection] Include return type in AppReference shape [Finder] Make method calls explicit in ExcludeDirectoryFilterIterator [Cache] Remove unset call on undefined variable in PhpArrayAdapter [Twig] Ensure WrappedTemplatedEmail::getReturnPath() returns a string [Routing] Simplify importing routes defined on controller services Fix tests [DependendcyInjection] Improve shape for "from_callable" definitions [PHPDoc] Fix various PHPDoc syntax errors [Console] Add missing VERBOSITY_SILENT case in CommandDataCollector [Notifier] Remove unused $transportName argument in EmailChannel::notify() [Translation] Remove an unused argument passed to parseNode() method [HttpClient] Reject 3xx pushed responses [Serializer] Use Asia/Tokyo instead of Japan in tests [ProxyManagerBridge] Remove comment that reference github discussion [JsonPath] Remove unused "nothing" property from JsonCrawler [ErrorHandler] Improve PHPDoc precision in SerializerErrorRenderer [Routing] Fix matching the "0" URL [Form] Fix EnumType choice_label logic for grouped choices ...
2 parents 1be133b + 7255c02 commit 0f6c879

File tree

8 files changed

+24
-13
lines changed

8 files changed

+24
-13
lines changed

Loader/AttributeServicesLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function load(mixed $resource, ?string $type = null): RouteCollection
4242

4343
public function supports(mixed $resource, ?string $type = null): bool
4444
{
45-
return 'tagged_services' === $type && 'attributes' === $resource;
45+
return 'routing.controllers' === $resource;
4646
}
4747
}

Loader/Configurator/RoutesReference.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
*
2727
* return Routes::config([
2828
* 'controllers' => [
29-
* 'resource' => 'attributes',
30-
* 'type' => 'tagged_services',
29+
* 'resource' => 'routing.controllers',
3130
* ],
3231
* ]);
3332
* ```

Matcher/Dumper/CompiledUrlMatcherTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function match(string $pathinfo): array
5757
} finally {
5858
$this->context->setScheme($scheme);
5959
}
60-
} elseif ('/' !== $trimmedPathinfo = rtrim($pathinfo, '/') ?: '/') {
60+
} elseif ('' !== $trimmedPathinfo = rtrim($pathinfo, '/')) {
6161
$pathinfo = $trimmedPathinfo === $pathinfo ? $pathinfo.'/' : $trimmedPathinfo;
6262
if ($ret = $this->doMatch($pathinfo, $allow, $allowSchemes)) {
6363
return $this->redirect($pathinfo, $ret['_route']) + $ret;
@@ -73,8 +73,8 @@ public function match(string $pathinfo): array
7373
private function doMatch(string $pathinfo, array &$allow = [], array &$allowSchemes = []): array
7474
{
7575
$allow = $allowSchemes = [];
76-
$pathinfo = rawurldecode($pathinfo) ?: '/';
77-
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
76+
$pathinfo = '' === ($pathinfo = rawurldecode($pathinfo)) ? '/' : $pathinfo;
77+
$trimmedPathinfo = '' === ($trimmedPathinfo = rtrim($pathinfo, '/')) ? '/' : $trimmedPathinfo;
7878
$context = $this->context;
7979
$requestMethod = $canonicalMethod = $context->getMethod();
8080

Matcher/RedirectableUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function match(string $pathinfo): array
4141
} finally {
4242
$this->context->setScheme($scheme);
4343
}
44-
} elseif ('/' === $trimmedPathinfo = rtrim($pathinfo, '/') ?: '/') {
44+
} elseif ('' === $trimmedPathinfo = rtrim($pathinfo, '/')) {
4545
throw $e;
4646
} else {
4747
try {

Matcher/TraceableUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a
5757
$method = 'GET';
5858
}
5959
$supportsTrailingSlash = 'GET' === $method && $this instanceof RedirectableUrlMatcherInterface;
60-
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
60+
$trimmedPathinfo = '' === ($trimmedPathinfo = rtrim($pathinfo, '/')) ? '/' : $trimmedPathinfo;
6161

6262
foreach ($routes as $name => $route) {
6363
$compiledRoute = $route->compile();

Matcher/UrlMatcher.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public function getContext(): RequestContext
7070
public function match(string $pathinfo): array
7171
{
7272
$this->allow = $this->allowSchemes = [];
73+
$pathinfo = '' === ($pathinfo = rawurldecode($pathinfo)) ? '/' : $pathinfo;
7374

74-
if ($ret = $this->matchCollection(rawurldecode($pathinfo) ?: '/', $this->routes)) {
75+
if ($ret = $this->matchCollection($pathinfo, $this->routes)) {
7576
return $ret;
7677
}
7778

@@ -114,7 +115,7 @@ protected function matchCollection(string $pathinfo, RouteCollection $routes): a
114115
$method = 'GET';
115116
}
116117
$supportsTrailingSlash = 'GET' === $method && $this instanceof RedirectableUrlMatcherInterface;
117-
$trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';
118+
$trimmedPathinfo = '' === ($trimmedPathinfo = rtrim($pathinfo, '/')) ? '/' : $trimmedPathinfo;
118119

119120
foreach ($routes as $name => $route) {
120121
$compiledRoute = $route->compile();

Tests/Loader/AttributeServicesLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function testSupports()
2626

2727
$this->assertFalse($loader->supports('attributes', null));
2828
$this->assertFalse($loader->supports('attributes', 'attribute'));
29-
$this->assertFalse($loader->supports('other', 'tagged_services'));
30-
$this->assertTrue($loader->supports('attributes', 'tagged_services'));
29+
$this->assertFalse($loader->supports('other', 'routing.controllers'));
30+
$this->assertTrue($loader->supports('routing.controllers'));
3131
}
3232

3333
public function testDelegatesToAttributeLoaderAndMergesCollections()
@@ -47,7 +47,7 @@ public function testDelegatesToAttributeLoaderAndMergesCollections()
4747
$attributeLoader->setResolver($resolver);
4848
$servicesLoader->setResolver($resolver);
4949

50-
$collection = $servicesLoader->load('attributes', 'tagged_services');
50+
$collection = $servicesLoader->load('routing.controllers');
5151

5252
$this->assertArrayHasKey('action', $collection->all());
5353
$this->assertArrayHasKey('put', $collection->all());

Tests/Matcher/UrlMatcherTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222

2323
class UrlMatcherTest extends TestCase
2424
{
25+
public function testZero()
26+
{
27+
$coll = new RouteCollection();
28+
$coll->add('index', new Route('/'));
29+
30+
$matcher = $this->getUrlMatcher($coll);
31+
32+
$this->expectException(ResourceNotFoundException::class);
33+
$matcher->match('0');
34+
}
35+
2536
public function testNoMethodSoAllowed()
2637
{
2738
$coll = new RouteCollection();

0 commit comments

Comments
 (0)