fix 14 PHPStan errors in console

This commit is contained in:
Art4 2025-03-13 12:37:30 +00:00
parent 2dfd7c83cf
commit bb6a4a3acd
3 changed files with 19 additions and 16 deletions

View file

@ -56,7 +56,7 @@ HELP;
return $help; return $help;
} }
public function __construct(Mode $appMode, array $argv = null) public function __construct(Mode $appMode, ?array $argv = null)
{ {
parent::__construct($argv); parent::__construct($argv);
@ -84,13 +84,13 @@ HELP;
switch ($command) { switch ($command) {
case 'add': case 'add':
return $this->addContact(); return ($this->addContact()) ? 0 : 1;
case 'remove': case 'remove':
return $this->removeContact(); return ($this->removeContact()) ? 0 : 1;
case 'search': case 'search':
return $this->searchContact(); return ($this->searchContact()) ? 0 : 1;
case 'terminate': case 'terminate':
return $this->terminateContact(); return ($this->terminateContact()) ? 0 : 1;
default: default:
throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.'); throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.');
} }
@ -206,7 +206,7 @@ HELP;
/** /**
* Marks a contact for removal * Marks a contact for removal
*/ */
private function removeContact() private function removeContact(): bool
{ {
$cid = $this->getArgument(1); $cid = $this->getArgument(1);
if (empty($cid)) { if (empty($cid)) {
@ -218,6 +218,8 @@ HELP;
} }
ContactModel::remove($cid); ContactModel::remove($cid);
return true;
} }
/** /**

View file

@ -106,21 +106,21 @@ HELP;
case 'password': case 'password':
return $this->password(); return $this->password();
case 'add': case 'add':
return $this->addUser(); return ($this->addUser()) ? 0 : 1;
case 'allow': case 'allow':
return $this->pendingUser(true); return ($this->pendingUser(true)) ? 0 : 1;
case 'deny': case 'deny':
return $this->pendingUser(false); return ($this->pendingUser(false)) ? 0 : 1;
case 'block': case 'block':
return $this->blockUser(true); return ($this->blockUser(true)) ? 0 : 1;
case 'unblock': case 'unblock':
return $this->blockUser(false); return ($this->blockUser(false)) ? 0 : 1;
case 'delete': case 'delete':
return $this->deleteUser(); return ($this->deleteUser()) ? 0 : 1;
case 'list': case 'list':
return $this->listUser(); return ($this->listUser()) ? 0 : 1;
case 'search': case 'search':
return $this->searchUser(); return ($this->searchUser()) ? 0 : 1;
case 'config': case 'config':
return ($this->configUser()) ? 0 : 1; return ($this->configUser()) ? 0 : 1;
default: default:
@ -178,7 +178,7 @@ HELP;
* *
* @throws \Exception * @throws \Exception
*/ */
private function password() private function password(): int
{ {
$user = $this->getUserByNick(1); $user = $this->getUserByNick(1);
@ -212,7 +212,7 @@ HELP;
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private function addUser() private function addUser(): bool
{ {
$name = $this->getArgument(1); $name = $this->getArgument(1);
$nick = $this->getArgument(2); $nick = $this->getArgument(2);

View file

@ -92,6 +92,7 @@ class PageInfo
{ {
$eventDispatcher = DI::eventDispatcher(); $eventDispatcher = DI::eventDispatcher();
/** @var array<string,mixed> */
$data = $eventDispatcher->dispatch( $data = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::PAGE_INFO, $data), new ArrayFilterEvent(ArrayFilterEvent::PAGE_INFO, $data),
)->getArray(); )->getArray();