Skip to content

Commit 30b652a

Browse files
committed
Merge branch '4.2'
* 4.2: (45 commits) [Form] various minor fixes Ensure the parent process is always killed bugfix: the terminal state was wrong and not reseted [Console] Fix inconsistent result for choice questions in non-interactive mode Define null return type for Constraint::getDefaultOption() [Routing] Fix: annotation loader ignores method's default values [HttpKernel] Fix DebugHandlersListener constructor docblock Skip Glob brace test when GLOB_BRACE is unavailable bumped Symfony version to 4.2.6 updated VERSION for 4.2.5 updated CHANGELOG for 4.2.5 bumped Symfony version to 3.4.25 updated VERSION for 3.4.24 update CONTRIBUTORS for 3.4.24 updated CHANGELOG for 3.4.24 [EventDispatcher] cleanup fix testIgnoredAttributesInContext Re-generate icu 64.1 data Improve PHPdoc / IDE autocomplete for config tree builder [Bridge][Twig] DebugCommand - fix escaping and filter ...
2 parents 90bff34 + b9f1655 commit 30b652a

File tree

7 files changed

+31
-3
lines changed

7 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ CHANGELOG
7979

8080
* [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and
8181
will be removed in Symfony 3.0, since the performance gains were minimal and
82-
it's hard to replicate the behaviour of PHP implementation.
82+
it's hard to replicate the behavior of PHP implementation.
8383

8484
2.3.0
8585
-----

Loader/AnnotationClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
196196
continue;
197197
}
198198
foreach ($paths as $locale => $path) {
199-
if (false !== strpos($path, sprintf('{%s}', $param->name))) {
199+
if (preg_match(sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
200200
$defaults[$param->name] = $param->getDefaultValue();
201201
break;
202202
}

Loader/AnnotationFileLoader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function load($file, $type = null)
5656

5757
$collection = new RouteCollection();
5858
if ($class = $this->findClass($path)) {
59+
$refl = new \ReflectionClass($class);
60+
if ($refl->isAbstract()) {
61+
return;
62+
}
63+
5964
$collection->addResource(new FileResource($path));
6065
$collection->addCollection($this->loader->load($class, $type));
6166
}

Tests/Fixtures/AnnotatedClasses/AbstractClass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313

1414
abstract class AbstractClass
1515
{
16+
abstract public function abstractRouteAction();
17+
18+
public function routeAction($arg1, $arg2 = 'defaultValue2', $arg3 = 'defaultValue3')
19+
{
20+
}
1621
}

Tests/Fixtures/AnnotationFixtures/DefaultValueController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ class DefaultValueController
1212
public function action($default = 'value')
1313
{
1414
}
15+
16+
/**
17+
* @Route("/hello/{name<\w+>}", name="hello_without_default")
18+
* @Route("/hello/{name<\w+>?Symfony}", name="hello_with_default")
19+
*/
20+
public function hello(string $name = 'World')
21+
{
22+
}
1523
}

Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,11 @@ public function testLocalizedPathRoutesWithExplicitPathPropety()
138138
public function testDefaultValuesForMethods()
139139
{
140140
$routes = $this->loader->load(DefaultValueController::class);
141-
$this->assertCount(1, $routes);
141+
$this->assertCount(3, $routes);
142142
$this->assertEquals('/{default}/path', $routes->get('action')->getPath());
143143
$this->assertEquals('value', $routes->get('action')->getDefault('default'));
144+
$this->assertEquals('Symfony', $routes->get('hello_with_default')->getDefault('name'));
145+
$this->assertEquals('World', $routes->get('hello_without_default')->getDefault('name'));
144146
}
145147

146148
public function testMethodActionControllers()

Tests/Loader/AnnotationFileLoaderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public function testLoadAnonymousClass()
7272
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php');
7373
}
7474

75+
public function testLoadAbstractClass()
76+
{
77+
$this->reader->expects($this->never())->method('getClassAnnotation');
78+
$this->reader->expects($this->never())->method('getMethodAnnotations');
79+
80+
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
81+
}
82+
7583
public function testSupports()
7684
{
7785
$fixture = __DIR__.'/../Fixtures/annotated.php';

0 commit comments

Comments
 (0)