Signed-off-by: Carl Schwan <carl@carlschwan.eu>
This commit is contained in:
Carl Schwan 2022-09-09 10:58:03 +02:00
Родитель fb7a3fe0b3
Коммит ca073423d4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: C3AA6B3A5EFA7AC5
17 изменённых файлов: 1260 добавлений и 216 удалений

3
.github/workflows/psalm.yml поставляемый
Просмотреть файл

@ -29,8 +29,5 @@ jobs:
- name: Install dependencies
run: composer i
- name: Install dependencies
run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}
- name: Run coding standards check
run: composer run psalm

Просмотреть файл

@ -9,6 +9,7 @@ use Nextcloud\CodingStandard\Config;
$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')

Просмотреть файл

@ -11,16 +11,16 @@
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --threads=1",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:clear": "psalm.phar --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
"psalm": "psalm --threads=1",
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
},
"require-dev": {
"nextcloud/coding-standard": "^1.0",
"phpunit/phpunit": "^9",
"php-parallel-lint/php-parallel-lint": "^1.2",
"christophwurst/nextcloud": "^21",
"psalm/phar": "^4.22"
"christophwurst/nextcloud": "^23.0",
"vimeo/psalm": "^4.27"
}
}

959
composer.lock сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -33,6 +33,7 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Console\Helper\QuestionHelper;
class AddCommand extends Command {
/** @var IUserManager */

Просмотреть файл

@ -54,7 +54,7 @@ class ListCommand extends Base {
} else {
$output->writeln("<info>No guests created</info>");
}
return 0;
return;
}
if ($outputType === self::OUTPUT_FORMAT_JSON || $outputType === self::OUTPUT_FORMAT_JSON_PRETTY) {
@ -65,6 +65,6 @@ class ListCommand extends Base {
$table->setRows($guests);
$table->render();
}
return 0;
return;
}
}

Просмотреть файл

