Fix psalm

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
pull/30826/head
Carl Schwan 2 years ago
parent 50c7a5e4cd
commit 0262cc33d7
No known key found for this signature in database
GPG Key ID: 06B35D38387B67BE

@ -2,13 +2,14 @@
declare(strict_types=1);
require_once './lib/composer/autoload.php';
require_once './vendor-bin/cs-fixer/vendor/autoload.php';
use Nextcloud\CodingStandard\Config;
$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->exclude('config')
->exclude('data')
->notPath('3rdparty')

@ -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="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>
@ -312,6 +358,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>
@ -638,9 +689,6 @@
<UndefinedFunction occurrences="1">
<code>\Sabre\Uri\split($this-&gt;path)</code>
</UndefinedFunction>
<UndefinedInterfaceMethod occurrences="1">
<code>writeStream</code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/dav/lib/Connector/Sabre/FilesPlugin.php">
<UndefinedFunction occurrences="3">
@ -1014,6 +1062,9 @@
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
<RedundantFunctionCall occurrences="1">
<code>array_values</code>
</RedundantFunctionCall>
</file>
<file src="apps/dav/lib/Upload/UploadHome.php">
<UndefinedFunction occurrences="1">
@ -1026,7 +1077,12 @@
</InvalidOperand>
</file>
<file src="apps/encryption/lib/Crypto/Crypt.php">
<RedundantCondition occurrences="1">
<InvalidArgument occurrences="2">
<code>false</code>
<code>false</code>
</InvalidArgument>
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="2">
@ -1062,17 +1118,24 @@
<InvalidThrow occurrences="1">
<code>throw $exception;</code>
</InvalidThrow>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
</file>
<file src="apps/encryption/lib/Migration/SetMasterKeyStatus.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
</file>
<file src="apps/encryption/lib/Recovery.php">
<InvalidScalarArgument occurrences="3">
<code>0</code>
<code>0</code>
<code>1</code>
</InvalidScalarArgument>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userSession</code>
<code>$userSession</code>
</RedundantCondition>
</file>
@ -1082,10 +1145,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>
@ -1140,6 +1209,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>
@ -1156,11 +1230,6 @@
<code>$files_list</code>
</InvalidArgument>
</file>
<file src="apps/files/ajax/list.php">
<TypeDoesNotContainType occurrences="1">
<code>!$dirInfo-&gt;getType() === 'dir'</code>
</TypeDoesNotContainType>
</file>
<file src="apps/files/appinfo/routes.php">
<InvalidScope occurrences="2">
<code>$this</code>
@ -1189,7 +1258,16 @@
<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">
<InvalidScalarArgument occurrences="1">
<code>$inputPath</code>
</InvalidScalarArgument>
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
@ -1278,6 +1356,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/Applicable.php">
<InvalidArgument occurrences="1">
<code>$mountId</code>
@ -1340,6 +1424,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>
@ -1534,6 +1624,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>
@ -1553,11 +1653,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>
@ -1603,9 +1709,6 @@
</InvalidDocblock>
</file>
<file src="apps/files_sharing/lib/External/Scanner.php">
<InvalidScalarArgument occurrences="1">
<code>$recursive</code>
</InvalidScalarArgument>
<MoreSpecificImplementedParamType occurrences="1">
<code>$cacheData</code>
</MoreSpecificImplementedParamType>
@ -1628,6 +1731,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>
@ -1681,6 +1789,11 @@
<code>dispatch</code>
</TooManyArguments>
</file>
<file src="apps/files_trashbin/lib/Command/Size.php">
<InvalidScalarArgument occurrences="1">
<code>$user</code>
</InvalidScalarArgument>
</file>
<file src="apps/files_trashbin/lib/Hooks.php">
<InvalidScalarArgument occurrences="1">
<code>$user</code>
@ -1740,12 +1853,13 @@
</TooManyArguments>
</file>
<file src="apps/files_trashbin/lib/Trash/LegacyTrashBackend.php">
<ParadoxicalCondition occurrences="1">
<code>null</code>
</ParadoxicalCondition>
<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>
@ -1769,6 +1883,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/Expiration.php">
<FalsableReturnStatement occurrences="1">
<code>$maxAge</code>
@ -1824,6 +1944,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>
@ -1834,6 +1959,10 @@
</TypeDoesNotContainNull>
</file>
<file src="apps/settings/lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="1">
<code>\OC_User::getUser()</code>
</InvalidScalarArgument>
@ -1865,6 +1994,11 @@
<code>dispatch</code>
</TooManyArguments>
</file>
<file src="apps/settings/lib/Controller/CommonSettingsTrait.php">
<RedundantCondition occurrences="1">
<code>$isSubAdmin</code>
</RedundantCondition>
</file>
<file src="apps/settings/lib/Hooks.php">
<InvalidArrayOffset occurrences="1">
<code>[$user-&gt;getEMailAddress() =&gt; $user-&gt;getDisplayName()]</code>
@ -1875,6 +2009,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>
@ -1891,11 +2030,14 @@
<code>getLanguages</code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/settings/lib/SetupChecks/CheckUserCertificates.php">
<InvalidArgument occurrences="1">
<code>false</code>
</InvalidArgument>
</file>
<file src="apps/sharebymail/lib/ShareByMailProvider.php">
<InvalidScalarArgument occurrences="4">
<InvalidScalarArgument occurrences="2">
<code>$share-&gt;getId()</code>
<code>$shareId</code>
<code>$shareId</code>
<code>(int)$data['id']</code>
</InvalidScalarArgument>
</file>
@ -1914,6 +2056,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>
@ -1960,6 +2107,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>
@ -1977,6 +2132,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>
@ -2021,9 +2179,6 @@
<InvalidArgument occurrences="1">
<code>$record</code>
</InvalidArgument>
<InvalidArrayOffset occurrences="1">
<code>[$attr =&gt; $result['values']]</code>
</InvalidArrayOffset>
<InvalidReturnStatement occurrences="2">
<code>$uuid</code>
<code>$values</code>
@ -2039,14 +2194,12 @@
<NullArgument occurrences="1">
<code>$cookie</code>
</NullArgument>
<RedundantCondition occurrences="4">
<RedundantCondition occurrences="3">
<code>!is_null($limit)</code>
<code>!isset($ldapName[0]) &amp;&amp; empty($ldapName[0])</code>
<code>$limit === 0</code>
<code>is_array($result)</code>
</RedundantCondition>
<TypeDoesNotContainNull occurrences="2">
<code>!$attribute === null</code>
<TypeDoesNotContainNull occurrences="1">
<code>is_null($findings)</code>
</TypeDoesNotContainNull>
<TypeDoesNotContainType occurrences="2">
@ -2304,17 +2457,27 @@
</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/user_status/lib/Db/UserStatusMapper.php">
<MoreSpecificImplementedParamType occurrences="1"/>
<MoreSpecificImplementedParamType occurrences="4">
<code>UserStatus insert(UserStatus $entity)</code>
<code>UserStatus insert(UserStatus $entity)</code>
<code>UserStatus insert(UserStatus $entity)</code>
<code>UserStatus insert(UserStatus $entity)</code>
</MoreSpecificImplementedParamType>
</file>
<file src="apps/user_status/lib/Service/StatusService.php">
<MismatchingDocblockParamType occurrences="1">
<code>string|null</code>
</MismatchingDocblockParamType>
<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">
@ -2410,6 +2573,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>
@ -2429,9 +2605,6 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<InvalidReturnType occurrences="1">
<code>null|int</code>
</InvalidReturnType>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
@ -2450,9 +2623,6 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<InvalidReturnType occurrences="1">
<code>null|int</code>
</InvalidReturnType>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
@ -2475,9 +2645,6 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|int</code>
</ImplementedReturnTypeMismatch>
<InvalidReturnType occurrences="1">
<code>null|int</code>
</InvalidReturnType>
<MismatchingDocblockReturnType occurrences="1">
<code>null|int</code>
</MismatchingDocblockReturnType>
@ -2526,8 +2693,10 @@
</InvalidReturnType>
</file>
<file src="core/Command/Log/Manage.php">
<InvalidScalarArgument occurrences="1">
<InvalidScalarArgument occurrences="3">
<code>$backend</code>
<code>$levelNum</code>
<code>$timezone</code>
</InvalidScalarArgument>
</file>
<file src="core/Command/Maintenance/DataFingerprint.php">
@ -2642,13 +2811,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>
@ -2657,8 +2832,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>
@ -3082,14 +3259,6 @@
<code>bool|mixed</code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/private/Collaboration/Resources/Manager.php">
<RedundantCondition occurrences="1">
<code>$user instanceof IUser</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="1">
<code>''</code>
</TypeDoesNotContainType>
</file>
<file src="lib/private/Command/CallableJob.php">
<ParamNameMismatch occurrences="1">
<code>$serializedCallable</code>
@ -3514,7 +3683,8 @@
<NullableReturnStatement occurrences="1">
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$userObject</code>
<code>$userObject</code>
</RedundantCondition>
<TooManyArguments occurrences="1">
@ -3703,6 +3873,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>
@ -3925,6 +4098,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>
@ -3945,10 +4123,6 @@
<FalsableReturnStatement occurrences="1">
<code>false</code>
</FalsableReturnStatement>
<InvalidArgument occurrences="2">
<code>$source</code>
<code>$target</code>
</InvalidArgument>
<InvalidOperand occurrences="3">
<code>$result</code>
<code>$result</code>
@ -4019,6 +4193,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>
@ -4068,9 +4247,13 @@
<code>null</code>
<code>null</code>
</NullableReturnStatement>
<RedundantCondition occurrences="3">
<RedundantCondition occurrences="7">
<code>$data</code>
<code>$data</code>
<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">
@ -4109,7 +4292,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>
@ -4152,6 +4338,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>
@ -4159,7 +4349,8 @@
<NullArgument occurrences="1">
<code>null</code>
</NullArgument>
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$archive</code>
<code>$archive</code>
</RedundantCondition>
</file>
@ -4234,7 +4425,8 @@
</InvalidPropertyAssignmentValue>
</file>
<file src="lib/private/Log.php">
<RedundantCondition occurrences="1">
<RedundantCondition occurrences="2">
<code>$request</code>
<code>$request</code>
</RedundantCondition>
</file>
@ -4285,16 +4477,11 @@
<code>mixed</code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/private/Memcache/Factory.php">
<file src="lib/private/Memcache/Memcached.php">
<TypeDoesNotContainType occurrences="1">
<code>$lockingCacheClass &amp;&amp; class_exists($distributedCacheClass)</code>
<code>\Memcached::HAVE_IGBINARY</code>
</TypeDoesNotContainType>
</file>
<file src="lib/private/Memcache/Memcached.php">
<RedundantCondition occurrences="1">
<code>method_exists(self::$cache, 'deleteMulti')</code>
</RedundantCondition>
</file>
<file src="lib/private/Memcache/Redis.php">
<InvalidMethodCall occurrences="2">
<code>exec</code>
@ -4311,22 +4498,11 @@
<code>$id</code>
</ParamNameMismatch>
</file>
<file src="lib/private/Notification/Manager.php">
<TypeDoesNotContainType occurrences="2">
<code>!($notification instanceof INotification)</code>
<code>!($notification instanceof INotification)</code>
</TypeDoesNotContainType>
</file>
<file src="lib/private/Preview/BackgroundCleanupJob.php">
<InvalidReturnStatement occurrences="1">
<code>[]</code>
</InvalidReturnStatement>
</file>
<file src="lib/private/Preview/Bitmap.php">
<ImplicitToStringCast occurrences="1">
<code>$bp</code>
</ImplicitToStringCast>
</file>
<file src="lib/private/Preview/Generator.php">
<InvalidArgument occurrences="2">
<code>$maxPreviewImage</code>
@ -4366,11 +4542,6 @@
<code>$provider-&gt;getThumbnail($file, $maxWidth, $maxHeight)</code>
</NullableReturnStatement>
</file>
<file src="lib/private/Preview/HEIC.php">
<ImplicitToStringCast occurrences="1">
<code>$bp</code>
</ImplicitToStringCast>
</file>
<file src="lib/private/Preview/Movie.php">
<InvalidScalarArgument occurrences="2">
<code>$second</code>
@ -4403,11 +4574,6 @@
<code>string</code>
</InvalidReturnType>
</file>
<file src="lib/private/Preview/SVG.php">
<ImplicitToStringCast occurrences="1">
<code>$svg</code>
</ImplicitToStringCast>
</file>
<file src="lib/private/PreviewManager.php">
<ForbiddenCode occurrences="2">
<code>shell_exec('command -v libreoffice')</code>
@ -4446,6 +4612,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>
@ -4455,6 +4626,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">
@ -4490,9 +4664,6 @@
<NullableReturnStatement occurrences="1">
<code>$this-&gt;collectionName</code>
</NullableReturnStatement>
<RedundantCondition occurrences="1">
<code>$file !== false</code>
</RedundantCondition>
</file>
<file src="lib/private/Search.php">
<RedundantCondition occurrences="1">
@ -4797,6 +4968,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>
@ -4867,6 +5041,9 @@
<ImplementedReturnTypeMismatch occurrences="1">
<code>array|int</code>
</ImplementedReturnTypeMismatch>
<InvalidArgument occurrences="1">
<code>$callback</code>
</InvalidArgument>
<InvalidNullableReturnType occurrences="1">
<code>bool|IUser</code>
</InvalidNullableReturnType>
@ -5039,16 +5216,8 @@
<RedundantCondition occurrences="1">
<code>count($obd_values) &gt; 0</code>
</RedundantCondition>
<UndefinedInterfaceMethod occurrences="1">
<code>getSourceStorage</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/legacy/OC_Image.php">
<FalsableReturnStatement occurrences="3">
<code>$this-&gt;resource</code>
<code>$this-&gt;valid() ? imagesx($this-&gt;resource) : -1</code>
<code>$this-&gt;valid() ? imagesy($this-&gt;resource) : -1</code>
</FalsableReturnStatement>
<ImplementedReturnTypeMismatch occurrences="1">
<code>null|string</code>
</ImplementedReturnTypeMismatch>
@ -5056,9 +5225,6 @@
<code>$data[floor($p)]</code>
<code>$data[floor($p)]</code>
</InvalidArrayOffset>
<InvalidPropertyAssignmentValue occurrences="1">
<code>$resource</code>
</InvalidPropertyAssignmentValue>
<InvalidReturnType occurrences="1">
<code>bool</code>
</InvalidReturnType>
@ -5074,10 +5240,6 @@
<RedundantCondition occurrences="1">
<code>$isWritable</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="2">
<code>get_class($resource) === 'GdImage'</code>
<code>get_class($this-&gt;resource) === 'GdImage'</code>
</TypeDoesNotContainType>
</file>
<file src="lib/private/legacy/OC_JSON.php">
<InvalidScalarArgument occurrences="1">
@ -5094,9 +5256,6 @@
<code>\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($prevLogging)</code>
<code>\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false)</code>
</InternalMethod>
<InvalidLiteralArgument occurrences="1">
<code>\OCP\Constants::FILENAME_INVALID_CHARS</code>
</InvalidLiteralArgument>
<InvalidReturnStatement occurrences="1">
<code>OC_Helper::computerFileSize($userQuota)</code>
</InvalidReturnStatement>
@ -5107,8 +5266,7 @@
<code>$user</code>
<code>OC_User::getUser()</code>
</InvalidScalarArgument>
<RedundantCondition occurrences="2">
<code>'off'</code>
<RedundantCondition occurrences="1">
<code>is_string($expected)</code>
</RedundantCondition>
<TypeDoesNotContainType occurrences="3">

