File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed 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)
167167 }
168168
169169 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 )) {
171175 return false ;
172176 }
173177 }
Original file line number Diff line number Diff line change @@ -163,4 +163,17 @@ public function testAttributes()
163163 $ matcher ->matchAttribute ('foo ' , 'babar ' );
164164 $ this ->assertFalse ($ matcher ->matches ($ request ));
165165 }
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+ }
166179}
You can’t perform that action at this time.
0 commit comments