Skip to content

Commit ccc7bc0

Browse files
Merge branch '4.4' into 5.2
* 4.4: [DoctrineBridge] Allow bundles to define a driver type "attribute" fix test SocketStreamTest for Windows Fix issue with RequestMatcher when attribute is a closure [PropertyInfo] Use the right context for methods defined in traits
2 parents 18373fd + bc4e440 commit ccc7bc0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

RequestMatcher.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ public function matches(Request $request)
164164
}
165165

166166
foreach ($this->attributes as $key => $pattern) {
167-
if (!preg_match('{'.$pattern.'}', $request->attributes->get($key))) {
167+
$requestAttribute = $request->attributes->get($key);
168+
if (!\is_string($requestAttribute)) {
169+
return false;
170+
}
171+
if (!preg_match('{'.$pattern.'}', $requestAttribute)) {
168172
return false;
169173
}
170174
}

Tests/RequestMatcherTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ public function testAttributes()
164164
$this->assertFalse($matcher->matches($request));
165165
}
166166

167+
public function testAttributesWithClosure()
168+
{
169+
$matcher = new RequestMatcher();
170+
171+
$request = Request::create('/admin/foo');
172+
$request->attributes->set('_controller', function () {
173+
return new Response('foo');
174+
});
175+
176+
$matcher->matchAttribute('_controller', 'babar');
177+
$this->assertFalse($matcher->matches($request));
178+
}
179+
167180
public function testIps()
168181
{
169182
$matcher = new RequestMatcher();

0 commit comments

Comments
 (0)