2424use Cake \Log \Log ;
2525use Cake \ORM \TableRegistry ;
2626use Cake \Routing \Router ;
27+ use Cake \Http \Response ;
2728use InvalidArgumentException ;
2829
2930use function __ ;
@@ -63,12 +64,11 @@ public function initialize(): void
6364 * @param int $reportId The report number
6465 *
6566 * @throws NotFoundException
66- * @return void Nothing
6767 */
68- public function create_issue ($ reportId ): void
68+ public function create_issue ($ reportId ): ? Response
6969 {
7070 if (empty ($ reportId )) {
71- throw new NotFoundException (__ ( 'Invalid report Id. ' ) );
71+ throw new NotFoundException ('Invalid report Id. ' );
7272 }
7373
7474 $ reportId = (int ) $ reportId ;
@@ -77,15 +77,15 @@ public function create_issue($reportId): void
7777 $ report = $ reportsTable ->findById ($ reportId )->all ()->first ();
7878
7979 if (! $ report ) {
80- throw new NotFoundException (__ ( 'The report does not exist. ' ) );
80+ throw new NotFoundException ('The report does not exist. ' );
8181 }
8282
8383 $ reportArray = $ report ->toArray ();
8484 if (empty ($ this ->request ->getParsedBody ())) {
8585 $ this ->set ('error_name ' , $ reportArray ['error_name ' ]);
8686 $ this ->set ('error_message ' , $ reportArray ['error_message ' ]);
8787
88- return ;
88+ return null ;
8989 }
9090
9191 $ this ->disableAutoRender ();
@@ -113,7 +113,7 @@ public function create_issue($reportId): void
113113 $ report ->status = $ this ->getReportStatusFromIssueState ($ issueDetails ['state ' ]);
114114 $ reportsTable ->save ($ report );
115115
116- $ this ->redirect ([
116+ return $ this ->redirect ([
117117 '_name ' => 'reports:view ' ,
118118 'id ' => $ reportId ,
119119 ]);
@@ -123,6 +123,7 @@ public function create_issue($reportId): void
123123 $ this ->getErrors ($ issueDetails , $ status ),
124124 ['params ' => ['class ' => $ flash_class ]]
125125 );
126+ return null ;
126127 }
127128 }
128129
@@ -136,7 +137,7 @@ public function create_issue($reportId): void
136137 public function link_issue ($ reportId ): void
137138 {
138139 if (empty ($ reportId )) {
139- throw new NotFoundException (__ ( 'Invalid report Id. ' ) );
140+ throw new NotFoundException ('Invalid report Id. ' );
140141 }
141142
142143 $ reportId = (int ) $ reportId ;
@@ -145,12 +146,12 @@ public function link_issue($reportId): void
145146 $ report = $ reportsTable ->findById ($ reportId )->all ()->first ();
146147
147148 if (! $ report ) {
148- throw new NotFoundException (__ ( 'The report does not exist. ' ) );
149+ throw new NotFoundException ('The report does not exist. ' );
149150 }
150151
151152 $ ticket_id = intval ($ this ->request ->getQuery ('ticket_id ' ));
152153 if (! $ ticket_id ) {
153- throw new NotFoundException (__ ( 'Invalid Ticket ID!! ' ) );
154+ throw new NotFoundException ('Invalid Ticket ID!! ' );
154155 }
155156
156157 $ reportArray = $ report ->toArray ();
@@ -195,7 +196,7 @@ public function link_issue($reportId): void
195196 );
196197 }
197198
198- $ this ->redirect ([
199+ return $ this ->redirect ([
199200 '_name ' => 'reports:view ' ,
200201 'id ' => $ reportId ,
201202 ]);
@@ -206,12 +207,11 @@ public function link_issue($reportId): void
206207 *
207208 * @param int $reportId The report Id
208209 * @throws NotFoundException
209- * @return void Nothing
210210 */
211- public function unlink_issue ($ reportId ): void
211+ public function unlink_issue ($ reportId ): Response
212212 {
213213 if (empty ($ reportId )) {
214- throw new NotFoundException (__ ( 'Invalid report Id. ' ) );
214+ throw new NotFoundException ('Invalid report Id. ' );
215215 }
216216
217217 $ reportId = (int ) $ reportId ;
@@ -220,14 +220,14 @@ public function unlink_issue($reportId): void
220220 $ report = $ reportsTable ->findById ($ reportId )->all ()->first ();
221221
222222 if (! $ report ) {
223- throw new NotFoundException (__ ( 'The report does not exist. ' ) );
223+ throw new NotFoundException ('The report does not exist. ' );
224224 }
225225
226226 $ reportArray = $ report ->toArray ();
227227 $ ticket_id = $ reportArray ['sourceforge_bug_id ' ];
228228
229229 if (! $ ticket_id ) {
230- throw new NotFoundException (__ ( 'Invalid Ticket ID!! ' ) );
230+ throw new NotFoundException ('Invalid Ticket ID!! ' );
231231 }
232232
233233 // "formatted" text of the comment.
@@ -260,7 +260,7 @@ public function unlink_issue($reportId): void
260260 );
261261 }
262262
263- $ this ->redirect ([
263+ return $ this ->redirect ([
264264 '_name ' => 'reports:view ' ,
265265 'id ' => $ reportId ,
266266 ]);
@@ -487,9 +487,8 @@ protected function getReportStatusFromIssueState(string $issueState): string
487487 *
488488 * Can not (& should not) be directly accessed via web.
489489 *
490- * @return void Nothing
491490 */
492- public function sync_issue_status (): void
491+ public function sync_issue_status (): ? Response
493492 {
494493 if (! Configure::read ('CronDispatcher ' )) {
495494 $ flash_class = 'alert alert-error ' ;
@@ -498,9 +497,7 @@ public function sync_issue_status(): void
498497 ['params ' => ['class ' => $ flash_class ]]
499498 );
500499
501- $ this ->redirect ('/ ' );
502-
503- return ;
500+ return $ this ->redirect ('/ ' );
504501 }
505502
506503 $ this ->disableAutoRender ();
@@ -556,5 +553,7 @@ public function sync_issue_status(): void
556553 ['scope ' => 'cron_jobs ' ]
557554 );
558555 }
556+
557+ return null ;
559558 }
560559}
0 commit comments