@ -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 {}
}

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

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

@ -1,7 +1,15 @@
{
"config" : {
"vendor-dir": "lib/composer",
"optimize-autoloader": true
"optimize-autoloader": true,
"sort-packages": true,
"platform": {
"php": "7.3"
},
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"composer/package-versions-deprecated": true
}
},
"autoload" : {
"psr-4": {
@ -21,13 +29,21 @@
"ext-zip": "*"
},
"require-dev": {
"nextcloud/coding-standard": "^0.5.0",
"vimeo/psalm": "^4.0"
"bamarni/composer-bin-plugin": "^1.4"
},
"scripts": {
"post-install-cmd": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install",
"composer dump-autoload"
],
"post-update-cmd": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all update --ansi",
"composer dump-autoload"
],
"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": "psalm --threads=1",
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=build/psalm-baseline.xml"
}
}

3021
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -247,8 +247,7 @@ class Upgrade extends Command {
$output->write('<comment>Maybe an upgrade is already in process. Please check the '
. 'logfile (data/nextcloud.log). If you want to re-run the '
. 'upgrade procedure, remove the "maintenance mode" from '
. 'config.php and call this script again.</comment>'
, true);
. 'config.php and call this script again.</comment>', true);
return self::ERROR_MAINTENANCE_MODE;
} else {
$output->writeln('<info>Nextcloud is already latest version</info>');

@ -42,30 +42,75 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
@ -75,28 +120,47 @@ class ClassLoader
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-return array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
@ -112,8 +176,10 @@ class ClassLoader
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
@ -157,10 +223,12 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
@ -205,7 +273,9 @@ class ClassLoader
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
@ -221,9 +291,11 @@ class ClassLoader
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
@ -243,6 +315,8 @@ class ClassLoader
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
@ -265,6 +339,8 @@ class ClassLoader
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
@ -285,6 +361,8 @@ class ClassLoader
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
@ -305,6 +383,8 @@ class ClassLoader
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
@ -324,6 +404,8 @@ class ClassLoader
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
@ -403,6 +485,11 @@ class ClassLoader
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
@ -474,6 +561,10 @@ class ClassLoader
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{

@ -1,62 +1,52 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*/
class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07',
'name' => '__root__',
),
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07',
),
),
);
/**
* @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;
private static $installedByVendor = array();
/**
* @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();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
@ -71,38 +61,60 @@ return $packages[0];
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
public static function isInstalled($packageName)
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return true;
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
@ -111,15 +123,15 @@ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
@ -147,10 +159,10 @@ return implode(' || ', $ranges);
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
@ -168,10 +180,10 @@ return $installed['versions'][$packageName]['version'];
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
@ -189,10 +201,10 @@ return $installed['versions'][$packageName]['pretty_version'];
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
@ -210,10 +222,27 @@ return $installed['versions'][$packageName]['reference'];
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @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()
{
$installed = self::getInstalled();
@ -221,59 +250,69 @@ $installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @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, 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()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
return self::$installed;
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* 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, 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()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @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, 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)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @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()
{
if (null === self::$canGetVendors) {
@ -288,10 +327,22 @@ if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
return $installed;

@ -1,24 +1,32 @@
<?php return array(
'root' =>
array (
'root' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07',
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'reference' => '50c7a5e4cddd055db6ab1e7e30cb94b43001543f',
'name' => '__root__',
'dev' => true,
),
'versions' =>
array (
'__root__' =>
array (
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'reference' => '50c7a5e4cddd055db6ab1e7e30cb94b43001543f',
'dev_requirement' => false,
),
'reference' => '619b35b480a2d348436156a2a6144895b00b1e07',
'bamarni/composer-bin-plugin' => array(
'pretty_version' => '1.4.1',
'version' => '1.4.1.0',
'type' => 'composer-plugin',
'install_path' => __DIR__ . '/../bamarni/composer-bin-plugin',
'aliases' => array(),
'reference' => '9329fb0fbe29e0e1b2db8f4639a193e4f5406225',
'dev_requirement' => true,
),
),
);

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

@ -12,16 +12,15 @@
</plugins>
<projectFiles>
<directory name="lib/public"/>
<ignoreFiles>
<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>
<issueHandlers>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<!-- Classes from PHP>=8 -->
<referencedClass name="GdImage" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
</psalm>

@ -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,8 +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" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>

@ -122,8 +122,7 @@ class ExpressionBuilderDBTest extends TestCase {
$query->createFunction(
'(' . $query->expr()->castColumn('configvalue', IQueryBuilder::PARAM_INT)
. ' + 1)'
)
, IQueryBuilder::PARAM_STR
), IQueryBuilder::PARAM_STR
)
)
->where($query->expr()->eq('appid', $query->createNamedParameter($appId)))

@ -399,23 +399,17 @@ class CacheTest extends \Test\TestCase {
$user = $this->createMock(IUser::class);
$this->assertCount(1, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', 'foo')
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', 'foo'), 10, 0, [], $user)));
$this->assertCount(2, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', 'foo%')
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', 'foo%'), 10, 0, [], $user)));
$this->assertCount(2, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'foo/file')
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'foo/file'), 10, 0, [], $user)));
$this->assertCount(3, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', 'foo/%')
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', 'foo/%'), 10, 0, [], $user)));
$this->assertCount(1, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, 'size', 100)
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, 'size', 100), 10, 0, [], $user)));
$this->assertCount(2, $this->cache->searchQuery(new SearchQuery(
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN_EQUAL, 'size', 100)
, 10, 0, [], $user)));
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN_EQUAL, 'size', 100), 10, 0, [], $user)));
}
public function movePathProvider() {

@ -0,0 +1,11 @@
{
"config": {
"platform": {
"php": "7.3"
}
},
"require": {
"friendsofphp/php-cs-fixer": "^3.4.0",
"nextcloud/coding-standard": "^1.0.0"
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,13 @@
{
"require": {
"vimeo/psalm": "^4.18"
},
"config": {
"platform": {
"php": "7.3"
},
"allow-plugins": {
"composer/package-versions-deprecated": true
}
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save