Skip to content

Commit 6b163d7

Browse files
Remove deprecated code paths that trigger a runtime notice
1 parent a235fb6 commit 6b163d7

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

Loader/AnnotationClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
143143

144144
foreach ($requirements as $placeholder => $requirement) {
145145
if (\is_int($placeholder)) {
146-
@trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()), E_USER_DEPRECATED);
146+
throw new \InvalidArgumentException(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()));
147147
}
148148
}
149149

@@ -303,7 +303,7 @@ protected function getGlobals(\ReflectionClass $class)
303303

304304
foreach ($globals['requirements'] as $placeholder => $requirement) {
305305
if (\is_int($placeholder)) {
306-
@trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()), E_USER_DEPRECATED);
306+
throw new \InvalidArgumentException(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()));
307307
}
308308
}
309309
}

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected function parseRoute(RouteCollection $collection, $name, array $config,
118118

119119
foreach ($requirements as $placeholder => $requirement) {
120120
if (\is_int($placeholder)) {
121-
@trigger_error(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s"?', $placeholder, $requirement, $name, $path), E_USER_DEPRECATED);
121+
throw new \InvalidArgumentException(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s"?', $placeholder, $requirement, $name, $path));
122122
}
123123
}
124124

Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@ public function testSimplePathRoute()
9191
}
9292

9393
/**
94-
* @group legacy
95-
* @expectedDeprecation A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "foo" in "Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController"?
96-
* @expectedDeprecation A placeholder name must be a string (1 given). Did you forget to specify the placeholder key for the requirement "\d+" in "Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController"?
97-
* @expectedDeprecation A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "foo" of route "foo" in "Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController::foo()"?
98-
* @expectedDeprecation A placeholder name must be a string (1 given). Did you forget to specify the placeholder key for the requirement "\d+" of route "foo" in "Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController::foo()"?
94+
* @expectedException \InvalidArgumentException
95+
* @expectedExceptionMessage A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "foo"
9996
*/
10097
public function testRequirementsWithoutPlaceholderName()
10198
{

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ public function testImportRouteWithNoTrailingSlash()
382382
}
383383

384384
/**
385-
* @group legacy
386-
* @expectedDeprecation A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "\d+" of route "foo" in "%srequirements_without_placeholder_name.yml"?
385+
* @expectedException \InvalidArgumentException
386+
* @expectedExceptionMessage A placeholder name must be a string (0 given). Did you forget to specify the placeholder key for the requirement "\d+" of route "foo"
387387
*/
388388
public function testRequirementsWithoutPlaceholderName()
389389
{

0 commit comments

Comments
 (0)