Solve more PHPStan issues
This commit is contained in:
parent
d60b1dd776
commit
eb03679579
@ -8,10 +8,12 @@ parameters:
|
||||
- ./console
|
||||
- index.php
|
||||
ignoreErrors:
|
||||
- '#Access to an undefined property Aviat\\Ion\\Friend#'
|
||||
- "#Offset 'fields' does not exist on array#"
|
||||
- '#Call to an undefined method Aura\\\Html\\\HelperLocator::[a-zA-Z0-9_]+\(\)#'
|
||||
- '#Call to an undefined method Query\\QueryBuilderInterface::[a-zA-Z0-9_]+\(\)#'
|
||||
excludes_analyse:
|
||||
- tests/mocks.php
|
||||
- vendor
|
||||
- vendor
|
||||
# These are objects that basically can return anything
|
||||
universalObjectCratesClasses:
|
||||
- Aviat\Ion\Friend
|
||||
|
@ -66,7 +66,7 @@ final class Auth {
|
||||
->getSegment(SESSION_SEGMENT);
|
||||
$this->model = $container->get('kitsu-model');
|
||||
|
||||
Event::on('::unauthorized::', [$this, 'reAuthenticate'], []);
|
||||
Event::on('::unauthorized::', [$this, 'reAuthenticate']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,6 +76,7 @@ final class Auth {
|
||||
* @param string $password
|
||||
* @return boolean
|
||||
* @throws Throwable
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function authenticate(string $password): bool
|
||||
{
|
||||
@ -90,9 +91,10 @@ final class Auth {
|
||||
/**
|
||||
* Make the call to re-authenticate with the existing refresh token
|
||||
*
|
||||
* @param string $refreshToken
|
||||
* @param string|null $refreshToken
|
||||
* @return boolean
|
||||
* @throws Throwable|InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function reAuthenticate(?string $refreshToken = NULL): bool
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ final class LibraryEntryTransformer extends AbstractTransformer
|
||||
{
|
||||
public function transform($item)
|
||||
{
|
||||
$item = (array)$item;
|
||||
$type = $item['media']['type'] ?? '';
|
||||
|
||||
$genres = [];
|
||||
@ -50,7 +51,7 @@ final class LibraryEntryTransformer extends AbstractTransformer
|
||||
}
|
||||
}
|
||||
|
||||
private function animeTransform($item, array $genres): AnimeListItem
|
||||
private function animeTransform(array $item, array $genres): AnimeListItem
|
||||
{
|
||||
$animeId = $item['media']['id'];
|
||||
$anime = $item['media'];
|
||||
@ -119,7 +120,7 @@ final class LibraryEntryTransformer extends AbstractTransformer
|
||||
]);
|
||||
}
|
||||
|
||||
private function mangaTransform($item, array $genres): MangaListItem
|
||||
private function mangaTransform(array $item, array $genres): MangaListItem
|
||||
{
|
||||
$mangaId = $item['media']['id'];
|
||||
$manga = $item['media'];
|
||||
|
@ -413,5 +413,6 @@ function renderTemplate(string $path, array $data): string
|
||||
ob_start();
|
||||
extract($data, EXTR_OVERWRITE);
|
||||
include $path;
|
||||
return ob_get_clean();
|
||||
$rawOutput = ob_get_clean();
|
||||
return (is_string($rawOutput)) ? $rawOutput : '';
|
||||
}
|
@ -52,13 +52,22 @@ abstract class BaseCommand extends Command {
|
||||
* @param string|int|null $bgColor
|
||||
* @return void
|
||||
*/
|
||||
public function echoBox($message, $fgColor = NULL, $bgColor = NULL): void
|
||||
public function echoBox(string|array $message, string|int|null $fgColor = NULL, string|int|null $bgColor = NULL): void
|
||||
{
|
||||
if (is_array($message))
|
||||
{
|
||||
$message = implode("\n", $message);
|
||||
}
|
||||
|
||||
if ($fgColor !== NULL)
|
||||
{
|
||||
$fgColor = (string)$fgColor;
|
||||
}
|
||||
if ($bgColor !== NULL)
|
||||
{
|
||||
$bgColor = (string)$bgColor;
|
||||
}
|
||||
|
||||
// color message
|
||||
$message = Colors::colorize($message, $fgColor, $bgColor);
|
||||
|
||||
@ -129,8 +138,17 @@ abstract class BaseCommand extends Command {
|
||||
return $this->_di($configArray, $APP_DIR);
|
||||
}
|
||||
|
||||
private function _line(string $message, $fgColor = NULL, $bgColor = NULL): void
|
||||
private function _line(string $message, int|string|null $fgColor = NULL, int|string|null $bgColor = NULL): void
|
||||
{
|
||||
if ($fgColor !== NULL)
|
||||
{
|
||||
$fgColor = (string)$fgColor;
|
||||
}
|
||||
if ($bgColor !== NULL)
|
||||
{
|
||||
$bgColor = (string)$bgColor;
|
||||
}
|
||||
|
||||
$message = Colors::colorize($message, $fgColor, $bgColor);
|
||||
$this->getConsole()->writeln($message);
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ final class SyncLists extends BaseCommand {
|
||||
* @param array $data
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected function update(string $type, array $data)
|
||||
protected function update(string $type, array $data): void
|
||||
{
|
||||
if ( ! empty($data['addToAnilist']))
|
||||
{
|
||||
@ -259,7 +259,7 @@ final class SyncLists extends BaseCommand {
|
||||
// ------------------------------------------------------------------------
|
||||
// Fetch helpers
|
||||
// ------------------------------------------------------------------------
|
||||
private function fetchAnilistCount(string $type)
|
||||
private function fetchAnilistCount(string $type): int
|
||||
{
|
||||
$list = $this->fetchAnilist($type);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user