fix(psalm): Add stubs

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2024-02-02 19:34:25 +01:00
parent fcc2029427
commit 8376c2e684
3 changed files with 144 additions and 161 deletions

View File

@ -12,6 +12,9 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
</stubs>
<projectFiles>
<directory name="lib" />
<ignoreFiles>

View File

@ -1,161 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.18.2@19aa905f7c3c7350569999a93c40ae91ae4e1626">
<file src="lib/BackgroundJobs/CrawlJob.php">
<UndefinedClass occurrences="1">
<code>TimedJob</code>
</UndefinedClass>
</file>
<file src="lib/Controller/BookmarkController.php">
<InvalidArgument occurrences="3">
<code>$folder</code>
<code>$id</code>
<code>$title</code>
</InvalidArgument>
<InvalidNullableReturnType occurrences="1">
<code>int</code>
</InvalidNullableReturnType>
<InvalidReturnStatement occurrences="1">
<code>new NotFoundResponse()</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>DataDisplayResponse</code>
</InvalidReturnType>
<NullableReturnStatement occurrences="1">
<code>$this-&gt;_getRootFolderId()</code>
</NullableReturnStatement>
</file>
<file src="lib/Controller/FoldersController.php">
<InvalidArgument occurrences="2">
<code>$parent_folder</code>
<code>$title</code>
</InvalidArgument>
</file>
<file src="lib/Controller/InternalBookmarkController.php">
<InvalidArgument occurrences="1">
<code>$tags</code>
</InvalidArgument>
</file>
<file src="lib/Db/BookmarkMapper.php">
<InvalidArgument occurrences="3"/>
</file>
<file src="lib/Db/PublicFolderMapper.php">
<InvalidReturnType occurrences="1">
<code>Entity</code>
</InvalidReturnType>
</file>
<file src="lib/Db/TreeMapper.php">
<InvalidArgument occurrences="1"/>
</file>
<file src="lib/Flow/CreateBookmark.php">
<UndefinedClass occurrences="2">
<code>File</code>
<code>View</code>
</UndefinedClass>
<UndefinedMethod occurrences="2">
<code>getSubject</code>
<code>getSubject</code>
</UndefinedMethod>
</file>
<file src="lib/Image.php">
<UndefinedConstant occurrences="2">
<code>JSON_THROW_ON_ERROR</code>
<code>JSON_THROW_ON_ERROR</code>
</UndefinedConstant>
</file>
<file src="lib/Migration/DeduplicateSharedFoldersRepairStep.php">
<InvalidArgument occurrences="1"/>
</file>
<file src="lib/Migration/Version000014000Date20181029094721.php">
<InvalidArgument occurrences="2">
<code>['index' =&gt; $qb-&gt;createPositionalParameter($i)]</code>
<code>['index' =&gt; $qb-&gt;createPositionalParameter($i)]</code>
</InvalidArgument>
<TooFewArguments occurrences="2">
<code>set</code>
<code>set</code>
</TooFewArguments>
</file>
<file src="lib/Migration/Version003000009Date20200505094721.php">
<UndefinedClass occurrences="1">
<code>Type</code>
</UndefinedClass>
</file>
<file src="lib/Migration/Version003004000Date20200807124721.php">
<UndefinedClass occurrences="1">
<code>Type</code>
</UndefinedClass>
</file>
<file src="lib/Migration/Version003004000Date20200817124721.php">
<UndefinedClass occurrences="1">
<code>Type</code>
</UndefinedClass>
</file>
<file src="lib/QueryParameters.php">
<NullableReturnStatement occurrences="1">
<code>$default</code>
</NullableReturnStatement>
</file>
<file src="lib/Service/BookmarkPreviewer.php">
<UndefinedInterfaceMethod occurrences="1">
<code>serialize</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Service/BookmarkService.php">
<NullArgument occurrences="1">
<code>$id</code>
</NullArgument>
</file>
<file src="lib/Service/BookmarksParser.php">
<NullPropertyFetch occurrences="1">
<code>$node-&gt;attributes-&gt;length</code>
</NullPropertyFetch>
</file>
<file src="lib/Service/CrawlService.php">
<MissingDependency occurrences="1">
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>NoUserException</code>
</UndefinedClass>
</file>
<file src="lib/Service/FileCache.php">
<LessSpecificImplementedReturnType occurrences="2">
<code>bool|mixed</code>
<code>bool|mixed</code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/Service/FolderService.php">
<InvalidReturnStatement occurrences="1">
<code>$publicFolder-&gt;getId()</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>string</code>
</InvalidReturnType>
</file>
<file src="lib/Service/HashManager.php">
<UndefinedConstant occurrences="2">
<code>JSON_THROW_ON_ERROR</code>
<code>JSON_THROW_ON_ERROR</code>
</UndefinedConstant>
</file>
<file src="lib/Service/HtmlImporter.php">
<InvalidArgument occurrences="1">
<code>$index++</code>
</InvalidArgument>
</file>
<file src="lib/Service/LinkExplorer.php">
<UndefinedInterfaceMethod occurrences="1">
<code>setMinimumImageDimensions</code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php">
<UndefinedConstant occurrences="1">
<code>JSON_THROW_ON_ERROR</code>
</UndefinedConstant>
</file>
<file src="lib/Service/Previewers/WebshotBookmarkPreviewer.php">
<UndefinedConstant occurrences="1">
<code>JSON_THROW_ON_ERROR</code>
</UndefinedConstant>
</file>
</files>

