diff --git a/lib/Command/SendEmails.php b/lib/Command/SendEmails.php index 6aacc1f1..e8eb3da6 100644 --- a/lib/Command/SendEmails.php +++ b/lib/Command/SendEmails.php @@ -81,14 +81,11 @@ public function execute(InputInterface $input, OutputInterface $output): int { do { $users = $this->mqHandler->getAllUsers(self::BATCH_SIZE); $batchCount = \count($users); - if ($batchCount === 0) { - // queue is empty - break; - } - - $this->sendBatch($users, $output); - if ($progress !== null) { - $progress->advance($batchCount); + if ($batchCount > 0) { + $this->sendBatch($users, $output); + if ($progress !== null) { + $progress->advance($batchCount); + } } } while ($batchCount > 0); diff --git a/lib/Controller/OCSEndPoint.php b/lib/Controller/OCSEndPoint.php index 104032e2..ffd0ade4 100644 --- a/lib/Controller/OCSEndPoint.php +++ b/lib/Controller/OCSEndPoint.php @@ -56,7 +56,7 @@ class OCSEndPoint { protected $objectId; /** @var string */ - protected $user; + protected $user = ''; /** @var bool */ protected $loadPreviews; diff --git a/lib/Data.php b/lib/Data.php index 47b58846..7adfd00e 100755 --- a/lib/Data.php +++ b/lib/Data.php @@ -85,6 +85,7 @@ public function getNotificationTypes(IL10N $l) { * @return bool */ public function send(IEvent $event) { + // @phpstan-ignore identical.alwaysFalse if ($event->getAffectedUser() === '' || $event->getAffectedUser() === null) { return false; } @@ -137,6 +138,7 @@ public function send(IEvent $event) { * @return bool */ public function storeMail(IEvent $event, $latestSendTime) { + // @phpstan-ignore identical.alwaysFalse if ($event->getAffectedUser() === '' || $event->getAffectedUser() === null) { return false; } diff --git a/lib/DataHelper.php b/lib/DataHelper.php index 85d4049f..95262687 100644 --- a/lib/DataHelper.php +++ b/lib/DataHelper.php @@ -177,6 +177,7 @@ public function createCollection() { * @return array List of Parameters */ public function parseParameters($parameterString) { + // @phpstan-ignore function.alreadyNarrowedType if (!\is_string($parameterString)) { return []; } diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index bff838b8..a2629fb4 100755 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -681,6 +681,7 @@ protected function shareNotificationForOriginalOwners($currentOwner, $subject, $ */ $this->view->chroot('/' . $currentOwner . '/files'); $mount = $this->view->getMount($path); + // @phpstan-ignore instanceof.alwaysTrue if (!($mount instanceof IMountPoint)) { return; } @@ -742,6 +743,7 @@ protected function addNotificationsForUser($user, $subject, $subjectParams, $fil $event->setAuthor($agentAuthor); } + // @phpstan-ignore identical.alwaysFalse if ($event->getAuthor() === null) { $event->setAuthor($this->currentUser); } diff --git a/lib/PlainTextParser.php b/lib/PlainTextParser.php index dc5fdcf1..05066ce3 100644 --- a/lib/PlainTextParser.php +++ b/lib/PlainTextParser.php @@ -53,6 +53,8 @@ public function parseMessage($message) { * @return string */ protected function parseCollections($message) { + // @phpstan-ignore nullCoalesce.variable + $message = $message ?? ''; return \preg_replace_callback('/(.*?)<\/collection>/', function ($match) { $parameterList = \explode('><', $match[1]); $parameterListLength = \sizeof($parameterList); diff --git a/lib/UserSettings.php b/lib/UserSettings.php index 58af6e3c..924ec372 100644 --- a/lib/UserSettings.php +++ b/lib/UserSettings.php @@ -138,6 +138,7 @@ public function getNotificationTypes($user, $method) { * Returns a "username => i:batchtime" Map for method = email */ public function filterUsersBySetting($users, $method, $type) { + // @phpstan-ignore function.alreadyNarrowedType if (empty($users) || !\is_array($users)) { return []; } diff --git a/phpstan.neon b/phpstan.neon index 0b7355bf..b1406769 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,30 +3,18 @@ parameters: - %currentWorkingDirectory%/../../lib/base.php ignoreErrors: - - message: '#Variable \$this might not be defined.#' + rawMessage: 'Variable $this might not be defined.' path: appinfo/routes.php count: 1 - - message: '#Comparison operation ">" between int<1, max> and 0 is always true.#' - path: lib/Command/SendEmails.php - count: 1 - - - message: '#Strict comparison using === between non-empty-string and null will always evaluate to false.#' - path: lib/Data.php - count: 2 - - - message: '#Method OCP\\DB\\QueryBuilder\\IExpressionBuilder::orX\(\) invoked with 2 parameters, 0-1 required.#' + rawMessage: 'Method OCP\DB\QueryBuilder\IExpressionBuilder::orX() invoked with 2 parameters, 0-1 required.' path: lib/Data.php count: 3 - - message: '#Call to method getSharedFrom\(\) on an unknown class OC\\Files\\Storage\\Shared.#' - path: lib/FilesHooks.php - count: 1 - - - message: '#PHPDoc tag @var for variable \$storage contains unknown class OC\\Files\\Storage\\Shared.#' + rawMessage: 'Call to method getSharedFrom() on an unknown class OC\Files\Storage\Shared.' path: lib/FilesHooks.php count: 1 - - message: '#Strict comparison using === between string and null will always evaluate to false.#' + rawMessage: 'PHPDoc tag @var for variable $storage contains unknown class OC\Files\Storage\Shared.' path: lib/FilesHooks.php count: 1 diff --git a/vendor-bin/phan/composer.json b/vendor-bin/phan/composer.json index 90031218..3bbe097d 100644 --- a/vendor-bin/phan/composer.json +++ b/vendor-bin/phan/composer.json @@ -1,5 +1,5 @@ { "require": { - "phan/phan": "^5.4" + "phan/phan": "^5.5" } } diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index 90c99dfd..5b6f57e1 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,5 +1,5 @@ { "require": { - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^2.2" } }