Skip to content

Commit

Permalink
Fix for PHP 8.4 (#3)
Browse files Browse the repository at this point in the history
* Fix for PHP 8.4

* Fix psalm
  • Loading branch information
devanych authored Dec 29, 2024
1 parent 460ee40 commit 31a7a20
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

steps:
- name: Checkout.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"

steps:
- name: Checkout.
Expand Down
7 changes: 4 additions & 3 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function match(ServerRequestInterface $request): bool
* @param array $parameters parameter-value set.
* @return string URL path generated.
* @throws InvalidRouteParameterException if the value does not match its regexp or the required parameter is null.
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedAssignment, RiskyTruthyFalsyComparison
*/
public function path(array $parameters = []): string
{
Expand Down Expand Up @@ -335,9 +335,9 @@ public function path(array $parameters = []): string
* @param bool|null $secure if `true`, then `https`. If `false`, then `http`. If `null`, then without the protocol.
* @return string URL generated.
* @throws InvalidRouteParameterException If the host or the parameter value does not match its regexp.
* @psalm-suppress PossiblyNullArgument
* @psalm-suppress PossiblyNullArgument, RiskyTruthyFalsyComparison
*/
public function url(array $parameters = [], string $host = null, bool $secure = null): string
public function url(array $parameters = [], ?string $host = null, ?bool $secure = null): string
{
$path = $this->path($parameters);
$host = $host ? trim($host, '/') : null;
Expand Down Expand Up @@ -435,6 +435,7 @@ private function normalizeParameter($value, string $name, string $pattern, bool
*
* @param string $host
* @return bool
* @psalm-suppress RiskyTruthyFalsyComparison
*/
private function isMatchedHost(string $host): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function path(string $name, array $parameters = []): string
/**
* {@inheritDoc}
*/
public function url(string $name, array $parameters = [], string $host = null, bool $secure = null): string
public function url(string $name, array $parameters = [], ?string $host = null, ?bool $secure = null): string
{
$route = $this->get($name);
return $route->url($parameters, $host, $secure);
Expand Down
2 changes: 1 addition & 1 deletion src/RouteCollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ public function path(string $name, array $parameters = []): string;
* @return string URL generated.
* @throws RouteNotFoundException if the route does not exist.
*/
public function url(string $name, array $parameters = [], string $host = null, bool $secure = null): string;
public function url(string $name, array $parameters = [], ?string $host = null, ?bool $secure = null): string;
}
2 changes: 1 addition & 1 deletion src/RouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class RouteCollector
/**
* @param RouteCollectionInterface|null $routes
*/
public function __construct(RouteCollectionInterface $routes = null)
public function __construct(?RouteCollectionInterface $routes = null)
{
$this->routes = $routes ?? new RouteCollection();
}
Expand Down

0 comments on commit 31a7a20

Please sign in to comment.