@ -82,7 +82,7 @@ class APIController extends OCSController {
foreach ($languageCodes as $lang) {
$l = $this->l10nFactory->get('lib', $lang);
// TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version
$potentialName = (string)$l->t('__language_name__');
$potentialName = $l->t('__language_name__');
if ($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file
$ln = [
'code' => $lang,

Просмотреть файл

@ -102,7 +102,6 @@ class SettingsController extends Controller {
public function getWhitelist(): DataResponse {
$useWhitelist = $this->config->useWhitelist();
$whitelist = $this->config->getAppWhitelist();
$whitelist = explode(',', $whitelist);
return new DataResponse([
'useWhitelist' => $useWhitelist,
'whitelist' => $whitelist,

Просмотреть файл

@ -62,7 +62,11 @@ class FilteredNavigationManager extends NavigationManager {
return $this->navigationManager->getActiveEntry();
}
public function setActiveEntry($id) {
$this->navigationManager->setActiveEntry($id);
public function setActiveEntry($appId) {
$this->navigationManager->setActiveEntry($appId);
}
public function setUnreadCounter(string $id, int $unreadCounter): void {
$this->navigationManager->setUnreadCounter($id, $unreadCounter);
}
}

Просмотреть файл

@ -21,7 +21,6 @@
namespace OCA\Guests;
use OC\Share\Share;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;

Просмотреть файл

@ -33,7 +33,6 @@ use OCP\AppFramework\QueryException;
use OCP\Constants;
use OCP\Files\Storage\IStorage;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
@ -43,10 +42,11 @@ use OCP\Security\ICrypto;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\GenericEvent;
use Psr\Log\LoggerInterface;
class Hooks {
/** @var ILogger */
/** @var LoggerInterface */
private $logger;
/** @var IUserSession */
@ -82,7 +82,7 @@ class Hooks {
private $config;
public function __construct(
ILogger $logger,
LoggerInterface $logger,
IUserSession $userSession,
IRequest $request,
Mail $mail,
@ -226,11 +226,10 @@ class Hooks {
try {
/** @var OwnershipTransferService $ownershipTransferService */
$ownershipTransferService = $this->container->query(OwnershipTransferService::class);
$ownershipTransferService = $this->container->get(OwnershipTransferService::class);
} catch (QueryException $e) {
$this->logger->logException($e, [
'level' => ILogger::ERROR,
'message' => 'Could not resolve ownership transfer service to import guest user data',
$this->logger->error('Could not resolve ownership transfer service to import guest user data', [
'exception' => $e,
]);
return;
}
@ -250,9 +249,8 @@ class Hooks {
true
);
} catch (TransferOwnershipException $e) {
$this->logger->logException($e, [
'level' => ILogger::ERROR,
'message' => 'Could not import guest user data',
$this->logger->error('Could not import guest user data', [
'exception' => $e,
]);
}

Просмотреть файл

@ -106,7 +106,7 @@ class RestrictionManager {
$settingsManager = $this->server->get(IManager::class);
$this->server->registerService(IManager::class, function () use ($settingsManager) {
return new FilteredSettingsManager($this->userSession->getUser(), $settingsManager, $this->whitelist);
return new FilteredSettingsManager($settingsManager, $this->whitelist);
});
}
}

Просмотреть файл

@ -180,7 +180,7 @@ class DirMask extends PermissionsMask {
}
}
public function fopen($path, $mode): resource {
public function fopen($path, $mode) {
if ($this->checkPath($path)) {
return parent::fopen($path, $mode);
} else {

Просмотреть файл

@ -200,8 +200,8 @@ class UserBackend extends ABackend implements
* Get a list of all display names and user ids.
*
* @param string $search
* @param string|null $limit
* @param string|null $offset
* @param int|null $limit
* @param int|null $offset
* @return array an array of all displayNames (value) and the corresponding uids (key)
*/
public function getDisplayNames($search = '', $limit = null, $offset = null): array {

Просмотреть файл

@ -8,7 +8,7 @@
errorBaseline="tests/psalm-baseline.xml"
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
<file name="tests/stub.php" preloadClasses="true"/>
</stubs>
<projectFiles>
<directory name="lib" />
@ -20,7 +20,7 @@
<directory name="vendor" />
<ignoreFiles>
<directory name="vendor/phpunit/php-code-coverage" />
<directory name="vendor/psalm" />
<directory name="vendor/vimeo/psalm" />
</ignoreFiles>
</extraFiles>
<issueHandlers>

Просмотреть файл

@ -1,93 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="lib/AppConfigOverwrite.php">
<UndefinedClass occurrences="1">
<code>AppConfig</code>
</UndefinedClass>
</file>
<files psalm-version="4.27.0@faf106e717c37b8c81721845dba9de3d8deed8ff">
<file src="lib/AppInfo/Application.php">
<InvalidArgument occurrences="2">
<code>registerEventListener</code>
<code>registerEventListener</code>
</InvalidArgument>
<UndefinedClass occurrences="1">
<code>\OC_App</code>
</UndefinedClass>
<UndefinedInterfaceMethod occurrences="1">
<code>listen</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/AppWhitelist.php">
<MissingDependency occurrences="1">
<code>Template</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>\OC_App</code>
</UndefinedClass>
</file>
<file src="lib/Command/AddCommand.php">
<UndefinedDocblockClass occurrences="3">
<code>$helper</code>
<code>$helper</code>
<code>$helper</code>
</UndefinedDocblockClass>
<UndefinedMethod occurrences="1">
<code>isInteractive</code>
</UndefinedMethod>
</file>
<file src="lib/Command/ListCommand.php">
<InvalidReturnStatement occurrences="2">
<code>0</code>
<code>0</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>void</code>
</InvalidReturnType>
</file>
<file src="lib/Config.php">
<UndefinedPropertyFetch occurrences="1">
<code>\OC::$SERVERROOT</code>
</UndefinedPropertyFetch>
</file>
<file src="lib/Controller/APIController.php">
<RedundantCast occurrences="1">
<code>(string)$l-&gt;t('__language_name__')</code>
</RedundantCast>
<UndefinedClass occurrences="2">
<code>Factory</code>
<code>Factory</code>
</UndefinedClass>
</file>
<file src="lib/Controller/SettingsController.php">
<InvalidArgument occurrences="1">
<code>$whitelist</code>
</InvalidArgument>
</file>
<file src="lib/Controller/UsersController.php">
<UndefinedClass occurrences="1">
<code>PublicEmitter</code>
</UndefinedClass>
</file>
<file src="lib/FilteredNavigationManager.php">
<ParamNameMismatch occurrences="1">
<code>$id</code>
</ParamNameMismatch>
<UndefinedMethod occurrences="1"/>
</file>
<file src="lib/Hooks.php">
<InvalidArgument occurrences="1">
<code>$e</code>
</InvalidArgument>
<InvalidScalarArgument occurrences="1">
<code>$share-&gt;getNodeId()</code>
</InvalidScalarArgument>
<UndefinedClass occurrences="2">
<code>OwnershipTransferService</code>
<code>TransferOwnershipException</code>
</UndefinedClass>
<UndefinedDocblockClass occurrences="2">
<code>$ownershipTransferService</code>
<code>$ownershipTransferService</code>
</UndefinedDocblockClass>
</file>
<file src="lib/Mail.php">
<MissingDependency occurrences="1">
@ -95,31 +19,13 @@
</MissingDependency>
</file>
<file src="lib/RestrictionManager.php">
<MissingDependency occurrences="1">
<code>AppConfigOverwrite</code>
</MissingDependency>
<UndefinedClass occurrences="2">
<code>AppConfig</code>
<code>ExternalMountPoint</code>
</UndefinedClass>
</file>
<file src="lib/Storage/DirMaskCache.php">
<UndefinedClass occurrences="1">
<code>CachePermissionsMask</code>
<code>ExternalMountPoint</code>
</UndefinedClass>
</file>
<file src="lib/UserBackend.php">
<ImplicitToStringCast occurrences="1">
<code>$query-&gt;func()-&gt;lower('displayname')</code>
</ImplicitToStringCast>
<InvalidArgument occurrences="1"/>
<InvalidScalarArgument occurrences="6">
<code>$limit</code>
<code>$limit</code>
<code>$limit</code>
<code>$offset</code>
<code>$offset</code>
<code>$offset</code>
</InvalidScalarArgument>
</file>
</files>

Просмотреть файл

@ -21,9 +21,83 @@ declare(strict_types=1);
*
*/
namespace OC\Cache {
use OCP\ICache;
/**
* @template T
* @deprecated use OCP\Cache\CappedMemoryCache instead
*/
class CappedMemoryCache implements ICache, \ArrayAccess {
public function __construct($capacity = 512) {
}
public function hasKey($key): bool {
}
/**
* @return ?T
*/
public function get($key) {
}
/**
* @param string $key
* @param T $value
* @param int $ttl
* @return bool
*/
public function set($key, $value, $ttl = 0): bool {
}
public function remove($key) {
}
public function clear($prefix = '') {
}
public function offsetExists($offset): bool {
}
/**
* @return T
*/
#[\ReturnTypeWillChange]
public function &offsetGet($offset) {
}
/**
* @param string $offset
* @param T $value
* @return void
*/
public function offsetSet($offset, $value): void {
}
public function offsetUnset($offset): void {
}
/** @return T[] */
public function getData() {
}
public static function isAvailable(): bool {
}
}
}
namespace OC {
class NavigationManager implements \OCP\INavigationManager {
}
class NavigationManager implements \OCP\INavigationManager {
}
class AppConfig {
public function __construct(\OC\DB\Connection $connection) {
}
public function getValue(string $app, string $key, string $default = null): string {
}
}
}
namespace OC\DB {
class Connection {
}
}
namespace {
@ -31,108 +105,161 @@ namespace {
use OCP\IServerContainer;
class OC {
static $CLI = false;
public static $CLI = false;
/** @var IServerContainer */
static $server;
public static $server;
public static $SERVERROOT = '';
}
class OC_App {
/**
* @deprecated
*/
public static function loadApp(string $appName) {
}
public static function cleanAppId(string $appName): string {
}
}
class OC_Template {
}
}
namespace OC\AppFramework {
class App {
public static function getAppIdForClass(string $class): string {
}
}
}
namespace OC\Files\Node {
use OCP\Files\FileInfo;
abstract class Node implements \OCP\Files\Node {
/** @return FileInfo|\ArrayAccess */
public function getFileInfo() {}
public function getFileInfo() {
}
/** @return \OCP\Files\Mount\IMountPoint */
public function getMountPoint() {}
public function getMountPoint() {
}
}
}
namespace OC\Hooks {
class Emitter {
public function emit(string $class, string $value, array $option) {}
public function emit(string $class, string $value, array $option) {
}
/** Closure $closure */
public function listen(string $class, string $value, $closure) {}
public function listen(string $class, string $value, $closure) {
}
}
class BasicEmitter extends Emitter {
}
class PublicEmitter extends Emitter {
}
}
namespace OC\Cache {
class CappedMemoryCache implements \ArrayAccess {
public function get($key) {}
public function set($key, $value, $ttl = '') {}
public function offsetSet($key, $value) {}
public function offsetGet($key) {}
namespace OC\L10N {
class Factory {
public const COMMON_LANGUAGE_CODES = [''];
}
}
namespace OC\Core\Command {
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Base {
public const OUTPUT_FORMAT_PLAIN = 'plain';
public const OUTPUT_FORMAT_JSON = 'json';
public const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty';
public function __construct() {}
protected function configure() {}
public function run(InputInterface $input, OutputInterface $output) {}
public function setName(string $name) {}
public function getHelper(string $name) {}
public function __construct() {
}
protected function configure() {
}
public function run(InputInterface $input, OutputInterface $output) {
}
public function setName(string $name) {
}
public function getHelper(string $name) {
}
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = ' - ') {
}
}
}
namespace OC\Files\ObjectStore {
class NoopScanner {}
class NoopScanner {
}
}
namespace Symfony\Component\Console\Helper {
use Symfony\Component\Console\Output\OutputInterface;
class Table {
public function __construct(OutputInterface $text) {}
public function setHeaders(array $header) {}
public function setRows(array $rows) {}
public function render() {}
public function __construct(OutputInterface $text) {
}
public function setHeaders(array $header) {
}
public function setRows(array $rows) {
}
public function render() {
}
}
}
namespace Symfony\Component\Console\Input {
class InputInterface {
public function getOption(string $key) {}
public function getArgument(string $key) {}
public function getOption(string $key) {
}
public function getArgument(string $key) {
}
public function isInteractive(): bool {
}
}
class InputArgument {
const REQUIRED = 0;
const OPTIONAL = 1;
const IS_ARRAY = 1;
public const REQUIRED = 0;
public const OPTIONAL = 1;
public const IS_ARRAY = 1;
}
class InputOption {
const VALUE_NONE = 1;
const VALUE_REQUIRED = 1;
const VALUE_OPTIONAL = 1;
public const VALUE_NONE = 1;
public const VALUE_REQUIRED = 1;
public const VALUE_OPTIONAL = 1;
}
}
namespace Symfony\Component\Console\Helper {
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Question\Question;
class QuestionHelper {
public function ask(InputInterface $input, OutputInterface $output, Question $question): bool {
}
}
}
namespace Symfony\Component\Console\Question {
class ConfirmationQuestion {
public function __construct(string $text, bool $default) {}
public function __construct(string $text, bool $default) {
}
}
}
namespace Symfony\Component\Console\Output {
class OutputInterface {
public const VERBOSITY_VERBOSE = 1;
public function writeln(string $text, int $flat = 0) {}
public function writeln(string $text, int $flat = 0) {
}
}
}
namespace OC\Files\Cache {
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Search\ISearchQuery;
use OCP\Files\Search\ISearchOperator;
use OCP\Files\Search\ISearchQuery;
use OCP\Files\IMimeTypeLoader;
@ -144,46 +271,74 @@ namespace OC\Files\Cache {
public function __construct($cache) {
$this->cache = $cache;
}
public function getNumericStorageId() { }
public function get() { }
public function getIncomplete() {}
public function getPathById($id) {}
public function getAll() {}
public function get($file) {}
public function getFolderContents($folder) {}
public function getFolderContentsById($fileId) {}
public function put($file, array $data) {}
public function insert($file, array $data) {}
public function update($id, array $data) {}
public function getId($file) {}
public function getParentId($file) {}
public function inCache($file) {}
public function remove($file) {}
public function move($source, $target) {}
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {}
public function clear() {}
public function getStatus($file) {}
public function search($pattern) {}
public function searchByMime($mimetype) {}
public function searchQuery(ISearchQuery $query) {}
public function correctFolderSize($path, $data = null, $isBackgroundScan = false) {}
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {}
public function normalize($path) {}
public function getQueryFilterForStorage(): ISearchOperator {}
public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {}
public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) {}
public function getNumericStorageId() {
}
public function getIncomplete() {
}
public function getPathById($id) {
}
public function getAll() {
}
public function get($file) {
}
public function getFolderContents($folder) {
}
public function getFolderContentsById($fileId) {
}
public function put($file, array $data) {
}
public function insert($file, array $data) {
}
public function update($id, array $data) {
}
public function getId($file) {
}
public function getParentId($file) {
}
public function inCache($file) {
}
public function remove($file) {
}
public function move($source, $target) {
}
public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
}
public function clear() {
}
public function getStatus($file) {
}
public function search($pattern) {
}
public function searchByMime($mimetype) {
}
public function searchQuery(ISearchQuery $query) {
}
public function correctFolderSize($path, $data = null, $isBackgroundScan = false) {
}
public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
}
public function normalize($path) {
}
public function getQueryFilterForStorage(): ISearchOperator {
}
public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
}
public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) {
}
}
}
namespace OC\Files\Cache\Wrapper {
use OC\Files\Cache\Cache;
class CacheWrapper extends Cache {}
class CacheWrapper extends Cache {
}
class CachePermissionsMask extends CacheWrapper {
}
}
namespace OC\Files {
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Mount\IMountPoint;
use OCP\IUser;
class Filesystem {
public static function addStorageWrapper(string $wrapperName, callable $wrapper, int $priority = 50) {
@ -199,11 +354,14 @@ namespace OC\Files {
* @param \OCP\Files\Mount\IMountPoint $mount
* @param \OCP\IUser|null $owner
*/
public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {}
public function __construct($path, $storage, $internalPath, $data, $mount, $owner = null) {
}
}
class View {
public function __construct(string $path) {}
public function unlink($path) {}
public function __construct(string $path) {
}
public function unlink($path) {
}
}
}
@ -211,8 +369,10 @@ namespace OC\User {
use OCP\UserInterface;
use OCP\IUser;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class User implements IUser {
public function __construct(string $uid, ?UserInterface $backend, EventDispatcherInterface $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) {}
public function __construct(string $uid, ?UserInterface $backend, EventDispatcherInterface $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) {
}
}
}
@ -220,13 +380,15 @@ namespace OCA\DAV\Upload {
use Sabre\DAV\File;
abstract class FutureFile extends File {}
abstract class FutureFile extends File {
}
}
namespace OCA\DAV\Connector\Sabre {
class Node {
public function getFileInfo(): \OCP\Files\FileInfo {}
public function getFileInfo(): \OCP\Files\FileInfo {
}
}
}
@ -263,9 +425,7 @@ namespace OC\BackgroundJob {
}
namespace OC\Files\Mount {
use OC\Files\Filesystem;
use OC\Files\Storage\Storage;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Mount\IMountPoint;
class MountPoint implements IMountPoint {
@ -386,22 +546,23 @@ namespace OC\Files\Mount {
namespace OC\Files\Storage\Wrapper{
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Search\ISearchQuery;
use OCP\Files\Storage\IStorage;
class Wrapper implements IStorage {
public function __construct(array $parameters) {
}
public function getWrapperStorage(): ?IStorage {}
public function getWrapperStorage(): ?IStorage {
}
public function getId() {}
public function getId() {
}
public function mkdir($path) {}
public function mkdir($path) {
}
public function rmdir($path) {}
public function rmdir($path) {
}
public function opendir($path) {
throw new \Exception('stub');
@ -564,23 +725,44 @@ namespace OC\Files\Storage\Wrapper{
}
public function getUpdater() {
throw new \Exception('stub');
}
public function getWatcher() {
throw new \Exception('stub');
}
}
class Jail extends Wrapper {
public function getUnjailedPath(string $path): string {}
public function getUnjailedPath(string $path): string {
}
}
class Quota extends Wrapper {
public function getQuota() {}
public function getQuota() {
}
}
class PermissionsMask extends Wrapper {
public function getQuota() {}
public function getQuota() {
}
}
}
namespace OCA\Files\Exception {
class TransferOwnershipException extends \Exception {
}
}
namespace OCA\Files\Service {
use OCP\IUser;
class OwnershipTransferService {
public function transfer(IUser $sourceUser,
IUser $destinationUser,
string $path,
?OutputInterface $output = null,
bool $move = false,
bool $firstLogin = false,
bool $transferIncomingShares = false): void {
}
}
}