fix(cs:fix)

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2024-02-02 20:04:13 +01:00
parent ebc52b0093
commit 6ced56ac21
14 changed files with 29 additions and 29 deletions

View File

@ -54,7 +54,7 @@ class Provider implements IProvider {
/**
* @inheritDoc
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'bookmarks') {
throw new InvalidArgumentException();
}

View File

@ -178,7 +178,7 @@ class TreeMapper extends QBMapper {
* @param IQueryBuilder|null $queryBuilder
* @return IQueryBuilder
*/
protected function selectFromType(string $type, array $cols = [], IQueryBuilder $queryBuilder = null): IQueryBuilder {
protected function selectFromType(string $type, array $cols = [], ?IQueryBuilder $queryBuilder = null): IQueryBuilder {
$qb = $queryBuilder ?? $this->db->getQueryBuilder();
$qb->resetQueryPart('from');
$qb
@ -318,7 +318,7 @@ class TreeMapper extends QBMapper {
$ancestors = array_flatten(array_map(function (Entity $ancestor) {
return $this->findParentsOf(self::TYPE_FOLDER, $ancestor->getId());
}, $ancestors));
if (0 === count($ancestors)) {
if (count($ancestors) === 0) {
return false;
}
}
@ -336,7 +336,7 @@ class TreeMapper extends QBMapper {
* @throws MultipleObjectsReturnedException
* @throws UnsupportedOperation
*/
public function deleteEntry(string $type, int $id, int $folderId = null): void {
public function deleteEntry(string $type, int $id, ?int $folderId = null): void {
$this->eventDispatcher->dispatch(BeforeDeleteEvent::class, new BeforeDeleteEvent($type, $id));
if ($type === self::TYPE_FOLDER) {
@ -439,7 +439,7 @@ class TreeMapper extends QBMapper {
* @throws MultipleObjectsReturnedException
* @throws UnsupportedOperation
*/
public function move(string $type, int $itemId, int $newParentFolderId, int $index = null): void {
public function move(string $type, int $itemId, int $newParentFolderId, ?int $index = null): void {
if ($type === self::TYPE_BOOKMARK) {
throw new UnsupportedOperation('Cannot move Bookmark');
}
@ -515,7 +515,7 @@ class TreeMapper extends QBMapper {
if ($type !== self::TYPE_BOOKMARK) {
throw new UnsupportedOperation('Only bookmarks can be in multiple folders');
}
if (0 === count($folders)) {
if (count($folders) === 0) {
return;
}
@ -537,7 +537,7 @@ class TreeMapper extends QBMapper {
* @param int|null $index
* @throws UnsupportedOperation|Exception
*/
public function addToFolders(string $type, int $itemId, array $folders, int $index = null): void {
public function addToFolders(string $type, int $itemId, array $folders, ?int $index = null): void {
if ($type !== self::TYPE_BOOKMARK) {
throw new UnsupportedOperation('Only bookmarks can be in multiple folders');
}

View File

@ -19,7 +19,7 @@ class MoveEvent extends ChangeEvent {
* @param int|null $oldParent
* @param int|null $newParent
*/
public function __construct(string $type, int $id, int $oldParent = null, int $newParent = null) {
public function __construct(string $type, int $id, ?int $oldParent = null, ?int $newParent = null) {
parent::__construct($type, $id);
$this->oldParent = $oldParent;
$this->newParent = $newParent;

View File

@ -7,7 +7,6 @@
namespace OCA\Bookmarks\Middleware;
use \OCP\AppFramework\Middleware;
use OCA\Bookmarks\Controller\BookmarkController;
use OCA\Bookmarks\Controller\FoldersController;
use OCA\Bookmarks\Controller\InternalBookmarkController;
@ -15,6 +14,7 @@ use OCA\Bookmarks\Controller\InternalFoldersController;
use OCA\Bookmarks\Exception\UnauthenticatedError;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Middleware;
class ExceptionMiddleware extends Middleware {
public function afterException($controller, $methodName, \Exception $exception): DataResponse {

View File

@ -100,7 +100,7 @@ class QueryParameters {
* @param array|null $columns
* @return string|null
*/
public function getSortBy(string $default = null, array $columns = null): ?string {
public function getSortBy(?string $default = null, ?array $columns = null): ?string {
if (isset($default) && !isset($this->sortBy)) {
return $default;
}

View File

@ -78,7 +78,7 @@ class Authorizer {
$this->setUserId($this->userSession->getUser()->getUID());
return;
}
if (false === $this->userSession->login($request->server['PHP_AUTH_USER'], $request->server['PHP_AUTH_PW'])) {
if ($this->userSession->login($request->server['PHP_AUTH_USER'], $request->server['PHP_AUTH_PW']) === false) {
return;
}
$this->setUserId($this->userSession->getUser()->getUID());
@ -90,7 +90,7 @@ class Authorizer {
return;
}
[$username, $password] = explode(':', base64_decode($credentials));
if (false === $this->userSession->login($username, $password)) {
if ($this->userSession->login($username, $password) === false) {
return;
}
$this->setUserId($this->userSession->getUser()->getUID());

View File

@ -131,7 +131,7 @@ class BookmarkService {
* @throws UrlParseError
* @throws UserLimitExceededError
*/
public function create(string $userId, string $url = '', string $title = null, string $description = null, array $tags = null, $folders = []): Bookmark {
public function create(string $userId, string $url = '', ?string $title = null, ?string $description = null, ?array $tags = null, $folders = []): Bookmark {
$bookmark = null;
$ownFolders = array_filter($folders, function ($folderId) use ($userId) {
/**
@ -174,7 +174,7 @@ class BookmarkService {
* @throws UserLimitExceededError
* @throws UnsupportedOperation
*/
private function _addBookmark($userId, $url, string $title = null, $description = null, array $tags = null, array $folders = []): Bookmark {
private function _addBookmark($userId, $url, ?string $title = null, $description = null, ?array $tags = null, array $folders = []): Bookmark {
$bookmark = null;
try {
@ -268,7 +268,7 @@ class BookmarkService {
* @throws UrlParseError
* @throws UserLimitExceededError
*/
public function update(string $userId, $id, string $url = null, string $title = null, string $description = null, array $tags = null, array $folders = null): ?Bookmark {
public function update(string $userId, $id, ?string $url = null, ?string $title = null, ?string $description = null, ?array $tags = null, ?array $folders = null): ?Bookmark {
/**
* @var $bookmark Bookmark
*/

View File

@ -96,7 +96,7 @@ class BookmarksParser {
* @return boolean
*/
public static function isValid($doctype): bool {
return self::DOCTYPE === $doctype;
return $doctype === self::DOCTYPE;
}
/**
@ -117,7 +117,7 @@ class BookmarksParser {
if (empty($input)) {
throw new HtmlParseError("The input shouldn't be empty");
}
if (false === $document->loadHTML($input, LIBXML_PARSEHUGE)) {
if ($document->loadHTML($input, LIBXML_PARSEHUGE) === false) {
throw new HtmlParseError('The HTML value does not appear to be valid Netscape Bookmark File Format HTML.');
}
$this->xpath = new DOMXPath($document);
@ -138,7 +138,7 @@ class BookmarksParser {
*
* @param DOMNode|null $node
*/
private function traverse(DOMNode $node = null): void {
private function traverse(?DOMNode $node = null): void {
$query = './*';
$entries = $this->xpath->query($query, $node ?: null);
if (!$entries) {
@ -268,7 +268,7 @@ class BookmarksParser {
if ($this->useDateTimeObjects) {
if (isset($attributes['add_date'])) {
$added = new DateTime();
if (self::THOUSAND_YEARS < (int)$attributes['add_date']) {
if ((int)$attributes['add_date'] > self::THOUSAND_YEARS) {
// Google exports dates in miliseconds. This way we only lose the first year of UNIX Epoch.
// This is invalid once we hit 2970. So, quite a long time.
$added->setTimestamp((int) ($attributes['add_date'] / 1000));
@ -297,7 +297,7 @@ class BookmarksParser {
private function getCurrentFolderTags(): array {
$tags = [];
array_walk_recursive($this->currentFolder, static function ($tag, $key) use (&$tags) {
if ('name' === $key) {
if ($key === 'name') {
$tags[] = $tag;
}
});

View File

@ -134,7 +134,7 @@ class FaviconPreviewer implements IBookmarkPreviewer {
$contentType = $response->getHeader('Content-Type');
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}

View File

@ -90,7 +90,7 @@ class HtmlImporter {
* @throws UserLimitExceededError
* @throws HtmlParseError
*/
public function importFile($userId, string $file, int $rootFolder = null): array {
public function importFile($userId, string $file, ?int $rootFolder = null): array {
$content = file_get_contents($file);
return $this->import($userId, $content, $rootFolder);
}
@ -113,7 +113,7 @@ class HtmlImporter {
*
* @psalm-return array{imported: list<array>, errors: array<array-key, mixed|string>}
*/
public function import($userId, string $content, int $rootFolderId = null): array {
public function import($userId, string $content, ?int $rootFolderId = null): array {
$imported = [];
$errors = [];

View File

@ -80,7 +80,7 @@ class DefaultBookmarkPreviewer implements IBookmarkPreviewer {
$contentType = $response->getHeader('Content-Type');
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}

View File

@ -67,7 +67,7 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer {
if (!isset($bookmark)) {
return null;
}
if ('' === $this->apiKey) {
if ($this->apiKey === '') {
return null;
}
$url = $bookmark->getUrl();
@ -97,7 +97,7 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer {
}
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}

View File

@ -84,7 +84,7 @@ class ScreenshotMachineBookmarkPreviewer implements IBookmarkPreviewer {
]
);
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}
$body = $response->getBody();

View File

@ -93,7 +93,7 @@ class WebshotBookmarkPreviewer implements IBookmarkPreviewer {
'timeout' => self::HTTP_TIMEOUT,
]);
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}
$data = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
@ -101,7 +101,7 @@ class WebshotBookmarkPreviewer implements IBookmarkPreviewer {
// get it
$response = $this->client->get($this->apiUrl . $data->id);
// Some HTPP Error occured :/
if (200 !== $response->getStatusCode()) {
if ($response->getStatusCode() !== 200) {
return null;
}
$body = $response->getBody();