Skip to content

Commit

Permalink
Fix for PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Dec 29, 2024
1 parent 460ee40 commit e822afb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 4 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
2 changes: 1 addition & 1 deletion src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function path(array $parameters = []): string
* @throws InvalidRouteParameterException If the host or the parameter value does not match its regexp.
* @psalm-suppress PossiblyNullArgument
*/
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;

Check failure on line 343 in src/Route.php

View workflow job for this annotation

GitHub Actions / PHP 8.3-ubuntu-latest

RiskyTruthyFalsyComparison

src/Route.php:343:17: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 343 in src/Route.php

View workflow job for this annotation

GitHub Actions / PHP 7.4-ubuntu-latest

RiskyTruthyFalsyComparison

src/Route.php:343:17: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 343 in src/Route.php

View workflow job for this annotation

GitHub Actions / PHP 8.1-ubuntu-latest

RiskyTruthyFalsyComparison

src/Route.php:343:17: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 343 in src/Route.php

View workflow job for this annotation

GitHub Actions / PHP 8.0-ubuntu-latest

RiskyTruthyFalsyComparison

src/Route.php:343:17: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)

Check failure on line 343 in src/Route.php

View workflow job for this annotation

GitHub Actions / PHP 8.3-ubuntu-latest

RiskyTruthyFalsyComparison

src/Route.php:343:17: RiskyTruthyFalsyComparison: Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
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 e822afb

Please sign in to comment.