feat: 🧑💻 add rector
This commit is contained in:
parent
66cb15ee32
commit
25af5bdf54
@ -12,12 +12,14 @@
|
|||||||
"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"
|
"psalm": "psalm --threads=1 --no-cache --show-info=true",
|
||||||
|
"rector": "rector && composer cs:fix"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"nextcloud/ocp": "^30.0.2",
|
"nextcloud/ocp": "^30.0.2",
|
||||||
"roave/security-advisories": "dev-latest",
|
|
||||||
"nextcloud/coding-standard": "^1.3.2",
|
"nextcloud/coding-standard": "^1.3.2",
|
||||||
|
"rector/rector": "^1.2.10",
|
||||||
|
"roave/security-advisories": "dev-latest",
|
||||||
"vimeo/psalm": "^5.26.1"
|
"vimeo/psalm": "^5.26.1"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
133
composer.lock
generated
133
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2bded493404c793fc0cfceedfeccc38c",
|
"content-hash": "1b3b97dd0074d6decb4ce7f570ef7d4e",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
@ -1049,23 +1049,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/type-resolver",
|
"name": "phpdocumentor/type-resolver",
|
||||||
"version": "1.9.0",
|
"version": "1.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
"url": "https://github.com/phpDocumentor/TypeResolver.git",
|
||||||
"reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d"
|
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d",
|
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a",
|
||||||
"reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d",
|
"reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"doctrine/deprecations": "^1.0",
|
"doctrine/deprecations": "^1.0",
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"phpdocumentor/reflection-common": "^2.0",
|
"phpdocumentor/reflection-common": "^2.0",
|
||||||
"phpstan/phpdoc-parser": "^1.18"
|
"phpstan/phpdoc-parser": "^1.18|^2.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-tokenizer": "*",
|
"ext-tokenizer": "*",
|
||||||
@ -1101,9 +1101,9 @@
|
|||||||
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||||
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0"
|
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0"
|
||||||
},
|
},
|
||||||
"time": "2024-11-03T20:11:34+00:00"
|
"time": "2024-11-09T15:12:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpdoc-parser",
|
"name": "phpstan/phpdoc-parser",
|
||||||
@ -1152,6 +1152,64 @@
|
|||||||
},
|
},
|
||||||
"time": "2024-10-13T11:25:22+00:00"
|
"time": "2024-10-13T11:25:22+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "1.12.8",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6a60a4d66142b8156c9da923f1972657bc4748c",
|
||||||
|
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan-shim": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"phpstan",
|
||||||
|
"phpstan.phar"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"docs": "https://phpstan.org/user-guide/getting-started",
|
||||||
|
"forum": "https://github.com/phpstan/phpstan/discussions",
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"security": "https://github.com/phpstan/phpstan/security/policy",
|
||||||
|
"source": "https://github.com/phpstan/phpstan-src"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/ondrejmirtes",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/phpstan",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-06T19:06:49+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/clock",
|
"name": "psr/clock",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@ -1353,6 +1411,65 @@
|
|||||||
},
|
},
|
||||||
"time": "2021-07-14T16:41:46+00:00"
|
"time": "2021-07-14T16:41:46+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "rector/rector",
|
||||||
|
"version": "1.2.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/rectorphp/rector.git",
|
||||||
|
"reference": "40f9cf38c05296bd32f444121336a521a293fa61"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/rectorphp/rector/zipball/40f9cf38c05296bd32f444121336a521a293fa61",
|
||||||
|
"reference": "40f9cf38c05296bd32f444121336a521a293fa61",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0",
|
||||||
|
"phpstan/phpstan": "^1.12.5"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"rector/rector-doctrine": "*",
|
||||||
|
"rector/rector-downgrade-php": "*",
|
||||||
|
"rector/rector-phpunit": "*",
|
||||||
|
"rector/rector-symfony": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/rector"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
||||||
|
"keywords": [
|
||||||
|
"automation",
|
||||||
|
"dev",
|
||||||
|
"migration",
|
||||||
|
"refactoring"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/rectorphp/rector/issues",
|
||||||
|
"source": "https://github.com/rectorphp/rector/tree/1.2.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/tomasvotruba",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-08T13:59:10+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "roave/security-advisories",
|
"name": "roave/security-advisories",
|
||||||
"version": "dev-latest",
|
"version": "dev-latest",
|
||||||
|
@ -16,6 +16,7 @@ use OCP\AppFramework\Services\IInitialState;
|
|||||||
class Application extends App implements IBootstrap
|
class Application extends App implements IBootstrap
|
||||||
{
|
{
|
||||||
public const APP_ID = 'repod';
|
public const APP_ID = 'repod';
|
||||||
|
|
||||||
private const GPODDERSYNC_ID = 'gpoddersync';
|
private const GPODDERSYNC_ID = 'gpoddersync';
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
@ -40,7 +41,7 @@ class Application extends App implements IBootstrap
|
|||||||
if (!$gpoddersync) {
|
if (!$gpoddersync) {
|
||||||
try {
|
try {
|
||||||
$appManager->enableApp(self::GPODDERSYNC_ID);
|
$appManager->enableApp(self::GPODDERSYNC_ID);
|
||||||
} catch (AppPathNotFoundException $e) {
|
} catch (AppPathNotFoundException) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ class EpisodesController extends Controller
|
|||||||
$client = $this->clientService->newClient();
|
$client = $this->clientService->newClient();
|
||||||
$feed = $client->get($url);
|
$feed = $client->get($url);
|
||||||
$episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody());
|
$episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody());
|
||||||
usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getPubDate() <=> $a->getPubDate());
|
usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b): int => $b->getPubDate() <=> $a->getPubDate());
|
||||||
$episodes = array_values(array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes))));
|
$episodes = array_values(array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode): string => $episode->getGuid(), $episodes))));
|
||||||
|
|
||||||
return new JSONResponse($episodes, $feed->getStatusCode());
|
return new JSONResponse($episodes, $feed->getStatusCode());
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ class OpmlController extends Controller
|
|||||||
foreach ($subscriptions as $subscription) {
|
foreach ($subscriptions as $subscription) {
|
||||||
try {
|
try {
|
||||||
$podcast = $this->podcastDataReader->getCachedOrFetchPodcastData($subscription->getUrl(), $this->userService->getUserUID());
|
$podcast = $this->podcastDataReader->getCachedOrFetchPodcastData($subscription->getUrl(), $this->userService->getUserUID());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,15 +11,13 @@ use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|||||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\IConfig;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
class PageController extends Controller
|
class PageController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IRequest $request,
|
IRequest $request
|
||||||
private IConfig $config
|
|
||||||
) {
|
) {
|
||||||
parent::__construct(Application::APP_ID, $request);
|
parent::__construct(Application::APP_ID, $request);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class PodcastController extends Controller
|
|||||||
if ($this->cacheFactory->isLocalCacheAvailable()) {
|
if ($this->cacheFactory->isLocalCacheAvailable()) {
|
||||||
try {
|
try {
|
||||||
$podcast = $this->podcastDataReader->tryGetCachedPodcastData($url);
|
$podcast = $this->podcastDataReader->tryGetCachedPodcastData($url);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ class PodcastController extends Controller
|
|||||||
if ($this->cacheFactory->isLocalCacheAvailable()) {
|
if ($this->cacheFactory->isLocalCacheAvailable()) {
|
||||||
try {
|
try {
|
||||||
$this->podcastDataReader->trySetCachedPodcastData($url, $podcast);
|
$this->podcastDataReader->trySetCachedPodcastData($url, $podcast);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ use OCA\GPodderSync\Core\EpisodeAction\EpisodeAction;
|
|||||||
* action: ?EpisodeActionType
|
* action: ?EpisodeActionType
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
class EpisodeActionExtraData implements \JsonSerializable
|
class EpisodeActionExtraData implements \JsonSerializable, \Stringable
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $title,
|
private string $title,
|
||||||
@ -120,7 +120,7 @@ class EpisodeActionExtraData implements \JsonSerializable
|
|||||||
'size' => $this->size,
|
'size' => $this->size,
|
||||||
'pubDate' => $this->pubDate,
|
'pubDate' => $this->pubDate,
|
||||||
'duration' => $this->duration,
|
'duration' => $this->duration,
|
||||||
'action' => $this->action ? $this->action->toArray() : null,
|
'action' => $this->action instanceof EpisodeAction ? $this->action->toArray() : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class EpisodeActionReader extends CoreEpisodeActionReader
|
|||||||
if (isset($pubDate)) {
|
if (isset($pubDate)) {
|
||||||
try {
|
try {
|
||||||
$pubDate = new \DateTime($pubDate);
|
$pubDate = new \DateTime($pubDate);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception) {
|
||||||
$pubDate = null;
|
$pubDate = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,8 @@ class FyydService implements IPodProvider
|
|||||||
if (array_key_exists('data', $langJson) && is_array($langJson['data'])) {
|
if (array_key_exists('data', $langJson) && is_array($langJson['data'])) {
|
||||||
$language = in_array($userLang, $langJson['data']) ? $userLang : 'en';
|
$language = in_array($userLang, $langJson['data']) ? $userLang : 'en';
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $exception) {
|
||||||
$this->logger->error($e->getMessage(), $e->getTrace());
|
$this->logger->error($exception->getMessage(), $exception->getTrace());
|
||||||
}
|
}
|
||||||
|
|
||||||
$podcastClient = $this->clientService->newClient();
|
$podcastClient = $this->clientService->newClient();
|
||||||
|
@ -36,7 +36,7 @@ class MultiPodService implements IPodProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($podcasts, fn (PodcastData $a, PodcastData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix());
|
usort($podcasts, fn (PodcastData $a, PodcastData $b): int => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix());
|
||||||
|
|
||||||
return array_values(
|
return array_values(
|
||||||
array_intersect_key(
|
array_intersect_key(
|
||||||
|
@ -30,7 +30,7 @@ class SearchProvider implements IProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getOrder(string $route, array $routeParameters): int {
|
public function getOrder(string $route, array $routeParameters): int {
|
||||||
if (0 === strpos($route, Application::APP_ID.'.')) {
|
if (str_starts_with($route, Application::APP_ID.'.')) {
|
||||||
// Active app, prefer my results
|
// Active app, prefer my results
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class UserService
|
|||||||
public function getCountryCode(): string {
|
public function getCountryCode(): string {
|
||||||
$isoCodes = explode('_', $this->getIsoCode());
|
$isoCodes = explode('_', $this->getIsoCode());
|
||||||
|
|
||||||
return isset($isoCodes[1]) ? $isoCodes[1] : 'us';
|
return $isoCodes[1] ?? 'us';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLangCode(): string {
|
public function getLangCode(): string {
|
||||||
|
29
rector.php
Normal file
29
rector.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Rector\Config\RectorConfig;
|
||||||
|
|
||||||
|
return RectorConfig::configure()
|
||||||
|
->withPaths([
|
||||||
|
__DIR__.'/lib',
|
||||||
|
])
|
||||||
|
->withPhpSets(php80: true)
|
||||||
|
->withPreparedSets(
|
||||||
|
deadCode: true,
|
||||||
|
codeQuality: true,
|
||||||
|
codingStyle: true,
|
||||||
|
typeDeclarations: true,
|
||||||
|
privatization: true,
|
||||||
|
instanceOf: true,
|
||||||
|
earlyReturn: true,
|
||||||
|
strictBooleans: true,
|
||||||
|
rectorPreset: true,
|
||||||
|
phpunitCodeQuality: true,
|
||||||
|
doctrineCodeQuality: true,
|
||||||
|
symfonyCodeQuality: true,
|
||||||
|
symfonyConfigs: true,
|
||||||
|
twig: true,
|
||||||
|
phpunit: true,
|
||||||
|
)
|
||||||
|
;
|
Loading…
Reference in New Issue
Block a user