]> git.mxchange.org Git - friendica.git/commitdiff
fix 14 PHPStan errors in console
authorArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 12:37:30 +0000 (12:37 +0000)
committerArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 12:37:30 +0000 (12:37 +0000)
src/Console/Contact.php
src/Console/User.php
src/Content/PageInfo.php

index 81730548263c5adf6cc8a09af4eb688b38165a0c..d54979c11b4b16dc0c6af57d418f15220a889036 100644 (file)
@@ -56,7 +56,7 @@ HELP;
                return $help;
        }
 
-       public function __construct(Mode $appMode, array $argv = null)
+       public function __construct(Mode $appMode, ?array $argv = null)
        {
                parent::__construct($argv);
 
@@ -84,13 +84,13 @@ HELP;
 
                switch ($command) {
                        case 'add':
-                               return $this->addContact();
+                               return ($this->addContact()) ? 0 : 1;
                        case 'remove':
-                               return $this->removeContact();
+                               return ($this->removeContact()) ? 0 : 1;
                        case 'search':
-                               return $this->searchContact();
+                               return ($this->searchContact()) ? 0 : 1;
                        case 'terminate':
-                               return $this->terminateContact();
+                               return ($this->terminateContact()) ? 0 : 1;
                        default:
                                throw new \Asika\SimpleConsole\CommandArgsException('Wrong command.');
                }
@@ -206,7 +206,7 @@ HELP;
        /**
         * Marks a contact for removal
         */
-       private function removeContact()
+       private function removeContact(): bool
        {
                $cid = $this->getArgument(1);
                if (empty($cid)) {
@@ -218,6 +218,8 @@ HELP;
                }
 
                ContactModel::remove($cid);
+
+               return true;
        }
 
        /**
index 89c217694d09fe0d68ba798be337d45b1f47aaf8..5a8f62cc8c612379f0345919cb128525c2e106ce 100644 (file)
@@ -106,21 +106,21 @@ HELP;
                        case 'password':
                                return $this->password();
                        case 'add':
-                               return $this->addUser();
+                               return ($this->addUser()) ? 0 : 1;
                        case 'allow':
-                               return $this->pendingUser(true);
+                               return ($this->pendingUser(true)) ? 0 : 1;
                        case 'deny':
-                               return $this->pendingUser(false);
+                               return ($this->pendingUser(false)) ? 0 : 1;
                        case 'block':
-                               return $this->blockUser(true);
+                               return ($this->blockUser(true)) ? 0 : 1;
                        case 'unblock':
-                               return $this->blockUser(false);
+                               return ($this->blockUser(false)) ? 0 : 1;
                        case 'delete':
-                               return $this->deleteUser();
+                               return ($this->deleteUser()) ? 0 : 1;
                        case 'list':
-                               return $this->listUser();
+                               return ($this->listUser()) ? 0 : 1;
                        case 'search':
-                               return $this->searchUser();
+                               return ($this->searchUser()) ? 0 : 1;
                        case 'config':
                                return ($this->configUser()) ? 0 : 1;
                        default:
@@ -178,7 +178,7 @@ HELP;
         *
         * @throws \Exception
         */
-       private function password()
+       private function password(): int
        {
                $user = $this->getUserByNick(1);
 
@@ -212,7 +212,7 @@ HELP;
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       private function addUser()
+       private function addUser(): bool
        {
                $name   = $this->getArgument(1);
                $nick   = $this->getArgument(2);
index 4d2a1180d3132b09f00787aa40371801c973615f..a53c36b68c1aa38b5ea3d221536c71c3997050af 100644 (file)
@@ -92,6 +92,7 @@ class PageInfo
        {
                $eventDispatcher = DI::eventDispatcher();
 
+               /** @var array<string,mixed> */
                $data = $eventDispatcher->dispatch(
                        new ArrayFilterEvent(ArrayFilterEvent::PAGE_INFO, $data),
                )->getArray();