Skip to content

Commit

Permalink
[Console] Prevent PHP 8.1 str_replace deprec on null
Browse files Browse the repository at this point in the history
Prevents:

> Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

on `getDefaultName()` returning `null`
  • Loading branch information
ogizanagi committed Jun 6, 2022
1 parent 40663b4 commit 9481924
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion DependencyInjection/AddConsoleCommandPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function process(ContainerBuilder $container)
if (!$r->isSubclassOf(Command::class)) {
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
}
$aliases = str_replace('%', '%%', $class::getDefaultName());
$aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
}

$aliases = explode('|', $aliases ?? '');
Expand Down

0 comments on commit 9481924

Please sign in to comment.