diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index 044638300d..c5af8c52a3 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -746,6 +746,10 @@ EOF; return 'null'; } if (!\is_array($value)) { + if (\is_object($value)) { + throw new \InvalidArgumentException('Symfony\Component\Routing\Route cannot contain objects.'); + } + return str_replace("\n", '\'."\n".\'', var_export($value, true)); } if (!$value) { diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 4bbfe131a7..a1c28ecab4 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -491,6 +491,18 @@ class PhpMatcherDumperTest extends TestCase return $this->matcherClass; } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Symfony\Component\Routing\Route cannot contain objects + */ + public function testGenerateDumperMatcherWithObject() + { + $routeCollection = new RouteCollection(); + $routeCollection->add('_', new Route('/', array(new \stdClass()))); + $dumper = new PhpMatcherDumper($routeCollection); + $dumper->dump(); + } } abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface