File tree 2 files changed +13
-8
lines changed
src/Symfony/Component/HttpKernel
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -67,9 +67,15 @@ private function parseControllerDefinition(callable $controller): ?array
67
67
if (\is_object ($ controller )) {
68
68
$ r = new \ReflectionClass ($ controller );
69
69
70
+ try {
71
+ $ line = $ r ->getMethod ('__invoke ' )->getEndLine ();
72
+ } catch (\ReflectionException $ e ) {
73
+ $ line = $ r ->getEndLine ();
74
+ }
75
+
70
76
return [
71
77
'file ' => $ r ->getFileName (),
72
- 'line ' => $ r -> getEndLine () ,
78
+ 'line ' => $ line ,
73
79
];
74
80
}
75
81
Original file line number Diff line number Diff line change @@ -215,20 +215,19 @@ public function testHandleWhenTheControllerIsAStaticArray()
215
215
public function testHandleWhenTheControllerDoesNotReturnAResponse ()
216
216
{
217
217
$ dispatcher = new EventDispatcher ();
218
- $ kernel = $ this ->getHttpKernel ($ dispatcher , function () { return ' foo ' ; });
218
+ $ kernel = $ this ->getHttpKernel ($ dispatcher , function () {});
219
219
220
220
try {
221
221
$ kernel ->handle (new Request ());
222
222
223
223
$ this ->fail ('The kernel should throw an exception. ' );
224
224
} catch (ControllerDoesNotReturnResponseException $ e ) {
225
- }
225
+ $ first = $ e -> getTrace ()[ 0 ];
226
226
227
- $ first = $ e ->getTrace ()[0 ];
228
-
229
- // `file` index the array starting at 0, and __FILE__ starts at 1
230
- $ line = file ($ first ['file ' ])[$ first ['line ' ] - 2 ];
231
- $ this ->assertContains ('// call controller ' , $ line );
227
+ // `file` index the array starting at 0, and __FILE__ starts at 1
228
+ $ line = file ($ first ['file ' ])[$ first ['line ' ] - 2 ];
229
+ $ this ->assertContains ('// call controller ' , $ line );
230
+ }
232
231
}
233
232
234
233
public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered ()
You can’t perform that action at this time.
0 commit comments