Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Routing][AnnotationClassLoader] fix utf-8 encoding in default route name #31421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public function getResolver()
*/
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
{
$name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name);
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
$name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name);
if ($this->defaultRouteIndex > 0) {
$name .= '_'.$this->defaultRouteIndex;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;

class EncodingClass
{
public function routeÀction()
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,27 @@ public function testInvokableClassWithMethodRouteLoad()
$this->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route->getMethods(), '->load merges class and method route methods');
}

/**
* @requires function mb_strtolower
*/
public function testDefaultRouteName()
{
$methodRouteData = [
'name' => null,
];

$this->reader
->expects($this->once())
->method('getMethodAnnotations')
->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)]))
;

$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass');
$defaultName = array_keys($routeCollection->all())[0];

$this->assertSame($defaultName, 'symfony_component_routing_tests_fixtures_annotatedclasses_encodingclass_routeàction');
}

private function getAnnotatedRoute($data)
{
return new Route($data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function setUp()

public function testLoad()
{
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
$this->reader->expects($this->exactly(4))->method('getClassAnnotation');

$this->reader
->expects($this->any())
Expand All @@ -52,6 +52,7 @@ public function testLoadIgnoresHiddenDirectories()
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass',
]);

$this->reader
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.