File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,11 @@ public function matches(Request $request)
167
167
}
168
168
169
169
foreach ($ this ->attributes as $ key => $ pattern ) {
170
- if (!preg_match ('{ ' .$ pattern .'} ' , $ request ->attributes ->get ($ key ))) {
170
+ $ requestAttribute = $ request ->attributes ->get ($ key );
171
+ if (!\is_string ($ requestAttribute )) {
172
+ return false ;
173
+ }
174
+ if (!preg_match ('{ ' .$ pattern .'} ' , $ requestAttribute )) {
171
175
return false ;
172
176
}
173
177
}
Original file line number Diff line number Diff line change @@ -163,4 +163,17 @@ public function testAttributes()
163
163
$ matcher ->matchAttribute ('foo ' , 'babar ' );
164
164
$ this ->assertFalse ($ matcher ->matches ($ request ));
165
165
}
166
+
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
+ }
166
179
}
You can’t perform that action at this time.
0 commit comments