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

Commit 9604e69

Browse filesBrowse files
bug #27727 [Routing] Disallow object usage inside Route (paxal)
This PR was submitted for the master branch but it was merged into the 4.1 branch instead (closes #27727). Discussion ---------- [Routing] Disallow object usage inside Route | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | ? | Fixed tickets | #27723 | License | MIT | Doc PR | ✘ As discussed in #27723 the `Route` object should not support nested objects as attributes (`requirements`, `defaults`, ...). Thus, if detected, an `\InvalidArgumentException` will be thrown. Will fix #27723 Commits ------- 426fb45 [Routing] Disallow object usage inside Route
2 parents 3f4644b + 426fb45 commit 9604e69
Copy full SHA for 9604e69

File tree

Expand file treeCollapse file tree

2 files changed

+16
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-0
lines changed

‎src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ public static function export($value): string
746746
return 'null';
747747
}
748748
if (!\is_array($value)) {
749+
if (\is_object($value)) {
750+
throw new \InvalidArgumentException('Symfony\Component\Routing\Route cannot contain objects.');
751+
}
752+
749753
return str_replace("\n", '\'."\n".\'', var_export($value, true));
750754
}
751755
if (!$value) {

‎src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,18 @@ private function generateDumpedMatcher(RouteCollection $collection, $redirectabl
491491

492492
return $this->matcherClass;
493493
}
494+
495+
/**
496+
* @expectedException \InvalidArgumentException
497+
* @expectedExceptionMessage Symfony\Component\Routing\Route cannot contain objects
498+
*/
499+
public function testGenerateDumperMatcherWithObject()
500+
{
501+
$routeCollection = new RouteCollection();
502+
$routeCollection->add('_', new Route('/', array(new \stdClass())));
503+
$dumper = new PhpMatcherDumper($routeCollection);
504+
$dumper->dump();
505+
}
494506
}
495507

496508
abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.