141
tests/stub.phpstub Normal file
View File

@ -0,0 +1,141 @@
<?php
declare(strict_types=1);
namespace OC\Hooks {
class Emitter {
public function emit(string $class, string $value, array $option) {
}
/** Closure $closure */
public function listen(string $class, string $value, $closure) {
}
}
}
namespace OC {
class SystemConfig {
public function getKeys();
public function setValue($key, $value);
public function setValues(array $configs);
public function getValue($key, $default = '');
public function getFilteredValue($key, $default = '');
public function deleteValue($key);
}
}
namespace OC\Files\Cache {
class CacheQueryBuilder extends \OCP\DB\QueryBuilder\IQueryBuilder {
public function __construct(\OCP\IDBCOnnection $db, \OC\SystemConfig $config, \Psr\Log\LoggerInterface $logger, \OCP\FilesMetadata\IFilesMetadataManager $filesMetadataManager);
public function selectFileCache(string $alias = null, bool $joinExtendedCache = true):CacheQueryBuilder;
public function whereStorageId(int $storageId):CacheQueryBuilder;
public function whereFileId(int $fileId):CacheQueryBuilder;
public function wherePath(string $path):CacheQueryBuilder;
public function whereParent(int $parent):CacheQueryBuilder;
public function whereParentInParameter(string $parameter):CacheQueryBuilder;
}
}
namespace Doctrine\DBAL {
final class ParameterType {
/**
* Represents the SQL NULL data type.
*/
public const NULL = 0;
/**
* Represents the SQL INTEGER data type.
*/
public const INTEGER = 1;
/**
* Represents the SQL CHAR, VARCHAR, or other string data type.
*
* @see \PDO::PARAM_STR
*/
public const STRING = 2;
/**
* Represents the SQL large object data type.
*/
public const LARGE_OBJECT = 3;
/**
* Represents a boolean data type.
*
* @see \PDO::PARAM_BOOL
*/
public const BOOLEAN = 5;
/**
* Represents a binary string data type.
*/
public const BINARY = 16;
/**
* Represents an ASCII string data type
*/
public const ASCII = 17;
/**
* This class cannot be instantiated.
*
* @codeCoverageIgnore
*/
private function __construct() {
}
}
final class ArrayParameterType {
/**
* Represents an array of ints to be expanded by Doctrine SQL parsing.
*/
public const INTEGER = ParameterType::INTEGER + Connection::ARRAY_PARAM_OFFSET;
/**
* Represents an array of strings to be expanded by Doctrine SQL parsing.
*/
public const STRING = ParameterType::STRING + Connection::ARRAY_PARAM_OFFSET;
/**
* Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
*/
public const ASCII = ParameterType::ASCII + Connection::ARRAY_PARAM_OFFSET;
/**
* Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
*/
public const BINARY = ParameterType::BINARY + Connection::ARRAY_PARAM_OFFSET;
/**
* @internal
*
* @psalm-param self::* $type
*
* @psalm-return ParameterType::INTEGER|ParameterType::STRING|ParameterType::ASCII|ParameterType::BINARY
*/
public static function toElementParameterType(int $type): int {
}
private function __construct() {
}
}
class Connection {
/**
* Represents an array of ints to be expanded by Doctrine SQL parsing.
*/
public const PARAM_INT_ARRAY = ParameterType::INTEGER + self::ARRAY_PARAM_OFFSET;
/**
* Represents an array of strings to be expanded by Doctrine SQL parsing.
*/
public const PARAM_STR_ARRAY = ParameterType::STRING + self::ARRAY_PARAM_OFFSET;
/**
* Offset by which PARAM_* constants are detected as arrays of the param type.
*/
public const ARRAY_PARAM_OFFSET = 100;
}
}