Skip to content

Commit a76ee38

Browse files
authored
Merge pull request #397 from josbeir/fix-beforeredirect-type-hinting
Fix type hinting in beforeRedirect()
2 parents d8e2c31 + 821ac28 commit a76ee38

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/CodeCompletion/Task/ControllerEventsTask.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function create(): string {
3232
3333
use Cake\Event\EventInterface;
3434
use Cake\Http\Response;
35+
use Psr\Http\Message\UriInterface;
3536
3637
if (false) {
3738
class Controller {
@@ -69,7 +70,7 @@ protected function events(bool $returnType): string {
6970
$docBlockRedirect = <<<TXT
7071
/**
7172
* @param \Cake\Event\EventInterface \$event
72-
* @param array|string \$url
73+
* @param \Psr\Http\Message\UriInterface|array|string \$url
7374
* @param \Cake\Http\Response \$response
7475
*
7576
* @return void
@@ -93,7 +94,7 @@ protected function events(bool $returnType): string {
9394
{$docBlock}public function shutdown(EventInterface \$event)$type {
9495
}
9596
96-
{$docBlockRedirect}public function beforeRedirect(EventInterface \$event, \$url, Response \$response)$type {
97+
{$docBlockRedirect}public function beforeRedirect(EventInterface \$event, UriInterface|array|string \$url, Response \$response)$type {
9798
}
9899
TXT;
99100

tests/TestCase/CodeCompletion/Task/ControllerEventsTaskTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function testCollectLegacy(): void {
3131
3232
use Cake\Event\EventInterface;
3333
use Cake\Http\Response;
34+
use Psr\Http\Message\UriInterface;
3435
3536
if (false) {
3637
class Controller {
@@ -76,12 +77,12 @@ public function shutdown(EventInterface $event) {
7677
7778
/**
7879
* @param \Cake\Event\EventInterface $event
79-
* @param array|string $url
80+
* @param \Psr\Http\Message\UriInterface|array|string $url
8081
* @param \Cake\Http\Response $response
8182
*
8283
* @return void
8384
*/
84-
public function beforeRedirect(EventInterface $event, $url, Response $response) {
85+
public function beforeRedirect(EventInterface $event, UriInterface|array|string $url, Response $response) {
8586
}
8687
}
8788
@@ -128,12 +129,12 @@ public function shutdown(EventInterface $event) {
128129
129130
/**
130131
* @param \Cake\Event\EventInterface $event
131-
* @param array|string $url
132+
* @param \Psr\Http\Message\UriInterface|array|string $url
132133
* @param \Cake\Http\Response $response
133134
*
134135
* @return void
135136
*/
136-
public function beforeRedirect(EventInterface $event, $url, Response $response) {
137+
public function beforeRedirect(EventInterface $event, UriInterface|array|string $url, Response $response) {
137138
}
138139
}
139140
}
@@ -154,6 +155,7 @@ public function testCollect() {
154155
155156
use Cake\Event\EventInterface;
156157
use Cake\Http\Response;
158+
use Psr\Http\Message\UriInterface;
157159
158160
if (false) {
159161
class Controller {
@@ -174,12 +176,12 @@ public function shutdown(EventInterface $event): void {
174176
175177
/**
176178
* @param \Cake\Event\EventInterface $event
177-
* @param array|string $url
179+
* @param \Psr\Http\Message\UriInterface|array|string $url
178180
* @param \Cake\Http\Response $response
179181
*
180182
* @return void
181183
*/
182-
public function beforeRedirect(EventInterface $event, $url, Response $response): void {
184+
public function beforeRedirect(EventInterface $event, UriInterface|array|string $url, Response $response): void {
183185
}
184186
}
185187
@@ -201,12 +203,12 @@ public function shutdown(EventInterface $event): void {
201203
202204
/**
203205
* @param \Cake\Event\EventInterface $event
204-
* @param array|string $url
206+
* @param \Psr\Http\Message\UriInterface|array|string $url
205207
* @param \Cake\Http\Response $response
206208
*
207209
* @return void
208210
*/
209-
public function beforeRedirect(EventInterface $event, $url, Response $response): void {
211+
public function beforeRedirect(EventInterface $event, UriInterface|array|string $url, Response $response): void {
210212
}
211213
}
212214
}

0 commit comments

Comments
 (0)