Skip to content

Commit e6cc85f

Browse files
Merge branch '4.2' into 4.3
* 4.2: minor: add some test in the ldap component [Bridge\ProxyManager] isProxyCandidate() does not take into account interfaces [Routing][AnnotationClassLoader] fix utf-8 encoding in default route name fixed a phpdoc [Debug] Wrap call to require_once in a try/catch prevent deprecation when filesize matches error code [PropertyInfo] Add missing documentation link in Readme Use the current working dir as default first arg in 'link' binary Respect parent class contract in ContainerAwareDoctrineEventManager [Validator] Add the missing translations for the Danish ("da") locale [PropertyAccess] Add missing property to PropertyAccessor [Cache] fix saving unrelated keys in recursive callback calls [Serializer] Fix denormalization of object with variadic constructor typed argument Allow set 'None' on samesite cookie flag Making cache rebuild correctly with MessageSubscriberInterface return values Fix finding parent definition
2 parents 1716997 + c5ce09e commit e6cc85f

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

Loader/AnnotationClassLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ public function getResolver()
248248
*/
249249
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
250250
{
251-
$name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name);
251+
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
252+
$name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name);
252253
if ($this->defaultRouteIndex > 0) {
253254
$name .= '_'.$this->defaultRouteIndex;
254255
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
4+
5+
class EncodingClass
6+
{
7+
public function routeÀction()
8+
{
9+
}
10+
}

Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,34 @@ public function testLocalizedPrefixWithoutRouteLocale()
306306
$this->assertEquals('/nl/suffix', $routes->get('action.nl')->getPath());
307307
}
308308

309+
/**
310+
* @requires function mb_strtolower
311+
*/
312+
public function testDefaultRouteName()
313+
{
314+
$methodRouteData = [
315+
'name' => null,
316+
];
317+
318+
$reader = $this->getReader();
319+
$reader
320+
->expects($this->once())
321+
->method('getMethodAnnotations')
322+
->will($this->returnValue([new RouteAnnotation($methodRouteData)]))
323+
;
324+
325+
$loader = new class($reader) extends AnnotationClassLoader {
326+
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
327+
{
328+
}
329+
};
330+
$routeCollection = $loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass');
331+
332+
$defaultName = array_keys($routeCollection->all())[0];
333+
334+
$this->assertSame($defaultName, 'symfony_component_routing_tests_fixtures_annotatedclasses_encodingclass_routeàction');
335+
}
336+
309337
public function testLoadingRouteWithPrefix()
310338
{
311339
$routes = $this->loader->load(RouteWithPrefixController::class);

Tests/Loader/AnnotationDirectoryLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function setUp()
2929

3030
public function testLoad()
3131
{
32-
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
32+
$this->reader->expects($this->exactly(4))->method('getClassAnnotation');
3333

3434
$this->reader
3535
->expects($this->any())
@@ -52,6 +52,7 @@ public function testLoadIgnoresHiddenDirectories()
5252
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
5353
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
5454
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
55+
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass',
5556
]);
5657

5758
$this->reader

0 commit comments

Comments
 (0)