Skip to content

Commit 797ed21

Browse files
committed
[Routing] Indicate type of rejected object in CompiledUrlMatcherDumper
1 parent b76bdfd commit 797ed21

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Matcher/Dumper/CompiledUrlMatcherDumper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,10 @@ public static function export(mixed $value): string
465465
if (null === $value) {
466466
return 'null';
467467
}
468+
if (\is_object($value)) {
469+
throw new \InvalidArgumentException(\sprintf('Symfony\Component\Routing\Route cannot contain objects, but "%s" given.', get_debug_type($value)));
470+
}
468471
if (!\is_array($value)) {
469-
if (\is_object($value)) {
470-
throw new \InvalidArgumentException('Symfony\Component\Routing\Route cannot contain objects.');
471-
}
472-
473472
return str_replace("\n", '\'."\n".\'', var_export($value, true));
474473
}
475474
if (!$value) {

Tests/Matcher/Dumper/CompiledUrlMatcherDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public function testGenerateDumperMatcherWithObject()
492492
$routeCollection->add('_', new Route('/', [new \stdClass()]));
493493
$dumper = new CompiledUrlMatcherDumper($routeCollection);
494494

495-
$this->expectExceptionMessage('Symfony\Component\Routing\Route cannot contain objects');
495+
$this->expectExceptionMessage('Symfony\Component\Routing\Route cannot contain objects, but "stdClass" given.');
496496
$this->expectException(\InvalidArgumentException::class);
497497

498498
$dumper->dump();

0 commit comments

Comments
 (0)