Fix a few psalm issues and moved back to psalm/phar 4.18

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-01-06 16:57:32 +01:00
parent 47c9c34cca
commit aeecb72e96
No known key found for this signature in database
GPG Key ID: 06B35D38387B67BE
27 changed files with 507 additions and 1727 deletions

View File

@ -237,7 +237,7 @@ class Crypt {
$encryptedContent = openssl_encrypt($plainContent,
$cipher,
$passPhrase,
false,
0,
$iv);
if (!$encryptedContent) {
@ -617,7 +617,7 @@ class Crypt {
$plainContent = openssl_decrypt($encryptedContent,
$cipher,
$passPhrase,
false,
0,
$iv);
if ($plainContent) {

View File

@ -159,7 +159,7 @@ class KeyManager {
$this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId);
}
$this->keyId = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false;
$this->keyId = $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false;
$this->log = $log;
}

View File

@ -62,8 +62,8 @@ class SetMasterKeyStatus implements IRepairStep {
// if no config for the master key is set we set it explicitly to '0' in
// order not to break old installations because the default changed to '1'.
$configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false);
if ($configAlreadySet === false) {
$configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', 'not-set');
if ($configAlreadySet === 'not-set') {
$this->config->setAppValue('encryption', 'useMasterKey', '0');
}
}

View File

@ -76,7 +76,7 @@ class Recovery {
IConfig $config,
IFile $file,
View $view) {
$this->user = ($userSession && $userSession->isLoggedIn()) ? $userSession->getUser() : false;
$this->user = ($userSession->isLoggedIn()) ? $userSession->getUser() : null;
$this->crypt = $crypt;
$this->keyManager = $keyManager;
$this->config = $config;

View File

@ -27,7 +27,7 @@ namespace OCA\Files_External\Lib\Storage;
* Low level wrapper around the ftp functions that smooths over some difference between servers
*/
class FtpConnection {
/** @var resource */
/** @var resource|\FTP\Connection */
private $connection;
public function __construct(bool $secure, string $hostname, int $port, string $username, string $password) {

View File

@ -39,10 +39,7 @@ class CheckUserCertificates {
public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
$this->l10n = $l10n;
$configValue = $config->getAppValue('files_external', 'user_certificate_scan', false);
if (!is_string($configValue)) {
$configValue = '';
}
$configValue = $config->getAppValue('files_external', 'user_certificate_scan', '');
$this->configValue = $configValue;
$this->urlGenerator = $urlGenerator;
}

View File

@ -1753,7 +1753,7 @@ class Access extends LDAPUtility {
}
$attribute = $this->connection->getFromCache($uuidAttr);
if (!$attribute === null) {
if ($attribute !== null) {
$this->connection->$uuidAttr = $attribute;
return true;
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.8.1@f73f2299dbc59a3e6c4d66cff4605176e728ee69">
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
<file src="lib/private/legacy/OC_Image.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|string</code>
@ -220,7 +220,9 @@
<InvalidReturnType occurrences="1">
<code>float</code>
</InvalidReturnType>
<UndefinedClass occurrences="12">
<UndefinedClass occurrences="14">
<code>\OC</code>
<code>\OC</code>
<code>\OC</code>
<code>\OC</code>
<code>\OC</code>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.17.0@6f4707aa41c9174353a6434bba3fc8840f981d9c">
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
<file src="3rdparty/sabre/dav/lib/CalDAV/Calendar.php">
<MoreSpecificImplementedParamType occurrences="1">
<code>$calendarData</code>
@ -36,6 +36,11 @@
<code>array</code>
</LessSpecificImplementedReturnType>
</file>
<file src="apps/admin_audit/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/cloud_federation_api/lib/Controller/RequestHandlerController.php">
<InvalidScalarArgument occurrences="1">
<code>$e-&gt;getCode()</code>
@ -44,6 +49,12 @@
<code>!is_array($notification)</code>
</TypeDoesNotContainType>
</file>
<file src="apps/comments/lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/comments/lib/Search/Result.php">
<InvalidScalarArgument occurrences="1">
<code>(int) $comment-&gt;getId()</code>
@ -54,6 +65,11 @@
<code>\Sabre\Uri\split($this-&gt;principalUri)</code>
</UndefinedFunction>
</file>
<file src="apps/contactsinteraction/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/dav/appinfo/v1/caldav.php">
<TooManyArguments occurrences="1">
<code>new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')</code>
@ -112,6 +128,36 @@
</MissingFile>
</file>
<file src="apps/dav/lib/AppInfo/Application.php">
<InvalidArgument occurrences="28">
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
<UndefinedInterfaceMethod occurrences="1">
<code>getAppDataDir</code>
</UndefinedInterfaceMethod>
@ -314,6 +360,11 @@
<code>@var VEvent $vevent</code>
</PossiblyInvalidDocblockTag>
</file>
<file src="apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php">
<UndefinedConstant occurrences="1">
<code>$provider::NOTIFICATION_TYPE</code>
</UndefinedConstant>
</file>
<file src="apps/dav/lib/CalDAV/Reminder/Notifier.php">
<FalsableReturnStatement occurrences="4">
<code>$this-&gt;l10n-&gt;l('date', $dt, ['width' =&gt; 'medium'])</code>
@ -1005,6 +1056,9 @@
<InvalidReturnType occurrences="1">
<code>array</code>
</InvalidReturnType>
<RedundantFunctionCall occurrences="1">
<code>array_values</code>
</RedundantFunctionCall>
</file>
<file src="apps/dav/lib/Upload/UploadHome.php">
<UndefinedFunction occurrences="1">
@ -1022,7 +1076,8 @@
</InvalidOperand>
</file>
<file src="apps/encryption/lib/Crypto/Crypt.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="2">
@ -1058,9 +1113,6 @@
<InvalidThrow occurrences="1">
<code>throw $exception;</code>
</InvalidThrow>
<RedundantCondition occurrences="1">
<code>$userSession</code>
</RedundantCondition>
</file>
<file src="apps/encryption/lib/Recovery.php">
<InvalidScalarArgument occurrences="3">
@ -1068,9 +1120,6 @@
<code>0</code>
<code>1</code>
</InvalidScalarArgument>
<RedundantCondition occurrences="1">
<code>$userSession</code>
</RedundantCondition>
</file>
<file src="apps/encryption/lib/Session.php">
<TooManyArguments occurrences="1">
@ -1078,10 +1127,16 @@
</TooManyArguments>
</file>
<file src="apps/encryption/lib/Util.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
</file>
<file src="apps/federatedfilesharing/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/federatedfilesharing/lib/Controller/RequestHandlerController.php">
<InvalidScalarArgument occurrences="7">
<code>$id</code>
@ -1136,6 +1191,11 @@
<code>null</code>
</NullableReturnStatement>
</file>
<file src="apps/federation/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/federation/lib/TrustedServers.php">
<InvalidArgument occurrences="1">
<code>'OCP\Federation\TrustedServerEvent::remove'</code>
@ -1180,6 +1240,12 @@
<code>10 * 1024 * 1024</code>
</InvalidScalarArgument>
</file>
<file src="apps/files/lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/files/lib/Command/Scan.php">
<NullArgument occurrences="1">
<code>null</code>
@ -1269,6 +1335,12 @@
<code>$this</code>
</InvalidScope>
</file>
<file src="apps/files_external/lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/files_external/lib/Command/Delete.php">
<NullArgument occurrences="1">
<code>null</code>
@ -1318,6 +1390,12 @@
<code>getUniqueStorages</code>
</UndefinedMethod>
</file>
<file src="apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php">
<InvalidArgument occurrences="2">
<code>addServiceListener</code>
<code>addServiceListener</code>
</InvalidArgument>
</file>
<file src="apps/files_external/lib/Lib/Backend/Backend.php">
<InvalidReturnType occurrences="1">
<code>self</code>
@ -1506,6 +1584,16 @@
<code>$_</code>
</UndefinedVariable>
</file>
<file src="apps/files_sharing/lib/AppInfo/Application.php">
<InvalidArgument occurrences="6">
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
</InvalidArgument>
</file>
<file src="apps/files_sharing/lib/Cache.php">
<FalsableReturnStatement occurrences="1">
<code>false</code>
@ -1525,11 +1613,17 @@
</UndefinedInterfaceMethod>
</file>
<file src="apps/files_sharing/lib/Controller/ShareAPIController.php">
<InvalidOperand occurrences="1">
<code>$permissions</code>
</InvalidOperand>
<InvalidScalarArgument occurrences="3">
<code>$code</code>
<code>$code</code>
<code>Constants::PERMISSION_ALL</code>
</InvalidScalarArgument>
<RedundantCondition occurrences="1">
<code>$permissions &amp; Constants::PERMISSION_READ</code>
</RedundantCondition>
<UndefinedClass occurrences="2">
<code>\OCA\Circles\Api\v1\Circles</code>
<code>\OCA\Circles\Api\v1\Circles</code>
@ -1597,6 +1691,11 @@
<code>$exception-&gt;getMessage()</code>
</InvalidArgument>
</file>
<file src="apps/files_sharing/lib/MountProvider.php">
<RedundantFunctionCall occurrences="1">
<code>array_values</code>
</RedundantFunctionCall>
</file>
<file src="apps/files_sharing/lib/ShareBackend/File.php">
<InvalidScalarArgument occurrences="2">
<code>$itemSource</code>
@ -1709,9 +1808,13 @@
</TooManyArguments>
</file>
<file src="apps/files_trashbin/lib/Trash/LegacyTrashBackend.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$trashFiles</code>
<code>$trashFiles</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="1">
<code>null</code>
</TypeDoesNotContainType>
<UndefinedInterfaceMethod occurrences="2">
<code>$file</code>
<code>getById</code>
@ -1735,6 +1838,12 @@
<code>$this</code>
</InvalidScope>
</file>
<file src="apps/files_versions/lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/files_versions/lib/Sabre/RestoreFolder.php">
<InvalidNullableReturnType occurrences="1">
<code>getChild</code>
@ -1778,6 +1887,11 @@
<file src="apps/oauth2/lib/Db/ClientMapper.php">
<InvalidCatch occurrences="2"/>
</file>
<file src="apps/provisioning_api/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/provisioning_api/lib/Controller/UsersController.php">
<InvalidScalarArgument occurrences="1">
<code>$quota</code>
@ -1788,6 +1902,11 @@
</TypeDoesNotContainNull>
</file>
<file src="apps/settings/lib/AppInfo/Application.php">
<InvalidArgument occurrences="3">
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="1">
<code>\OC_User::getUser()</code>
</InvalidScalarArgument>
@ -1829,6 +1948,11 @@
<code>isReady</code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/settings/lib/Settings/Admin/Server.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
</file>
<file src="apps/settings/lib/Settings/Admin/Sharing.php">
<InvalidScalarArgument occurrences="1">
<code>Constants::PERMISSION_ALL</code>
@ -1865,6 +1989,11 @@
<code>$type</code>
</InvalidScalarArgument>
</file>
<file src="apps/theming/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/theming/lib/Controller/IconController.php">
<InvalidReturnStatement occurrences="1">
<code>$response</code>
@ -1905,6 +2034,14 @@
<code>$folder !== null</code>
</RedundantCondition>
</file>
<file src="apps/twofactor_backupcodes/lib/AppInfo/Application.php">
<InvalidArgument occurrences="4">
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/twofactor_backupcodes/lib/BackgroundJob/RememberBackupCodesJob.php">
<InvalidArgument occurrences="1">
<code>bool</code>
@ -1922,6 +2059,9 @@
</InvalidScalarArgument>
</file>
<file src="apps/updatenotification/lib/Notification/BackgroundJob.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$this-&gt;users</code>
</InvalidPropertyAssignmentValue>
@ -2122,7 +2262,6 @@
</InvalidPropertyAssignmentValue>
<InvalidReturnType occurrences="1">
<code>null</code>
<code>null</code>
</InvalidReturnType>
<InvalidScalarArgument occurrences="3">
<code>$this-&gt;getHomePath($ldapEntry[$attr][0])</code>
@ -2181,10 +2320,20 @@
</TypeDoesNotContainType>
</file>
<file src="apps/user_status/lib/AppInfo/Application.php">
<InvalidArgument occurrences="3">
<code>registerEventListener</code>
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
<UndefinedInterfaceMethod occurrences="1">
<code>registerProvider</code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/workflowengine/lib/AppInfo/Application.php">
<InvalidArgument occurrences="1">
<code>registerEventListener</code>
</InvalidArgument>
</file>
<file src="apps/workflowengine/lib/Check/AbstractStringCheck.php">
<NullArgument occurrences="1">
<code>null</code>
@ -2279,6 +2428,19 @@
<code>isUserScopeEnabled</code>
</UndefinedInterfaceMethod>
</file>
<file src="core/Application.php">
<InvalidArgument occurrences="9">
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
</InvalidArgument>
</file>
<file src="core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php">
<ParamNameMismatch occurrences="1">
<code>$arguments</code>
@ -2294,14 +2456,6 @@
<code>$arguments</code>
</ParamNameMismatch>
</file>
<file src="core/Command/App/GetPath.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
</file>
<file src="core/Command/App/Install.php">
<TypeDoesNotContainType occurrences="1">
<code>$result === false</code>
@ -2312,14 +2466,6 @@
<code>array</code>
</LessSpecificImplementedReturnType>
</file>
<file src="core/Command/Config/App/GetConfig.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
</file>
<file src="core/Command/Config/Import.php">
<InvalidScalarArgument occurrences="2">
<code>0</code>
@ -2334,14 +2480,6 @@
<code>getFilteredValues</code>
</TooManyArguments>
</file>
<file src="core/Command/Config/System/GetConfig.php">
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
</file>
<file src="core/Command/Db/AddMissingColumns.php">
<InvalidArgument occurrences="1">
<code>IDBConnection::ADD_MISSING_COLUMNS_EVENT</code>
@ -2497,13 +2635,19 @@
<code>$this</code>
</InvalidScope>
</file>
<file src="core/templates/layout.guest.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
</file>
<file src="core/templates/layout.public.php">
<UndefinedInterfaceMethod occurrences="1">
<code>getIcon</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/autoloader.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$this-&gt;memoryCache</code>
<code>$this-&gt;memoryCache</code>
</RedundantCondition>
</file>
@ -2512,8 +2656,10 @@
<code>getAppsNeedingUpgrade</code>
<code>getIncompatibleApps</code>
</InternalMethod>
<InvalidArgument occurrences="1">
<InvalidArgument occurrences="3">
<code>$restrictions</code>
<code>addServiceListener</code>
<code>addServiceListener</code>
</InvalidArgument>
<RedundantCondition occurrences="1">
<code>((array)$request-&gt;getParam('appid')) !== ''</code>
@ -3337,7 +3483,8 @@
<NullableReturnStatement occurrences="1">
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userObject</code>
<code>$userObject</code>
</RedundantCondition>
<TooManyArguments occurrences="1">
@ -3523,6 +3670,9 @@
</MoreSpecificImplementedParamType>
</file>
<file src="lib/private/Files/ObjectStore/ObjectStoreStorage.php">
<InvalidScalarArgument occurrences="1">
<code>$source</code>
</InvalidScalarArgument>
<ParamNameMismatch occurrences="2">
<code>$source</code>
<code>$target</code>
@ -3726,6 +3876,11 @@
</InvalidReturnType>
</file>
<file src="lib/private/Files/Storage/Wrapper/Encoding.php">
<InvalidScalarArgument occurrences="3">
<code>\Normalizer::FORM_C</code>
<code>\Normalizer::FORM_C</code>
<code>\Normalizer::FORM_D</code>
</InvalidScalarArgument>
<UndefinedInterfaceMethod occurrences="13">
<code>$this-&gt;namesCache</code>
<code>$this-&gt;namesCache</code>
@ -3816,6 +3971,11 @@
<code>stream_flush</code>
</InvalidReturnType>
</file>
<file src="lib/private/Files/Template/TemplateManager.php">
<RedundantCondition occurrences="1">
<code>!$isDefaultTemplates</code>
</RedundantCondition>
</file>
<file src="lib/private/Files/Type/Detection.php">
<ParamNameMismatch occurrences="1">
<code>$mimetype</code>
@ -3865,9 +4025,11 @@
<code>null</code>
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="3">
<code>$data</code>
<RedundantCondition occurrences="5">
<code>$result</code>
<code>$result &amp;&amp; in_array('delete', $hooks) and $result</code>
<code>Constants::PERMISSION_READ</code>
<code>Constants::PERMISSION_READ</code>
<code>is_resource($source)</code>
</RedundantCondition>
<UndefinedDocblockClass occurrences="2">
@ -3906,7 +4068,10 @@
<MoreSpecificImplementedParamType occurrences="1">
<code>$user</code>
</MoreSpecificImplementedParamType>
<RedundantCondition occurrences="3">
<RedundantCondition occurrences="6">
<code>$this-&gt;emitter</code>
<code>$this-&gt;emitter</code>
<code>$this-&gt;emitter</code>
<code>$this-&gt;emitter</code>
<code>$this-&gt;emitter</code>
<code>$this-&gt;emitter</code>
@ -3949,6 +4114,10 @@
<FalsableReturnStatement occurrences="1">
<code>false</code>
</FalsableReturnStatement>
<InvalidArgument occurrences="2">
<code>false</code>
<code>false</code>
</InvalidArgument>
<InvalidArrayOffset occurrences="2">
<code>$app['path']</code>
<code>$app['path']</code>
@ -3956,9 +4125,6 @@
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
<RedundantCondition occurrences="1">
<code>$archive</code>
</RedundantCondition>
</file>
<file src="lib/private/IntegrityCheck/Checker.php">
<InvalidArrayAccess occurrences="3">
@ -4030,7 +4196,8 @@
</InvalidPropertyAssignmentValue>
</file>
<file src="lib/private/Log.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$request</code>
<code>$request</code>
</RedundantCondition>
</file>
@ -4203,6 +4370,11 @@
<code>dispatch</code>
</TooManyArguments>
</file>
<file src="lib/private/Repair/Owncloud/CleanPreviews.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
</file>
<file src="lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php">
<ParamNameMismatch occurrences="1">
<code>$arguments</code>
@ -4212,6 +4384,9 @@
<ParamNameMismatch occurrences="1">
<code>$arguments</code>
</ParamNameMismatch>
<TypeDoesNotContainType occurrences="1">
<code>$counter % 100 === 0</code>
</TypeDoesNotContainType>
</file>
<file src="lib/private/Repair/RemoveLinkShares.php">
<ImplicitToStringCast occurrences="2">
@ -4512,6 +4687,14 @@
<code>dispatch</code>
</TooManyArguments>
</file>
<file src="lib/private/TagManager.php">
<InvalidNullableReturnType occurrences="1">
<code>\OCP\ITags</code>
</InvalidNullableReturnType>
<NullableReturnStatement occurrences="1">
<code>null</code>
</NullableReturnStatement>
</file>
<file src="lib/private/Tags.php">
<InvalidArgument occurrences="1">
<code>[$this-&gt;user, $this-&gt;type, $chunk]</code>
@ -4543,6 +4726,9 @@
</NullArgument>
</file>
<file src="lib/private/Template/JSResourceLocator.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
<InvalidOperand occurrences="6">
<code>$this-&gt;appendIfExist($this-&gt;serverroot, $script.'.js')</code>
<code>$this-&gt;appendIfExist($this-&gt;serverroot, $theme_dir.$script.'.js')</code>
@ -4610,6 +4796,9 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>array|int</code>
</ImplementedReturnTypeMismatch>
<InvalidArgument occurrences="1">
<code>$callback</code>
</InvalidArgument>
<InvalidNullableReturnType occurrences="1">
<code>bool|IUser</code>
</InvalidNullableReturnType>

74
build/stubs/ftp.php Normal file
View File

@ -0,0 +1,74 @@
<?php
/** @generate-class-entries */
namespace FTP {
/**
* @strict-properties
* @not-serializable
*/
final class Connection
{
}
}
namespace {
function ftp_connect(string $hostname, int $port = 21, int $timeout = 90): FTP\Connection|resource|false {}
#ifdef HAVE_FTP_SSL
function ftp_ssl_connect(string $hostname, int $port = 21, int $timeout = 90): FTP\Connection|resource|false {}
#endif
function ftp_login(FTP\Connection|resource $ftp, string $username, string $password): bool {}
function ftp_pwd(FTP\Connection|resource $ftp): string|false {}
function ftp_cdup(FTP\Connection|resource $ftp): bool {}
function ftp_chdir(FTP\Connection|resource $ftp, string $directory): bool {}
function ftp_exec(FTP\Connection|resource $ftp, string $command): bool {}
function ftp_raw(FTP\Connection|resource $ftp, string $command): ?array {}
function ftp_mkdir(FTP\Connection|resource $ftp, string $directory): string|false {}
function ftp_rmdir(FTP\Connection|resource $ftp, string $directory): bool {}
function ftp_chmod(FTP\Connection|resource $ftp, int $permissions, string $filename): int|false {}
/** @param string $response */
function ftp_alloc(FTP\Connection|resource $ftp, int $size, &$response = null): bool {}
function ftp_nlist(FTP\Connection|resource $ftp, string $directory): array|false {}
function ftp_rawlist(FTP\Connection|resource $ftp, string $directory, bool $recursive = false): array|false {}
function ftp_mlsd(FTP\Connection|resource $ftp, string $directory): array|false {}
function ftp_systype(FTP\Connection|resource $ftp): string|false {}
/** @param resource $stream */
function ftp_fget(FTP\Connection|resource $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
/** @param resource $stream */
function ftp_nb_fget(FTP\Connection|resource $ftp, $stream, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): int {}
function ftp_pasv(FTP\Connection|resource $ftp, bool $enable): bool {}
function ftp_get(FTP\Connection|resource $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
function ftp_nb_get(FTP\Connection|resource $ftp, string $local_filename, string $remote_filename, int $mode = FTP_BINARY, int $offset = 0): int {}
function ftp_nb_continue(FTP\Connection|resource $ftp): int {}
/** @param resource $stream */
function ftp_fput(FTP\Connection|resource $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): bool {}
/** @param resource $stream */
function ftp_nb_fput(FTP\Connection|resource $ftp, string $remote_filename, $stream, int $mode = FTP_BINARY, int $offset = 0): int {}
function ftp_put(FTP\Connection|resource $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): bool {}
function ftp_append(FTP\Connection|resource $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY): bool {}
function ftp_nb_put(FTP\Connection|resource $ftp, string $remote_filename, string $local_filename, int $mode = FTP_BINARY, int $offset = 0): int|false {}
function ftp_size(FTP\Connection|resource $ftp, string $filename): int {}
function ftp_mdtm(FTP\Connection|resource $ftp, string $filename): int {}
function ftp_rename(FTP\Connection|resource $ftp, string $from, string $to): bool {}
function ftp_delete(FTP\Connection|resource $ftp, string $filename): bool {}
function ftp_site(FTP\Connection|resource $ftp, string $command): bool {}
function ftp_close(FTP\Connection|resource $ftp): bool {}
/** @alias ftp_close */
function ftp_quit(FTP\Connection|resource $ftp): bool {}
/** @param int|bool $value */
function ftp_set_option(FTP\Connection|resource $ftp, int $option, $value): bool {}
function ftp_get_option(FTP\Connection|resource $ftp, int $option): int|bool {}
}

View File

@ -1,5 +1,11 @@
<?php
/**
* @strict-properties
* @not-serializable
*/
final class GdImage {}
/**
* Retrieve information about the currently installed GD library
* @link https://php.net/manual/en/function.gd-info.php

File diff suppressed because it is too large Load Diff

50
build/stubs/pcntl.php Normal file
View File

@ -0,0 +1,50 @@
<?php
// Licensed under Apache-2.0
// Copied from https://github.com/JetBrains/phpstorm-stubs/blob/master/pcntl/pcntl.php
define('WNOHANG', 1);
define('WUNTRACED', 2);
define('WCONTINUED', 8);
define('SIG_IGN', 1);
define('SIG_DFL', 0);
define('SIG_ERR', -1);
define('SIGHUP', 1);
define('SIGINT', 2);
define('SIGQUIT', 3);
define('SIGILL', 4);
define('SIGTRAP', 5);
define('SIGABRT', 6);
define('SIGIOT', 6);
define('SIGBUS', 7);
define('SIGFPE', 8);
define('SIGKILL', 9);
define('SIGUSR1', 10);
define('SIGSEGV', 11);
define('SIGUSR2', 12);
define('SIGPIPE', 13);
define('SIGALRM', 14);
define('SIGTERM', 15);
define('SIGSTKFLT', 16);
define('SIGCLD', 17);
define('SIGCHLD', 17);
define('SIGCONT', 18);
define('SIGSTOP', 19);
define('SIGTSTP', 20);
define('SIGTTIN', 21);
define('SIGTTOU', 22);
define('SIGURG', 23);
define('SIGXCPU', 24);
define('SIGXFSZ', 25);
define('SIGVTALRM', 26);
define('SIGPROF', 27);
define('SIGWINCH', 28);
define('SIGPOLL', 29);
define('SIGIO', 29);
define('SIGPWR', 30);
define('SIGSYS', 31);
define('SIGBABY', 31);
define('PRIO_PGRP', 1);
define('PRIO_USER', 2);
define('PRIO_PROCESS', 0);

View File

@ -42,7 +42,7 @@
"cs:fix": "php-cs-fixer fix",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"lint": "find . -name \\*.php -not -path './lib/composer/*' -not -path './build/stubs/*' -print0 | xargs -0 -n1 php -l",
"psalm": "psalm",
"psalm:update-baseline": "psalm --update-baseline --set-baseline=build/psalm-baseline.xml"
"psalm": "psalm --threads=1",
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=build/psalm-baseline.xml"
}
}

View File

@ -48,7 +48,7 @@ class GetPath extends Base {
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return null|int null or 0 if everything went fine, or an error code
* @return int 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$appName = $input->getArgument('app');

View File

@ -69,7 +69,7 @@ class GetConfig extends Base {
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return null|int null or 0 if everything went fine, or an error code
* @return int 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$appName = $input->getArgument('app');

View File

@ -65,9 +65,9 @@ class GetConfig extends Base {
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
* @return null|int null or 0 if everything went fine, or an error code
* @return int 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
protected function execute(InputInterface $input, OutputInterface $output) {
$configNames = $input->getArgument('name');
$configName = array_shift($configNames);
$defaultValue = $input->getOption('default-value');

View File

@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'reference' => '63a9bc2aacf829563ac74abe29d4edf6ff31b8b1',
'reference' => '1225189f74d06606aafc4150d07584b90cea50dd',
'name' => '__root__',
'dev' => false,
),
@ -16,7 +16,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'reference' => '63a9bc2aacf829563ac74abe29d4edf6ff31b8b1',
'reference' => '1225189f74d06606aafc4150d07584b90cea50dd',
'dev_requirement' => false,
),
),

View File

@ -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')

View File

@ -1407,7 +1407,7 @@ class View {
}
$info = new FileInfo($path, $storage, $internalPath, $data, $mount, $owner);
if ($data and isset($data['fileid'])) {
if (isset($data['fileid'])) {
if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
//add the sizes of other mount points to the folder
$extOnly = ($includeMountPoints === 'ext');

View File

@ -308,91 +308,80 @@ class Installer {
$extractDir = $this->tempManager->getTemporaryFolder();
$archive = new TAR($tempFile);
if ($archive) {
if (!$archive->extract($extractDir)) {
$errorMessage = 'Could not extract app ' . $appId;
if (!$archive->extract($extractDir)) {
$errorMessage = 'Could not extract app ' . $appId;
$archiveError = $archive->getError();
if ($archiveError instanceof \PEAR_Error) {
$errorMessage .= ': ' . $archiveError->getMessage();
}
throw new \Exception($errorMessage);
}
$allFiles = scandir($extractDir);
$folders = array_diff($allFiles, ['.', '..']);
$folders = array_values($folders);
if (count($folders) > 1) {
throw new \Exception(
sprintf(
'Extracted app %s has more than 1 folder',
$appId
)
);
$archiveError = $archive->getError();
if ($archiveError instanceof \PEAR_Error) {
$errorMessage .= ': ' . $archiveError->getMessage();
}
// Check if appinfo/info.xml has the same app ID as well
if ((PHP_VERSION_ID < 80000)) {
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
libxml_disable_entity_loader($loadEntities);
} else {
$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
}
if ((string)$xml->id !== $appId) {
throw new \Exception(
sprintf(
'App for id %s has a wrong app ID in info.xml: %s',
$appId,
(string)$xml->id
)
);
}
throw new \Exception($errorMessage);
}
$allFiles = scandir($extractDir);
$folders = array_diff($allFiles, ['.', '..']);
$folders = array_values($folders);
// Check if the version is lower than before
$currentVersion = OC_App::getAppVersion($appId);
$newVersion = (string)$xml->version;
if (version_compare($currentVersion, $newVersion) === 1) {
throw new \Exception(
sprintf(
'App for id %s has version %s and tried to update to lower version %s',
$appId,
$currentVersion,
$newVersion
)
);
}
$baseDir = OC_App::getInstallPath() . '/' . $appId;
// Remove old app with the ID if existent
OC_Helper::rmdirr($baseDir);
// Move to app folder
if (@mkdir($baseDir)) {
$extractDir .= '/' . $folders[0];
OC_Helper::copyr($extractDir, $baseDir);
}
OC_Helper::copyr($extractDir, $baseDir);
OC_Helper::rmdirr($extractDir);
return;
} else {
if (count($folders) > 1) {
throw new \Exception(
sprintf(
'Could not extract app with ID %s to %s',
$appId,
$extractDir
'Extracted app %s has more than 1 folder',
$appId
)
);
}
} else {
// Signature does not match
throw new \Exception(
sprintf(
'App with id %s has invalid signature',
$appId
)
);
// Check if appinfo/info.xml has the same app ID as well
if ((PHP_VERSION_ID < 80000)) {
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
libxml_disable_entity_loader($loadEntities);
} else {
$xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
}
if ((string)$xml->id !== $appId) {
throw new \Exception(
sprintf(
'App for id %s has a wrong app ID in info.xml: %s',
$appId,
(string)$xml->id
)
);
}
// Check if the version is lower than before
$currentVersion = OC_App::getAppVersion($appId);
$newVersion = (string)$xml->version;
if (version_compare($currentVersion, $newVersion) === 1) {
throw new \Exception(
sprintf(
'App for id %s has version %s and tried to update to lower version %s',
$appId,
$currentVersion,
$newVersion
)
);
}
$baseDir = OC_App::getInstallPath() . '/' . $appId;
// Remove old app with the ID if existent
OC_Helper::rmdirr($baseDir);
// Move to app folder
if (@mkdir($baseDir)) {
$extractDir .= '/' . $folders[0];
OC_Helper::copyr($extractDir, $baseDir);
}
OC_Helper::copyr($extractDir, $baseDir);
OC_Helper::rmdirr($extractDir);
return;
}
// Signature does not match
throw new \Exception(
sprintf(
'App with id %s has invalid signature',
$appId
)
);
}
}

View File

@ -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;

View File

@ -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');
}

View File

@ -16,6 +16,10 @@
<directory name="lib/composer/bin"/>
</ignoreFiles>
</projectFiles>
<stubs>
<file name="build/stubs/gd.php"/>
<file name="build/stubs/ldap.php"/>
</stubs>
<extraFiles>
<directory name="3rdparty"/>
</extraFiles>

View File

@ -75,14 +75,14 @@
<file name="build/stubs/sftp.php"/>
<file name="build/stubs/ssh2.php"/>
<file name="build/stubs/xsl.php"/>
<file name="build/stubs/ftp.php"/>
<file name="build/stubs/pcntl.php"/>
</stubs>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OCA\GroupFolders\Mount\GroupFolderStorage"/>
<referencedClass name="OCA\TwoFactorNextcloudNotification\Controller\APIController"/>
<!-- Classes from PHP>=8 (needed to be able to use \GdImage::class) -->
<referencedClass name="GdImage" />
</errorLevel>
</UndefinedClass>
<UndefinedFunction>
@ -126,11 +126,6 @@
<!-- Helper classes for sharing API integration from other apps -->
<referencedClass name="OCA\Deck\Sharing\ShareAPIHelper" />
<referencedClass name="OCA\Talk\Share\Helper\DeletedShareAPIController" />
<!-- Classes from PHP>=8 -->
<referencedClass name="GdImage" />
<referencedClass name="LDAP\Connection" />
<referencedClass name="LDAP\Result" />
<referencedClass name="LDAP\ResultEntry" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>

View File

@ -1,9 +1,11 @@
{
"require": {
"nikic/php-parser": "^4.13",
"vimeo/psalm": "^4.17"
"vimeo/psalm": "^4.18"
},
"config": {
"platform": {
"php": "7.3"
},
"allow-plugins": {
"composer/package-versions-deprecated": true
}

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a27ae1441b036754d39358d5dde4905b",
"content-hash": "c3c578c654631288a179470ece96f0ba",
"packages": [
{
"name": "amphp/amp",
@ -923,20 +923,20 @@
},
{
"name": "psr/container",
"version": "1.1.2",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
"url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": ""
},
"require": {
"php": ">=7.4.0"
"php": ">=7.2.0"
},
"type": "library",
"autoload": {
@ -965,9 +965,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/1.1.2"
"source": "https://github.com/php-fig/container/tree/1.1.1"
},
"time": "2021-11-05T16:50:12+00:00"
"time": "2021-03-05T17:36:06+00:00"
},
{
"name": "psr/log",
@ -1914,16 +1914,16 @@
},
{
"name": "vimeo/psalm",
"version": "4.17.0",
"version": "4.18.1",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "6f4707aa41c9174353a6434bba3fc8840f981d9c"
"reference": "dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/6f4707aa41c9174353a6434bba3fc8840f981d9c",
"reference": "6f4707aa41c9174353a6434bba3fc8840f981d9c",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb",
"reference": "dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb",
"shasum": ""
},
"require": {
@ -2014,9 +2014,9 @@
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm/tree/4.17.0"
"source": "https://github.com/vimeo/psalm/tree/4.18.1"
},
"time": "2022-01-01T18:39:47+00:00"
"time": "2022-01-08T21:21:26+00:00"
},
{
"name": "webmozart/assert",
@ -2136,5 +2136,8 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"platform-overrides": {
"php": "7.3"
},
"plugin-api-version": "2.2.0"
}