Skip to content

Commit fe97317

Browse files
committed
Further fix for type hinting bug
1 parent 9a8fa6c commit fe97317

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [6.1.1] 2024-11
8+
9+
### Fixed
10+
- Further fixes for type hinting bug related to array based callables with a string class name.
11+
712
## [6.1.0] 2024-11
813

914
### Fixed

docs/_data/releases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
name: League\Route 6.x
2323
type: Current
2424
requires: PHP >= 8.1.0
25-
release: 6.1.0 - 2024-11
25+
release: 6.1.1 - 2024-11
2626
support: Ongoing
2727
url: /6.x/
2828
menu:

src/RouteCollectionInterface.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88

99
interface RouteCollectionInterface
1010
{
11-
public function delete(string $path, string|callable $handler): Route;
12-
public function get(string $path, string|callable $handler): Route;
13-
public function head(string $path, string|callable $handler): Route;
14-
public function map(string|array $method, string $path, string|callable|RequestHandlerInterface $handler): Route;
15-
public function options(string $path, string|callable $handler): Route;
16-
public function patch(string $path, string|callable $handler): Route;
17-
public function post(string $path, string|callable $handler): Route;
18-
public function put(string $path, string|callable $handler): Route;
11+
public function delete(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
12+
public function get(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
13+
public function head(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
14+
public function map(
15+
string|array $method,
16+
string $path,
17+
callable|array|string|RequestHandlerInterface $handler
18+
): Route;
19+
public function options(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
20+
public function patch(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
21+
public function post(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
22+
public function put(string $path, callable|array|string|RequestHandlerInterface $handler): Route;
1923
}

src/RouteCollectionTrait.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@ trait RouteCollectionTrait
1212
abstract public function map(
1313
string|array $method,
1414
string $path,
15-
string|callable|RequestHandlerInterface $handler
15+
callable|array|string|RequestHandlerInterface $handler
1616
): Route;
1717

18-
public function delete(string $path, string|callable $handler): Route
18+
public function delete(string $path, callable|array|string|RequestHandlerInterface $handler): Route
1919
{
2020
return $this->map(Request::METHOD_DELETE, $path, $handler);
2121
}
2222

23-
public function get(string $path, string|callable $handler): Route
23+
public function get(string $path, callable|array|string|RequestHandlerInterface $handler): Route
2424
{
2525
return $this->map(Request::METHOD_GET, $path, $handler);
2626
}
2727

28-
public function head(string $path, string|callable $handler): Route
28+
public function head(string $path, callable|array|string|RequestHandlerInterface $handler): Route
2929
{
3030
return $this->map(Request::METHOD_HEAD, $path, $handler);
3131
}
3232

33-
public function options(string $path, string|callable $handler): Route
33+
public function options(string $path, callable|array|string|RequestHandlerInterface $handler): Route
3434
{
3535
return $this->map(Request::METHOD_OPTIONS, $path, $handler);
3636
}
3737

38-
public function patch(string $path, string|callable $handler): Route
38+
public function patch(string $path, callable|array|string|RequestHandlerInterface $handler): Route
3939
{
4040
return $this->map(Request::METHOD_PATCH, $path, $handler);
4141
}
4242

43-
public function post(string $path, string|callable $handler): Route
43+
public function post(string $path, callable|array|string|RequestHandlerInterface $handler): Route
4444
{
4545
return $this->map(Request::METHOD_POST, $path, $handler);
4646
}
4747

48-
public function put(string $path, string|callable $handler): Route
48+
public function put(string $path, callable|array|string|RequestHandlerInterface $handler): Route
4949
{
5050
return $this->map(Request::METHOD_PUT, $path, $handler);
5151
}

src/RouteGroup.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ public function getPrefix(): string
4343
return $this->prefix;
4444
}
4545

46-
public function map(string|array $method, string $path, string|callable|RequestHandlerInterface $handler): Route
47-
{
46+
public function map(
47+
string|array $method,
48+
string $path,
49+
callable|array|string|RequestHandlerInterface $handler
50+
): Route {
4851
$path = ($path === '/') ? $this->prefix : $this->prefix . sprintf('/%s', ltrim($path, '/'));
4952
$route = $this->collection->map($method, $path, $handler);
5053

src/Router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
120120
public function map(
121121
string|array $method,
122122
string $path,
123-
string|callable|RequestHandlerInterface $handler
123+
callable|array|string|RequestHandlerInterface $handler
124124
): Route {
125125
$path = sprintf('/%s', ltrim($path, '/'));
126126
$route = new Route($method, $path, $handler);

0 commit comments

Comments
 (0)