feat: 🧑‍💻 switch to phpstan
All checks were successful
repod / xml (push) Successful in 16s
repod / php (push) Successful in 41s
repod / nodejs (push) Successful in 43s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2025-02-14 16:25:10 +00:00
parent c4a9908f58
commit e2735080f0
15 changed files with 29 additions and 3138 deletions

View File

@ -24,7 +24,7 @@ jobs:
- run: composer install - run: composer install
- run: composer run lint - run: composer run lint
- run: composer run cs:check - run: composer run cs:check
- run: composer run psalm - run: composer run phpstan
nodejs: nodejs:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -5,32 +5,33 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"OCA\\RePod\\": "lib/", "OCA\\RePod\\": "lib/",
"OCA\\GPodderSync\\": "stubs/OCA/GPodderSync/" "OCA\\GPodderSync\\": "stubs/OCA/GPodderSync/",
"OCP\\": "vendor/nextcloud/ocp/OCP/"
} }
}, },
"scripts": { "scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l", "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff", "cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix", "cs:fix": "php-cs-fixer fix",
"psalm": "psalm --threads=1 --no-cache --show-info=true", "phpstan": "phpstan clear-result-cache && phpstan analyse -c phpstan.neon",
"rector": "rector && composer cs:fix" "rector": "rector && composer cs:fix"
}, },
"require": { "require": {
"php": "~8.1.31" "php": "^8.1"
}, },
"require-dev": { "require-dev": {
"nextcloud/ocp": "^30.0.6",
"roave/security-advisories": "dev-latest",
"nextcloud/coding-standard": "^1.3.2", "nextcloud/coding-standard": "^1.3.2",
"nextcloud/ocp": "^30.0.6",
"nextcloud/rector": "^0.3.1", "nextcloud/rector": "^0.3.1",
"phpstan/phpstan": "^1.12",
"rector/rector": "~1.2.10", "rector/rector": "~1.2.10",
"vimeo/psalm": "^6.5.1" "roave/security-advisories": "dev-latest"
}, },
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,
"sort-packages": true, "sort-packages": true,
"platform": { "platform": {
"php": "8.1.31" "php": "8.1"
} }
} }
} }

3094
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,6 @@ class Application extends App implements IBootstrap
} }
public function boot(IBootContext $context): void { public function boot(IBootContext $context): void {
/** @psalm-suppress DeprecatedInterface */
$appContainer = $context->getAppContainer(); $appContainer = $context->getAppContainer();
/** @var IAppManager $appManager */ /** @var IAppManager $appManager */

View File

@ -10,9 +10,9 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
* Base: https://github.com/pbek/nextcloud-nextpod/blob/main/lib/Core/EpisodeAction/EpisodeActionExtraData.php. * Base: https://github.com/pbek/nextcloud-nextpod/blob/main/lib/Core/EpisodeAction/EpisodeActionExtraData.php.
* Specs: https://github.com/Podcast-Standards-Project/PSP-1-Podcast-RSS-Specification/blob/main/README.md#required-item-elements. * Specs: https://github.com/Podcast-Standards-Project/PSP-1-Podcast-RSS-Specification/blob/main/README.md#required-item-elements.
* *
* @psalm-import-type EpisodeActionType from EpisodeAction * @phpstan-import-type EpisodeActionType from EpisodeAction
* *
* @psalm-type EpisodeActionExtraDataType = array{ * @phpstan-type EpisodeActionExtraDataType = array{
* title: string, * title: string,
* url: ?string, * url: ?string,
* name: string, * name: string,

View File

@ -142,7 +142,6 @@ class EpisodeActionReader extends CoreEpisodeActionReader
* @param null|\SimpleXMLElement|string $value * @param null|\SimpleXMLElement|string $value
*/ */
private function stringOrNull($value): ?string { private function stringOrNull($value): ?string {
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!empty($value)) { if (!empty($value)) {
return (string) $value; return (string) $value;
} }

View File

@ -44,7 +44,7 @@ class MultiPodService implements IPodProvider
array_unique( array_unique(
array_map( array_map(
fn (PodcastData $feed) => $feed->getLink(), fn (PodcastData $feed) => $feed->getLink(),
array_filter($podcasts, fn (PodcastData $feed) => $feed->getLink()) array_filter($podcasts, fn (PodcastData $feed): bool => null !== $feed->getLink())
) )
) )
) )

View File

@ -29,6 +29,9 @@ class SearchProvider implements IProvider
return $this->l10n->t('Podcast'); return $this->l10n->t('Podcast');
} }
/**
* @param array<string> $routeParameters
*/
public function getOrder(string $route, array $routeParameters): int { public function getOrder(string $route, array $routeParameters): int {
if (str_starts_with($route, Application::APP_ID.'.')) { if (str_starts_with($route, Application::APP_ID.'.')) {
// Active app, prefer my results // Active app, prefer my results

6
phpstan.neon Normal file
View File

@ -0,0 +1,6 @@
parameters:
level: 9
paths:
- lib
ignoreErrors:
- '#Method [a-zA-Z0-9:\(\)\\_]+ return type with generic class OCP\\AppFramework\\Http\\[a-zA-Z]+ does not specify its types#'

View File

@ -1,29 +0,0 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
phpVersion="8.1"
>
<projectFiles>
<directory name="lib" />
<directory name="stubs" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<extraFiles>
<directory name="vendor" />
</extraFiles>
<issueHandlers>
<InvalidReturnType>
<errorLevel type="suppress">
<directory name="stubs" />
</errorLevel>
</InvalidReturnType>
</issueHandlers>
</psalm>

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace OCA\GPodderSync\Core\EpisodeAction; namespace OCA\GPodderSync\Core\EpisodeAction;
/** /**
* @psalm-type EpisodeActionType = array{ * @phpstan-type EpisodeActionType = array{
* podcast: string, * podcast: string,
* episode: string, * episode: string,
* action: string, * action: string,

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData; namespace OCA\GPodderSync\Core\PodcastData;
/** /**
* @psalm-type PodcastActionCountsType = array{ * @phpstan-type PodcastActionCountsType = array{
* delete: int, * delete: int,
* download: int, * download: int,
* flattr: int, * flattr: int,

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData; namespace OCA\GPodderSync\Core\PodcastData;
/** /**
* @psalm-type PodcastDataType = array{ * @phpstan-type PodcastDataType = array{
* title: ?string, * title: ?string,
* author: ?string, * author: ?string,
* link: ?string, * link: ?string,

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace OCA\GPodderSync\Core\PodcastData; namespace OCA\GPodderSync\Core\PodcastData;
/** /**
* @psalm-type PodcastMetricsType = array{ * @phpstan-type PodcastMetricsType = array{
* url: string, * url: string,
* listenedSeconds: int, * listenedSeconds: int,
* actionCounts: PodcastActionCounts * actionCounts: PodcastActionCounts

View File

@ -8,7 +8,7 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
use OCP\AppFramework\Db\Entity; use OCP\AppFramework\Db\Entity;
/** /**
* @psalm-import-type EpisodeActionType from EpisodeAction * @phpstan-import-type EpisodeActionType from EpisodeAction
* *
* @method string getPodcast() * @method string getPodcast()
* @method void setPodcast(string $podcast) * @method void setPodcast(string $podcast)