diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-01-06 14:19:06 +0100 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-01-27 17:20:00 +0100 |
commit | d69531ac8ecabfaa2c915d5266d09971c0129a77 (patch) | |
tree | 876d8e19059e7b424cc29ef49167cdf9bf47db69 /lib | |
parent | 0c631830bba9ff49e5f281699cf2514ea2e4d54d (diff) | |
download | nextcloud-server-d69531ac8ecabfaa2c915d5266d09971c0129a77.tar.gz nextcloud-server-d69531ac8ecabfaa2c915d5266d09971c0129a77.zip |
Fix psalm not running
The issue was that we were using psalm/phar instead of vimeo/psalm. This
caused issue with the custom psalm plugin in buildd/psalm.
This is using the opportunity to also update the psalm version from 3.8
to 3.17 and the php-cs-fixer too.
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
26 files changed, 52 insertions, 37 deletions
diff --git a/lib/composer/composer/InstalledVersions.php b/lib/composer/composer/InstalledVersions.php index b3a4e1611e6..d50e0c9fcc4 100644 --- a/lib/composer/composer/InstalledVersions.php +++ b/lib/composer/composer/InstalledVersions.php @@ -20,12 +20,25 @@ use Composer\Semver\VersionParser; * * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * - * To require it's presence, you can require `composer-runtime-api ^2.0` + * To require its presence, you can require `composer-runtime-api ^2.0` */ class InstalledVersions { + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null + */ private static $installed; + + /** + * @var bool|null + */ private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> + */ private static $installedByVendor = array(); /** @@ -228,7 +241,7 @@ class InstalledVersions /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string} + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} */ public static function getRootPackage() { @@ -242,7 +255,7 @@ class InstalledVersions * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} */ public static function getRawData() { @@ -265,7 +278,7 @@ class InstalledVersions * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}> + * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> */ public static function getAllRawData() { @@ -288,7 +301,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data */ public static function reload($data) { @@ -298,7 +311,7 @@ class InstalledVersions /** * @return array[] - * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}> + * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}> */ private static function getInstalled() { diff --git a/lib/composer/composer/installed.php b/lib/composer/composer/installed.php index b811738fbd0..d4da958244b 100644 --- a/lib/composer/composer/installed.php +++ b/lib/composer/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../../', 'aliases' => array(), - 'reference' => '66144c300395458ff38b86e50cd92174443cd85e', + 'reference' => '63a9bc2aacf829563ac74abe29d4edf6ff31b8b1', 'name' => '__root__', 'dev' => false, ), @@ -16,7 +16,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../../', 'aliases' => array(), - 'reference' => '66144c300395458ff38b86e50cd92174443cd85e', + 'reference' => '63a9bc2aacf829563ac74abe29d4edf6ff31b8b1', 'dev_requirement' => false, ), ), diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index cdfb123179e..7f855c07d46 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -633,7 +633,7 @@ class AccountManager implements IAccountManager { } // the value col is limited to 255 bytes. It is used for searches only. - $value = $property['value'] ? Util::shortenMultibyteString($property['value'], 255) : ''; + $value = $property['value'] ? Util::shortenMultibyteString($property['value'], 255) : ''; $query->setParameter('name', $property['name']) ->setParameter('value', $value); diff --git a/lib/private/AppFramework/Http/Dispatcher.php b/lib/private/AppFramework/Http/Dispatcher.php index 6bbab42cb79..0f12dbda629 100644 --- a/lib/private/AppFramework/Http/Dispatcher.php +++ b/lib/private/AppFramework/Http/Dispatcher.php @@ -131,7 +131,7 @@ class Dispatcher { $numExecuted = $databaseStatsAfter['executed'] - $databaseStatsBefore['executed']; if ($numBuilt > 50) { - $this->logger->debug('Controller {class}::{method} created {count} QueryBuilder objects, please check if they are created inside a loop by accident.' , [ + $this->logger->debug('Controller {class}::{method} created {count} QueryBuilder objects, please check if they are created inside a loop by accident.', [ 'class' => get_class($controller), 'method' => $methodName, 'count' => $numBuilt, @@ -139,7 +139,7 @@ class Dispatcher { } if ($numExecuted > 100) { - $this->logger->warning('Controller {class}::{method} executed {count} queries.' , [ + $this->logger->warning('Controller {class}::{method} executed {count} queries.', [ 'class' => get_class($controller), 'method' => $methodName, 'count' => $numExecuted, diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index a95fd208155..ea4cbf3b2fb 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -302,7 +302,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return string */ public function getHeader(string $name): string { - $name = strtoupper(str_replace('-', '_',$name)); + $name = strtoupper(str_replace('-', '_', $name)); if (isset($this->server['HTTP_' . $name])) { return $this->server['HTTP_' . $name]; } diff --git a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php index 8bdbacda20b..5f683fa38ac 100644 --- a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php @@ -109,7 +109,7 @@ class RateLimitingMiddleware extends Middleware { */ public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof RateLimitExceededException) { - if (stripos($this->request->getHeader('Accept'),'html') === false) { + if (stripos($this->request->getHeader('Accept'), 'html') === false) { $response = new DataResponse([], $exception->getCode()); } else { $response = new TemplateResponse( diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index b7330976e12..cece8bdf900 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -357,8 +357,8 @@ class JobList implements IJobList { public function resetBackgroundJob(IJob $job): void { $query = $this->connection->getQueryBuilder(); $query->update('jobs') - ->set('last_run', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) - ->set('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) + ->set('last_run', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) + ->set('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)) ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId()), IQueryBuilder::PARAM_INT)); $query->executeStatement(); } diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index a0fba16998f..419bbb88e0c 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -93,7 +93,7 @@ class Manager implements IManager { */ public function getCollectionForUser(int $id, ?IUser $user): ICollection { $query = $this->connection->getQueryBuilder(); - $userId = $user instanceof IUser ? $user->getUID() : ''; + $userId = $user !== null ? $user->getUID() : ''; $query->select('*') ->from(self::TABLE_COLLECTIONS, 'c') @@ -114,7 +114,7 @@ class Manager implements IManager { } $access = $row['access'] === null ? null : (bool) $row['access']; - if ($user instanceof IUser) { + if ($user !== null) { return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access); } @@ -131,7 +131,7 @@ class Manager implements IManager { */ public function searchCollections(IUser $user, string $filter, int $limit = 50, int $start = 0): array { $query = $this->connection->getQueryBuilder(); - $userId = $user instanceof IUser ? $user->getUID() : ''; + $userId = $user->getUID(); $query->select('c.*', 'a.access') ->from(self::TABLE_COLLECTIONS, 'c') diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index 4d9b43d0787..334006d1706 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -136,7 +136,7 @@ class Adapter { /** * @throws \OCP\DB\Exception */ - public function insertIgnoreConflict(string $table,array $values) : int { + public function insertIgnoreConflict(string $table, array $values) : int { try { $builder = $this->conn->getQueryBuilder(); $builder->insert($table); diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index 1262fd4f1ab..9045aa7f879 100644 --- a/lib/private/DB/AdapterPgSql.php +++ b/lib/private/DB/AdapterPgSql.php @@ -43,7 +43,7 @@ class AdapterPgSql extends Adapter { return $statement; } - public function insertIgnoreConflict(string $table,array $values) : int { + public function insertIgnoreConflict(string $table, array $values) : int { if ($this->isPre9_5CompatMode() === true) { return parent::insertIgnoreConflict($table, $values); } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index f2d91065b9a..d7a219ff567 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1182,7 +1182,7 @@ class View { if ($result && in_array('delete', $hooks) and $result) { $this->removeUpdate($storage, $internalPath); } - if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') { + if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') { $this->writeUpdate($storage, $internalPath); } if ($result && in_array('touch', $hooks)) { diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 1189907eac9..61f506d2676 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -244,7 +244,7 @@ class Mailer implements IMailer { } [$name, $domain] = explode('@', $email, 2); - $domain = idn_to_ascii($domain, 0,INTL_IDNA_VARIANT_UTS46); + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); return $name.'@'.$domain; } diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index 8af6c5a4fa1..08880451a73 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -66,6 +66,7 @@ class Memcached extends Cache implements IMemcache { //\Memcached::OPT_BINARY_PROTOCOL => true, ]; // by default enable igbinary serializer if available + /** @psalm-suppress RedundantCondition */ if (\Memcached::HAVE_IGBINARY) { $defaultOptions[\Memcached::OPT_SERIALIZER] = \Memcached::SERIALIZER_IGBINARY; diff --git a/lib/private/Migration/BackgroundRepair.php b/lib/private/Migration/BackgroundRepair.php index 25026575d38..03a3d3f4a7c 100644 --- a/lib/private/Migration/BackgroundRepair.php +++ b/lib/private/Migration/BackgroundRepair.php @@ -97,7 +97,7 @@ class BackgroundRepair extends TimedJob { try { $repair->addStep($step); } catch (\Exception $ex) { - $this->logger->logException($ex,[ + $this->logger->logException($ex, [ 'app' => 'migration' ]); diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index d8bbc02e105..c707884355b 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -381,12 +381,12 @@ class Manager implements IManager { throw new \InvalidArgumentException('The given notification has been processed'); } - if (!($notification instanceof INotification) || !$notification->isValidParsed()) { + if (!$notification->isValidParsed()) { throw new \InvalidArgumentException('The given notification has not been handled'); } } - if (!($notification instanceof INotification) || !$notification->isValidParsed()) { + if (!$notification->isValidParsed()) { throw new \InvalidArgumentException('The given notification has not been handled'); } diff --git a/lib/private/Preview/MarkDown.php b/lib/private/Preview/MarkDown.php index e24bdb5959b..929f319f57d 100644 --- a/lib/private/Preview/MarkDown.php +++ b/lib/private/Preview/MarkDown.php @@ -43,7 +43,7 @@ class MarkDown extends TXT { return null; } - $content = stream_get_contents($content,3000); + $content = stream_get_contents($content, 3000); //don't create previews of empty text files if (trim($content) === '') { @@ -119,7 +119,7 @@ class MarkDown extends TXT { // Get rid of markdown symbols that we still needed for the font size $line = preg_replace('/^#*\s/', '', $line); - $wrappedText = wordwrap($line, $wordWrap,"\n"); + $wrappedText = wordwrap($line, $wordWrap, "\n"); $linesWrapped = count(explode("\n", $wrappedText)); imagettftext($image, $actualFontSize, 0, $x, $y, $textColor, $actualFontSize === $fontSize ? $fontFile : $fontFileBold, $wrappedText); $nextLineStart = (int)($linesWrapped * ceil($actualFontSize * 2)); diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index d55d32386a7..bb3af6b90de 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -62,7 +62,7 @@ class TXT extends ProviderV2 { return null; } - $content = stream_get_contents($content,3000); + $content = stream_get_contents($content, 3000); //don't create previews of empty text files if (trim($content) === '') { diff --git a/lib/private/Security/TrustedDomainHelper.php b/lib/private/Security/TrustedDomainHelper.php index 175e4cbd356..0688ebba5b3 100644 --- a/lib/private/Security/TrustedDomainHelper.php +++ b/lib/private/Security/TrustedDomainHelper.php @@ -98,7 +98,7 @@ class TrustedDomainHelper implements ITrustedDomainHelper { return true; } // Reject misformed domains in any case - if (strpos($domain,'-') === 0 || strpos($domain,'..') !== false) { + if (strpos($domain, '-') === 0 || strpos($domain, '..') !== false) { return false; } // Match, allowing for * wildcards diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index 8a12465fd8d..920baf3e4ee 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -125,7 +125,7 @@ class MySQL extends AbstractDatabase { $connection->executeUpdate($query); } } catch (\Exception $ex) { - $this->logger->error('Database user creation failed.',[ + $this->logger->error('Database user creation failed.', [ 'exception' => $ex, 'app' => 'mysql.setup', ]); diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 548c8a2c451..47b09982f3a 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -847,7 +847,7 @@ class Share extends Constants { * @param array $parameters additional format parameters * @return array format result */ - private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) { + private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE, $parameters = null) { if ($format === self::FORMAT_NONE) { return $items; } elseif ($format === self::FORMAT_STATUSES) { diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 85655c4e379..cfc4079e117 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -666,7 +666,7 @@ class DefaultShareProvider implements IShareProvider { ); } - $qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid')); + $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); $qb->orderBy('id'); diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 382179b23e0..753a4a217d1 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -187,7 +187,7 @@ class URLGenerator implements IURLGenerator { $theme = \OC_Util::getTheme(); //if a theme has a png but not an svg always use the png - $basename = substr(basename($file),0,-4); + $basename = substr(basename($file), 0, -4); $appPath = \OC_App::getAppPath($appName); diff --git a/lib/private/legacy/OC_DB.php b/lib/private/legacy/OC_DB.php index 1fbc233f535..39faf8e80aa 100644 --- a/lib/private/legacy/OC_DB.php +++ b/lib/private/legacy/OC_DB.php @@ -42,7 +42,7 @@ class OC_DB { * * SQL query via Doctrine prepare(), needs to be execute()'d! */ - public static function prepare($query , $limit = null, $offset = null, $isManipulation = null) { + public static function prepare($query, $limit = null, $offset = null, $isManipulation = null) { $connection = \OC::$server->getDatabaseConnection(); if ($isManipulation === null) { diff --git a/lib/private/legacy/OC_DB_StatementWrapper.php b/lib/private/legacy/OC_DB_StatementWrapper.php index d8e8f0ae37f..d6214a49a33 100644 --- a/lib/private/legacy/OC_DB_StatementWrapper.php +++ b/lib/private/legacy/OC_DB_StatementWrapper.php @@ -59,7 +59,7 @@ class OC_DB_StatementWrapper { /** * pass all other function directly to the \Doctrine\DBAL\Driver\Statement */ - public function __call($name,$arguments) { + public function __call($name, $arguments) { return call_user_func_array([$this->statement,$name], $arguments); } diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 1730539d6fd..6c9a37e1999 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -850,6 +850,7 @@ class OC_Util { ], ]; $missingDependencies = []; + /** @var array<array-key, bool|string|int> $invalidIniSettings */ $invalidIniSettings = []; $iniWrapper = \OC::$server->get(IniGetWrapper::class); @@ -895,7 +896,7 @@ class OC_Util { } foreach ($invalidIniSettings as $setting) { if (is_bool($setting[1])) { - $setting[1] = $setting[1] ? 'on' : 'off'; + $setting[1] = $setting[1] === true ? 'on' : 'off'; } $errors[] = [ 'error' => $l->t('PHP setting "%s" is not set to "%s".', [$setting[0], var_export($setting[1], true)]), diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index 2fa7fa1ad36..d12baa400c0 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -188,7 +188,7 @@ interface IDBConnection { * @return int number of inserted rows * @since 16.0.0 */ - public function insertIgnoreConflict(string $table,array $values) : int; + public function insertIgnoreConflict(string $table, array $values) : int; /** * Insert or update a row value |