Remove a lot of redundant PHPDoc properties
timw4mail/HummingBirdAnimeClient/pipeline/head There was a failure building this commit Details

This commit is contained in:
Timothy Warren 2022-03-03 13:25:10 -05:00
parent 84e7c45f10
commit 496ba418c9
103 changed files with 273 additions and 1088 deletions

View File

@ -70,9 +70,6 @@ abstract class APIRequestBuilder {
/** /**
* Do a basic minimal GET request * Do a basic minimal GET request
*
* @param string $uri
* @return Request
*/ */
public static function simpleRequest(string $uri): Request public static function simpleRequest(string $uri): Request
{ {
@ -89,7 +86,6 @@ abstract class APIRequestBuilder {
* *
* @param string $type The type of authorization, eg, basic, bearer, etc. * @param string $type The type of authorization, eg, basic, bearer, etc.
* @param string $value The authorization value * @param string $value The authorization value
* @return self
*/ */
public function setAuth(string $type, string $value): self public function setAuth(string $type, string $value): self
{ {
@ -101,10 +97,6 @@ abstract class APIRequestBuilder {
/** /**
* Set a basic authentication header * Set a basic authentication header
*
* @param string $username
* @param string $password
* @return self
*/ */
public function setBasicAuth(string $username, string $password): self public function setBasicAuth(string $username, string $password): self
{ {
@ -114,9 +106,6 @@ abstract class APIRequestBuilder {
/** /**
* Set the request body * Set the request body
*
* @param FormBody|string $body
* @return self
*/ */
public function setBody(FormBody|string $body): self public function setBody(FormBody|string $body): self
{ {
@ -128,7 +117,6 @@ abstract class APIRequestBuilder {
* Set body as form fields * Set body as form fields
* *
* @param array $fields Mapping of field names to values * @param array $fields Mapping of field names to values
* @return self
*/ */
public function setFormFields(array $fields): self public function setFormFields(array $fields): self
{ {
@ -140,9 +128,6 @@ abstract class APIRequestBuilder {
/** /**
* Unset a request header * Unset a request header
*
* @param string $name
* @return self
*/ */
public function unsetHeader(string $name): self public function unsetHeader(string $name): self
{ {
@ -153,9 +138,7 @@ abstract class APIRequestBuilder {
/** /**
* Set a request header * Set a request header
* *
* @param string $name
* @param string|null $value * @param string|null $value
* @return self
*/ */
public function setHeader(string $name, string $value = NULL): self public function setHeader(string $name, string $value = NULL): self
{ {
@ -177,7 +160,6 @@ abstract class APIRequestBuilder {
* name => value * name => value
* *
* @param array $headers * @param array $headers
* @return self
*/ */
public function setHeaders(array $headers): self public function setHeaders(array $headers): self
{ {
@ -191,24 +173,18 @@ abstract class APIRequestBuilder {
/** /**
* Set the request body * Set the request body
*
* @param mixed $body
* @return self
*/ */
public function setJsonBody(mixed $body): self public function setJsonBody(mixed $body): self
{ {
$requestBody = ( ! is_string($body)) $requestBody = ( is_string($body))
? Json::encode($body) ? $body
: $body; : Json::encode($body);
return $this->setBody($requestBody); return $this->setBody($requestBody);
} }
/** /**
* Append a query string in array format * Append a query string in array format
*
* @param array $params
* @return self
*/ */
public function setQuery(array $params): self public function setQuery(array $params): self
{ {
@ -219,7 +195,6 @@ abstract class APIRequestBuilder {
/** /**
* Return the promise for the current request * Return the promise for the current request
* *
* @return Request
* @throws \Throwable * @throws \Throwable
*/ */
public function getFullRequest(): Request public function getFullRequest(): Request
@ -245,7 +220,6 @@ abstract class APIRequestBuilder {
/** /**
* Get the data from the response of the passed request * Get the data from the response of the passed request
* *
* @param Request $request
* @return mixed * @return mixed
* @throws \Error * @throws \Error
* @throws \Throwable * @throws \Throwable
@ -260,10 +234,7 @@ abstract class APIRequestBuilder {
/** /**
* Create a new http request * Create a new http request
* *
* @param string $type
* @param string $uri
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return self
*/ */
public function newRequest(string $type, string $uri): self public function newRequest(string $type, string $uri): self
{ {
@ -292,8 +263,6 @@ abstract class APIRequestBuilder {
/** /**
* Create the full request url * Create the full request url
*
* @return Request
*/ */
private function buildUri(): Request private function buildUri(): Request
{ {
@ -313,10 +282,6 @@ abstract class APIRequestBuilder {
/** /**
* Reset the class state for a new request * Reset the class state for a new request
*
* @param string|null $url
* @param string $type
* @return void
*/ */
private function resetState(?string $url, string $type = 'GET'): void private function resetState(?string $url, string $type = 'GET'): void
{ {

View File

@ -28,15 +28,11 @@ abstract class AbstractListItem {
* Create a list item * Create a list item
* *
* @param array $data - * @param array $data -
* @return Request
*/ */
abstract public function create(array $data): Request; abstract public function create(array $data): Request;
/** /**
* Create a full list item for syncing * Create a full list item for syncing
*
* @param array $data
* @return Request
*/ */
abstract public function createFull(array $data): Request; abstract public function createFull(array $data): Request;
@ -44,16 +40,12 @@ abstract class AbstractListItem {
* Retrieve a list item * Retrieve a list item
* *
* @param string $id - The id of the list item * @param string $id - The id of the list item
* @return array * @return mixed[]
*/ */
abstract public function get(string $id): array; abstract public function get(string $id): array;
/** /**
* Increase progress on a list item * Increase progress on a list item
*
* @param string $id
* @param FormItemData $data
* @return Request
*/ */
abstract public function increment(string $id, FormItemData $data): Request; abstract public function increment(string $id, FormItemData $data): Request;
@ -62,7 +54,6 @@ abstract class AbstractListItem {
* *
* @param string $id - The id of the list item to update * @param string $id - The id of the list item to update
* @param FormItemData $data - The data with which to update the list item * @param FormItemData $data - The data with which to update the list item
* @return Request
*/ */
abstract public function update(string $id, FormItemData $data): Request; abstract public function update(string $id, FormItemData $data): Request;
@ -70,7 +61,6 @@ abstract class AbstractListItem {
* Delete a list item * Delete a list item
* *
* @param string $id - The id of the list item to delete * @param string $id - The id of the list item to delete
* @return Request|null
*/ */
abstract public function delete(string $id):?Request; abstract public function delete(string $id):?Request;
} }

View File

@ -31,9 +31,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Create a minimal list item * Create a minimal list item
*
* @param array $data
* @return Request
*/ */
public function create(array $data): Request public function create(array $data): Request
{ {
@ -43,9 +40,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Create a fleshed-out list item * Create a fleshed-out list item
*
* @param array $data
* @return Request
*/ */
public function createFull(array $data): Request public function createFull(array $data): Request
{ {
@ -55,10 +49,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Delete a list item * Delete a list item
*
* @param string $id
* @param string $type
* @return Request
*/ */
public function delete(string $id, string $type = 'anime'): Request public function delete(string $id, string $type = 'anime'): Request
{ {
@ -67,9 +57,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Get the data for a list item * Get the data for a list item
*
* @param string $id
* @return array
*/ */
public function get(string $id): array public function get(string $id): array
{ {
@ -78,10 +65,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Increase the progress on the medium by 1 * Increase the progress on the medium by 1
*
* @param string $id
* @param FormItemData $data
* @return Request
*/ */
public function increment(string $id, FormItemData $data): Request public function increment(string $id, FormItemData $data): Request
{ {
@ -95,10 +78,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Update a list item * Update a list item
*
* @param string $id
* @param FormItemData $data
* @return Request
*/ */
public function update(string $id, FormItemData $data): Request public function update(string $id, FormItemData $data): Request
{ {

View File

@ -36,32 +36,24 @@ use Throwable;
final class Model final class Model
{ {
use RequestBuilderTrait; use RequestBuilderTrait;
/**
* @var ListItem
*/
private ListItem $listItem;
/** /**
* Constructor * Constructor
*
* @param ListItem $listItem
*/ */
public function __construct(ListItem $listItem) public function __construct(private ListItem $listItem)
{ {
$this->listItem = $listItem;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ! Generic API calls // ! Generic API calls
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Attempt to get an auth token * Attempt to get an auth token
* *
* @param string $code - The request token * @param string $code - The request token
* @param string $redirectUri - The oauth callback url * @param string $redirectUri - The oauth callback url
* @return array
* @throws Throwable * @throws Throwable
* @return mixed[]
*/ */
public function authenticate(string $code, string $redirectUri): array public function authenticate(string $code, string $redirectUri): array
{ {
@ -84,8 +76,6 @@ final class Model
/** /**
* Check auth status with simple API call * Check auth status with simple API call
*
* @return array
*/ */
public function checkAuth(): array public function checkAuth(): array
{ {
@ -95,8 +85,6 @@ final class Model
/** /**
* Get user list data for syncing with Kitsu * Get user list data for syncing with Kitsu
* *
* @param string $type
* @return array
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -119,8 +107,6 @@ final class Model
/** /**
* Create a list item * Create a list item
* *
* @param array $data
* @param string $type
* @return Request * @return Request
*/ */
public function createListItem(array $data, string $type = 'anime'): ?Request public function createListItem(array $data, string $type = 'anime'): ?Request
@ -159,10 +145,6 @@ final class Model
/** /**
* Create a list item with all the relevant data * Create a list item with all the relevant data
*
* @param array $data
* @param string $type
* @return Request
*/ */
public function createFullListItem(array $data, string $type): Request public function createFullListItem(array $data, string $type): Request
{ {
@ -185,7 +167,7 @@ final class Model
* @param string $malId - The unique identifier of that list item * @param string $malId - The unique identifier of that list item
* @param string $type - Them media type (anime/manga) * @param string $type - Them media type (anime/manga)
* *
* @return array * @return mixed[]
*/ */
public function getListItem(string $malId, string $type): array public function getListItem(string $malId, string $type): array
{ {
@ -205,9 +187,7 @@ final class Model
/** /**
* Increase the watch count for the current list item * Increase the watch count for the current list item
* *
* @param FormItem $data
* @param string $type - Them media type (anime/manga) * @param string $type - Them media type (anime/manga)
* @return Request|null
*/ */
public function incrementListItem(FormItem $data, string $type): ?Request public function incrementListItem(FormItem $data, string $type): ?Request
{ {
@ -223,9 +203,7 @@ final class Model
/** /**
* Modify a list item * Modify a list item
* *
* @param FormItem $data
* @param string $type - Them media type (anime/manga) * @param string $type - Them media type (anime/manga)
* @return Request|null
*/ */
public function updateListItem(FormItem $data, string $type): ?Request public function updateListItem(FormItem $data, string $type): ?Request
{ {
@ -244,7 +222,6 @@ final class Model
* *
* @param string $malId - The id of the list item to remove * @param string $malId - The id of the list item to remove
* @param string $type - Them media type (anime/manga) * @param string $type - Them media type (anime/manga)
* @return Request|null
*/ */
public function deleteListItem(string $malId, string $type): ?Request public function deleteListItem(string $malId, string $type): ?Request
{ {
@ -260,9 +237,7 @@ final class Model
/** /**
* Get the id of the specific list entry from the malId * Get the id of the specific list entry from the malId
* *
* @param string $malId
* @param string $type - The media type (anime/manga) * @param string $type - The media type (anime/manga)
* @return string|null
*/ */
public function getListIdFromMalId(string $malId, string $type): ?string public function getListIdFromMalId(string $malId, string $type): ?string
{ {
@ -279,9 +254,6 @@ final class Model
* Get the Anilist list item id from the media id from its MAL id * Get the Anilist list item id from the media id from its MAL id
* this way is more accurate than getting the list item id * this way is more accurate than getting the list item id
* directly from the MAL id * directly from the MAL id
*
* @param string $mediaId
* @return string|null
*/ */
private function getListIdFromMediaId(string $mediaId): ?string private function getListIdFromMediaId(string $mediaId): ?string
{ {
@ -303,10 +275,6 @@ final class Model
/** /**
* Get the Anilist media id from the malId * Get the Anilist media id from the malId
*
* @param string $malId
* @param string $type
* @return string|null
*/ */
private function getMediaIdFromMalId(string $malId, string $type = 'ANIME'): ?string private function getMediaIdFromMalId(string $malId, string $type = 'ANIME'): ?string
{ {

View File

@ -38,20 +38,16 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* The base url for api requests * The base url for api requests
* @var string $base_url
*/ */
protected string $baseUrl = Anilist::BASE_URL; protected string $baseUrl = Anilist::BASE_URL;
/** /**
* Valid HTTP request methods * Valid HTTP request methods
* @var array
*/ */
protected array $validMethods = ['POST']; protected array $validMethods = ['POST'];
/** /**
* HTTP headers to send with every request * HTTP headers to send with every request
*
* @var array
*/ */
protected array $defaultHeaders = [ protected array $defaultHeaders = [
'Accept' => 'application/json', 'Accept' => 'application/json',
@ -67,9 +63,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Create a request object * Create a request object
* @param string $url
* @param array $options
* @return Request
* @throws Throwable * @throws Throwable
*/ */
public function setUpRequest(string $url, array $options = []): Request public function setUpRequest(string $url, array $options = []): Request
@ -111,10 +104,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Run a GraphQL API query * Run a GraphQL API query
*
* @param string $name
* @param array $variables
* @return array
*/ */
public function runQuery(string $name, array $variables = []): array public function runQuery(string $name, array $variables = []): array
{ {
@ -144,9 +133,6 @@ final class RequestBuilder extends APIRequestBuilder {
} }
/** /**
* @param string $name
* @param array $variables
* @return Request
* @throws Throwable * @throws Throwable
*/ */
public function mutateRequest (string $name, array $variables = []): Request public function mutateRequest (string $name, array $variables = []): Request
@ -177,10 +163,8 @@ final class RequestBuilder extends APIRequestBuilder {
} }
/** /**
* @param string $name
* @param array $variables
* @return array
* @throws Throwable * @throws Throwable
* @return mixed[]
*/ */
public function mutate (string $name, array $variables = []): array public function mutate (string $name, array $variables = []): array
{ {
@ -193,9 +177,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Make a request * Make a request
* *
* @param string $url
* @param array $options
* @return Response
* @throws Throwable * @throws Throwable
*/ */
private function getResponse(string $url, array $options = []): Response private function getResponse(string $url, array $options = []): Response
@ -220,8 +201,6 @@ final class RequestBuilder extends APIRequestBuilder {
} }
/** /**
* @param Request $request
* @return Response
* @throws Throwable * @throws Throwable
*/ */
public function getResponseFromRequest(Request $request): Response public function getResponseFromRequest(Request $request): Response
@ -247,8 +226,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Remove some boilerplate for post requests * Remove some boilerplate for post requests
* *
* @param array $options
* @return array
* @throws Throwable * @throws Throwable
*/ */
protected function postRequest(array $options = []): array protected function postRequest(array $options = []): array

View File

@ -28,9 +28,6 @@ trait RequestBuilderTrait {
/** /**
* Set the request builder object * Set the request builder object
*
* @param RequestBuilder $requestBuilder
* @return self
*/ */
public function setRequestBuilder(RequestBuilder $requestBuilder): self public function setRequestBuilder(RequestBuilder $requestBuilder): self
{ {

View File

@ -36,7 +36,6 @@ class AnimeListTransformer extends AbstractTransformer {
/** /**
* Transform Anilist list item to Kitsu form update format * Transform Anilist list item to Kitsu form update format
* *
* @param array $item
* @return FormItem * @return FormItem
*/ */
public function untransform(array $item): FormItem public function untransform(array $item): FormItem

View File

@ -36,9 +36,6 @@ class MangaListTransformer extends AbstractTransformer {
/** /**
* Transform Anilist list item to Kitsu form update format * Transform Anilist list item to Kitsu form update format
*
* @param array $item
* @return FormItem
*/ */
public function untransform(array $item): FormItem public function untransform(array $item): FormItem
{ {

View File

@ -22,15 +22,15 @@ class MediaListEntry extends AbstractType {
public int|string $id; public int|string $id;
public ?string $notes; public ?string $notes = null;
public ?bool $private; public ?bool $private = null;
public int $progress; public int $progress;
public ?int $repeat; public ?int $repeat = null;
public string $status; public string $status;
public ?int $score; public ?int $score = null;
} }

View File

@ -23,16 +23,10 @@ use Psr\SimpleCache\CacheInterface;
*/ */
trait CacheTrait { trait CacheTrait {
/**
* @var CacheInterface
*/
protected CacheInterface $cache; protected CacheInterface $cache;
/** /**
* Inject the cache object * Inject the cache object
*
* @param CacheInterface $cache
* @return self
*/ */
public function setCache(CacheInterface $cache): self public function setCache(CacheInterface $cache): self
{ {
@ -42,8 +36,6 @@ trait CacheTrait {
/** /**
* Get the cache object if it exists * Get the cache object if it exists
*
* @return CacheInterface
*/ */
public function getCache(): CacheInterface public function getCache(): CacheInterface
{ {
@ -53,11 +45,6 @@ trait CacheTrait {
/** /**
* Get the cached value if it exists, otherwise set the cache value * Get the cached value if it exists, otherwise set the cache value
* and return it. * and return it.
*
* @param string $key
* @param callable $primer
* @param array|null $primeArgs
* @return mixed
*/ */
public function getCached(string $key, callable $primer, ?array $primeArgs = []): mixed public function getCached(string $key, callable $primer, ?array $primeArgs = []): mixed
{ {

View File

@ -34,15 +34,11 @@ final class Auth {
/** /**
* Anime API Model * Anime API Model
*
* @var Model
*/ */
private Model $model; private Model $model;
/** /**
* Session object * Session object
*
* @var Segment
*/ */
private Segment $segment; private Segment $segment;
@ -65,9 +61,6 @@ final class Auth {
/** /**
* Make the appropriate authentication call, * Make the appropriate authentication call,
* and save the resulting auth token if successful * and save the resulting auth token if successful
*
* @param string $password
* @return boolean
*/ */
public function authenticate(string $password): bool public function authenticate(string $password): bool
{ {
@ -81,9 +74,6 @@ final class Auth {
/** /**
* Make the call to re-authenticate with the existing refresh token * Make the call to re-authenticate with the existing refresh token
*
* @param string|null $refreshToken
* @return boolean
*/ */
public function reAuthenticate(?string $refreshToken = NULL): bool public function reAuthenticate(?string $refreshToken = NULL): bool
{ {
@ -101,8 +91,6 @@ final class Auth {
/** /**
* Check whether the current user is authenticated * Check whether the current user is authenticated
*
* @return boolean
*/ */
public function isAuthenticated(): bool public function isAuthenticated(): bool
{ {
@ -111,8 +99,6 @@ final class Auth {
/** /**
* Clear authentication values * Clear authentication values
*
* @return void
*/ */
public function logout(): void public function logout(): void
{ {
@ -121,8 +107,6 @@ final class Auth {
/** /**
* Retrieve the authentication token from the session * Retrieve the authentication token from the session
*
* @return string|null
*/ */
public function getAuthToken(): ?string public function getAuthToken(): ?string
{ {
@ -137,8 +121,6 @@ final class Auth {
/** /**
* Retrieve the refresh token * Retrieve the refresh token
*
* @return string|null
*/ */
private function getRefreshToken(): ?string private function getRefreshToken(): ?string
{ {
@ -153,9 +135,6 @@ final class Auth {
/** /**
* Save the new authentication information * Save the new authentication information
*
* @param array|false $auth
* @return bool
*/ */
private function storeAuth(array|false $auth): bool private function storeAuth(array|false $auth): bool
{ {
@ -185,4 +164,5 @@ final class Auth {
return FALSE; return FALSE;
} }
} }
// End of KitsuAuth.php // End of KitsuAuth.php

View File

@ -31,8 +31,6 @@ final class ListItem extends AbstractListItem {
use RequestBuilderTrait; use RequestBuilderTrait;
/** /**
* @param array $data
* @return Request
* @throws Throwable * @throws Throwable
*/ */
public function create(array $data): Request public function create(array $data): Request
@ -90,8 +88,6 @@ final class ListItem extends AbstractListItem {
} }
/** /**
* @param string $id
* @return Request
* @throws Throwable * @throws Throwable
*/ */
public function delete(string $id): Request public function delete(string $id): Request
@ -102,9 +98,8 @@ final class ListItem extends AbstractListItem {
} }
/** /**
* @param string $id
* @return array
* @throws Throwable * @throws Throwable
* @return mixed[]
*/ */
public function get(string $id): array public function get(string $id): array
{ {
@ -115,10 +110,6 @@ final class ListItem extends AbstractListItem {
/** /**
* Increase the progress on the medium by 1 * Increase the progress on the medium by 1
*
* @param string $id
* @param FormItemData $data
* @return Request
*/ */
public function increment(string $id, FormItemData $data): Request public function increment(string $id, FormItemData $data): Request
{ {
@ -129,9 +120,6 @@ final class ListItem extends AbstractListItem {
} }
/** /**
* @param string $id
* @param FormItemData $data
* @return Request
* @throws Throwable * @throws Throwable
*/ */
public function update(string $id, FormItemData $data): Request public function update(string $id, FormItemData $data): Request
@ -151,6 +139,7 @@ final class ListItem extends AbstractListItem {
{ {
$updateData['progress'] = (int)$data['progress']; $updateData['progress'] = (int)$data['progress'];
} }
if ($data['ratingTwenty'] !== NULL) if ($data['ratingTwenty'] !== NULL)
{ {
$updateData['ratingTwenty'] = (int)$data['ratingTwenty']; $updateData['ratingTwenty'] = (int)$data['ratingTwenty'];

View File

@ -67,30 +67,17 @@ final class Model {
*/ */
protected MangaTransformer $mangaTransformer; protected MangaTransformer $mangaTransformer;
/**
* @var ListItem
*/
protected ListItem $listItem;
/** /**
* Constructor * Constructor
*
* @param ListItem $listItem
*/ */
public function __construct(ListItem $listItem) public function __construct(protected ListItem $listItem)
{ {
$this->animeTransformer = new AnimeTransformer(); $this->animeTransformer = new AnimeTransformer();
$this->mangaTransformer = new MangaTransformer(); $this->mangaTransformer = new MangaTransformer();
$this->listItem = $listItem;
} }
/** /**
* Get the access token from the Kitsu API * Get the access token from the Kitsu API
*
* @param string $username
* @param string $password
* @return array|false
*/ */
public function authenticate(string $username, string $password): array|false public function authenticate(string $username, string $password): array|false
{ {
@ -113,7 +100,7 @@ final class Model {
if (array_key_exists('error', $data)) if (array_key_exists('error', $data))
{ {
dump([ dump([
'method' => __CLASS__ . '\\' . __METHOD__, 'method' => self::class . '\\' . __METHOD__,
'error' => $data['error'], 'error' => $data['error'],
'response' => $response, 'response' => $response,
]); ]);
@ -130,9 +117,6 @@ final class Model {
/** /**
* Extend the current session with a refresh token * Extend the current session with a refresh token
*
* @param string $token
* @return array|false
*/ */
public function reAuthenticate(string $token): array|false public function reAuthenticate(string $token): array|false
{ {
@ -152,7 +136,7 @@ final class Model {
if (array_key_exists('error', $data)) if (array_key_exists('error', $data))
{ {
dump([ dump([
'method' => __CLASS__ . '\\' . __METHOD__, 'method' => self::class . '\\' . __METHOD__,
'error' => $data['error'], 'error' => $data['error'],
'response' => $response, 'response' => $response,
]); ]);
@ -171,7 +155,6 @@ final class Model {
* Get the userid for a username from Kitsu * Get the userid for a username from Kitsu
* *
* @param string|null $username * @param string|null $username
* @return string
*/ */
public function getUserIdByUsername(string $username = NULL): string public function getUserIdByUsername(string $username = NULL): string
{ {
@ -192,8 +175,7 @@ final class Model {
/** /**
* Get information about a character * Get information about a character
* *
* @param string $slug * @return mixed[]
* @return array
*/ */
public function getCharacter(string $slug): array public function getCharacter(string $slug): array
{ {
@ -205,8 +187,7 @@ final class Model {
/** /**
* Get information about a person * Get information about a person
* *
* @param string $slug * @return mixed[]
* @return array
*/ */
public function getPerson(string $slug): array public function getPerson(string $slug): array
{ {
@ -218,8 +199,7 @@ final class Model {
/** /**
* Get profile information for the configured user * Get profile information for the configured user
* *
* @param string $username * @return mixed[]
* @return array
*/ */
public function getUserData(string $username): array public function getUserData(string $username): array
{ {
@ -231,12 +211,8 @@ final class Model {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ! Anime-specific methods // ! Anime-specific methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Get information about a particular anime * Get information about a particular anime
*
* @param string $slug
* @return Anime
*/ */
public function getAnime(string $slug): Anime public function getAnime(string $slug): Anime
{ {
@ -269,9 +245,6 @@ final class Model {
/** /**
* Get information about a particular anime * Get information about a particular anime
*
* @param string $animeId
* @return Anime
*/ */
public function getAnimeById(string $animeId): Anime public function getAnimeById(string $animeId): Anime
{ {
@ -284,7 +257,7 @@ final class Model {
/** /**
* Retrieve the data for the anime watch history page * Retrieve the data for the anime watch history page
* *
* @return array * @return mixed[]
*/ */
public function getAnimeHistory(): array public function getAnimeHistory(): array
{ {
@ -308,7 +281,7 @@ final class Model {
* Get the anime list for the configured user * Get the anime list for the configured user
* *
* @param string $status - The watching status to filter the list with * @param string $status - The watching status to filter the list with
* @return array * @return mixed[]
*/ */
public function getAnimeList(string $status): array public function getAnimeList(string $status): array
{ {
@ -346,7 +319,6 @@ final class Model {
* Get the number of anime list items * Get the number of anime list items
* *
* @param string $status - Optional status to filter by * @param string $status - Optional status to filter by
* @return int
*/ */
public function getAnimeListCount(string $status = '') : int public function getAnimeListCount(string $status = '') : int
{ {
@ -356,7 +328,7 @@ final class Model {
/** /**
* Get all the anime entries, that are organized for output to html * Get all the anime entries, that are organized for output to html
* *
* @return array * @return array<string, mixed[]>
*/ */
public function getFullOrganizedAnimeList(): array public function getFullOrganizedAnimeList(): array
{ {
@ -364,7 +336,7 @@ final class Model {
$statuses = KitsuWatchingStatus::getConstList(); $statuses = KitsuWatchingStatus::getConstList();
foreach ($statuses as $key => $status) foreach ($statuses as $status)
{ {
$mappedStatus = AnimeWatchingStatus::KITSU_TO_TITLE[$status]; $mappedStatus = AnimeWatchingStatus::KITSU_TO_TITLE[$status];
$output[$mappedStatus] = $this->getAnimeList($status) ?? []; $output[$mappedStatus] = $this->getAnimeList($status) ?? [];
@ -376,12 +348,8 @@ final class Model {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ! Manga-specific methods // ! Manga-specific methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Get information about a particular manga * Get information about a particular manga
*
* @param string $slug
* @return MangaPage
*/ */
public function getManga(string $slug): MangaPage public function getManga(string $slug): MangaPage
{ {
@ -408,9 +376,6 @@ final class Model {
/** /**
* Get information about a particular manga * Get information about a particular manga
*
* @param string $mangaId
* @return MangaPage
*/ */
public function getMangaById(string $mangaId): MangaPage public function getMangaById(string $mangaId): MangaPage
{ {
@ -423,7 +388,7 @@ final class Model {
/** /**
* Retrieve the data for the manga read history page * Retrieve the data for the manga read history page
* *
* @return array * @return mixed[]
*/ */
public function getMangaHistory(): array public function getMangaHistory(): array
{ {
@ -445,7 +410,7 @@ final class Model {
* Get the manga list for the configured user * Get the manga list for the configured user
* *
* @param string $status - The reading status by which to filter the list * @param string $status - The reading status by which to filter the list
* @return array * @return mixed[]
*/ */
public function getMangaList(string $status): array public function getMangaList(string $status): array
{ {
@ -483,7 +448,6 @@ final class Model {
* Get the number of manga list items * Get the number of manga list items
* *
* @param string $status - Optional status to filter by * @param string $status - Optional status to filter by
* @return int
*/ */
public function getMangaListCount(string $status = '') : int public function getMangaListCount(string $status = '') : int
{ {
@ -493,7 +457,7 @@ final class Model {
/** /**
* Get all Manga lists * Get all Manga lists
* *
* @return array * @return array<string, mixed[]>
*/ */
public function getFullOrganizedMangaList(): array public function getFullOrganizedMangaList(): array
{ {
@ -511,13 +475,12 @@ final class Model {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Base methods // Base methods
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** /**
* Search for an anime or manga * Search for an anime or manga
* *
* @param string $type - 'anime' or 'manga' * @param string $type - 'anime' or 'manga'
* @param string $query - name of the item to search for * @param string $query - name of the item to search for
* @return array * @return array<int, array<string, mixed>>
*/ */
public function search(string $type, string $query): array public function search(string $type, string $query): array
{ {
@ -563,9 +526,7 @@ final class Model {
/** /**
* Find a media item on Kitsu by its associated MAL id * Find a media item on Kitsu by its associated MAL id
* *
* @param string $malId
* @param string $type "anime" or "manga" * @param string $type "anime" or "manga"
* @return string|NULL
*/ */
public function getKitsuIdFromMALId(string $malId, string $type='anime'): ?string public function getKitsuIdFromMALId(string $malId, string $type='anime'): ?string
{ {
@ -594,6 +555,9 @@ final class Model {
return (new LibraryEntryTransformer())->transform($baseData['data']['findLibraryEntryById']); return (new LibraryEntryTransformer())->transform($baseData['data']['findLibraryEntryById']);
} }
/**
* @return mixed[]
*/
public function getThumbList(string $type): array public function getThumbList(string $type): array
{ {
$statuses = [ $statuses = [
@ -624,7 +588,7 @@ final class Model {
* Get the data to sync Kitsu anime/manga list with another API * Get the data to sync Kitsu anime/manga list with another API
* *
* @param string $type * @param string $type
* @return array * @return mixed[]
*/ */
public function getSyncList(string $type): array public function getSyncList(string $type): array
{ {
@ -654,7 +618,7 @@ final class Model {
/** /**
* Get the aggregated pages of anime or manga history * Get the aggregated pages of anime or manga history
* *
* @return array * @return mixed[]
*/ */
protected function getHistoryList(): array protected function getHistoryList(): array
{ {
@ -666,9 +630,7 @@ final class Model {
/** /**
* Get the raw anime/manga list from GraphQL * Get the raw anime/manga list from GraphQL
* *
* @param string $type * @return mixed[]
* @param string $status
* @return array
*/ */
protected function getList(string $type, string $status = ''): array protected function getList(string $type, string $status = ''): array
{ {
@ -687,7 +649,7 @@ final class Model {
$cursor = ''; $cursor = '';
$username = $this->getUsername(); $username = $this->getUsername();
return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username) { return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username): \Generator {
while (TRUE) while (TRUE)
{ {
$vars = [ $vars = [
@ -698,6 +660,7 @@ final class Model {
{ {
$vars['status'] = $status; $vars['status'] = $status;
} }
if ($cursor !== '') if ($cursor !== '')
{ {
$vars['after'] = $cursor; $vars['after'] = $cursor;
@ -738,7 +701,7 @@ final class Model {
$cursor = ''; $cursor = '';
$username = $this->getUsername(); $username = $this->getUsername();
return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username) { return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username): \Generator {
while (TRUE) while (TRUE)
{ {
$vars = [ $vars = [
@ -781,7 +744,7 @@ final class Model {
$cursor = ''; $cursor = '';
$username = $this->getUsername(); $username = $this->getUsername();
return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username) { return new Amp\Producer(function (callable $emit) use ($type, $status, $cursor, $username): \Generator {
while (TRUE) while (TRUE)
{ {
$vars = [ $vars = [
@ -843,8 +806,6 @@ final class Model {
/** /**
* Get the kitsu username from config * Get the kitsu username from config
*
* @return string
*/ */
private function getUsername(): string private function getUsername(): string
{ {

View File

@ -26,12 +26,8 @@ trait MutationTrait {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ! Generic API calls // ! Generic API calls
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Create a list item * Create a list item
*
* @param array $data
* @return Request|null
*/ */
public function createListItem(array $data): ?Request public function createListItem(array $data): ?Request
{ {
@ -46,9 +42,6 @@ trait MutationTrait {
/** /**
* Increase the progress count for a list item * Increase the progress count for a list item
*
* @param FormItem $data
* @return Request
*/ */
public function incrementListItem(FormItem $data): Request public function incrementListItem(FormItem $data): Request
{ {
@ -57,9 +50,6 @@ trait MutationTrait {
/** /**
* Modify a list item * Modify a list item
*
* @param FormItem $data
* @return Request
*/ */
public function updateListItem(FormItem $data): Request public function updateListItem(FormItem $data): Request
{ {
@ -70,7 +60,6 @@ trait MutationTrait {
* Remove a list item * Remove a list item
* *
* @param string $id - The id of the list item to remove * @param string $id - The id of the list item to remove
* @return Request
*/ */
public function deleteListItem(string $id): Request public function deleteListItem(string $id): Request
{ {

View File

@ -40,20 +40,16 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* The base url for api requests * The base url for api requests
* @var string $base_url
*/ */
protected string $baseUrl = K::GRAPHQL_ENDPOINT; protected string $baseUrl = K::GRAPHQL_ENDPOINT;
/** /**
* Where to look for GraphQL request files * Where to look for GraphQL request files
* @var string
*/ */
protected string $filePath = __DIR__; protected string $filePath = __DIR__;
/** /**
* HTTP headers to send with every request * HTTP headers to send with every request
*
* @var array
*/ */
protected array $defaultHeaders = [ protected array $defaultHeaders = [
'User-Agent' => USER_AGENT, 'User-Agent' => USER_AGENT,
@ -70,11 +66,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Create a request object * Create a request object
*
* @param string $type
* @param string $url
* @param array $options
* @return Request
*/ */
public function setUpRequest(string $type, string $url, array $options = []): Request public function setUpRequest(string $type, string $url, array $options = []): Request
{ {
@ -131,9 +122,7 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Run a GraphQL API query * Run a GraphQL API query
* *
* @param string $name * @return mixed[]
* @param array $variables
* @return array
*/ */
public function runQuery(string $name, array $variables = []): array public function runQuery(string $name, array $variables = []): array
{ {
@ -156,9 +145,7 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Run a GraphQL mutation * Run a GraphQL mutation
* *
* @param string $name * @return mixed[]
* @param array $variables
* @return array
*/ */
public function mutate(string $name, array $variables = []): array public function mutate(string $name, array $variables = []): array
{ {
@ -180,11 +167,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Make a request * Make a request
*
* @param string $type
* @param string $url
* @param array $options
* @return Response
*/ */
public function getResponse(string $type, string $url, array $options = []): Response public function getResponse(string $type, string $url, array $options = []): Response
{ {
@ -205,10 +187,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Create a GraphQL query and return the Request object * Create a GraphQL query and return the Request object
*
* @param string $name
* @param array $variables
* @return Request
*/ */
public function queryRequest(string $name, array $variables = []): Request public function queryRequest(string $name, array $variables = []): Request
{ {
@ -239,10 +217,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Create a GraphQL mutation request, and return the Request object * Create a GraphQL mutation request, and return the Request object
*
* @param string $name
* @param array $variables
* @return Request
*/ */
public function mutateRequest (string $name, array $variables = []): Request public function mutateRequest (string $name, array $variables = []): Request
{ {
@ -272,11 +246,6 @@ final class RequestBuilder extends APIRequestBuilder {
/** /**
* Make a request * Make a request
*
* @param string $type
* @param string $url
* @param array $options
* @return array
*/ */
private function request(string $type, string $url, array $options = []): array private function request(string $type, string $url, array $options = []): array
{ {
@ -305,7 +274,7 @@ final class RequestBuilder extends APIRequestBuilder {
{ {
return Json::decode($rawBody); return Json::decode($rawBody);
} }
catch (JsonException $e) catch (JsonException)
{ {
// dump($e); // dump($e);
dump($rawBody); dump($rawBody);

View File

@ -19,14 +19,12 @@ namespace Aviat\AnimeClient\API\Kitsu;
trait RequestBuilderTrait { trait RequestBuilderTrait {
/** /**
* The request builder for the Kitsu API * The request builder for the Kitsu API
* @var RequestBuilder
*/ */
protected RequestBuilder $requestBuilder; protected RequestBuilder $requestBuilder;
/** /**
* Set the request builder object * Set the request builder object
* *
* @param RequestBuilder $requestBuilder
* @return RequestBuilderTrait|ListItem|Model * @return RequestBuilderTrait|ListItem|Model
*/ */
public function setRequestBuilder(RequestBuilder $requestBuilder): self public function setRequestBuilder(RequestBuilder $requestBuilder): self

View File

@ -146,4 +146,5 @@ final class AnimeListTransformer extends AbstractTransformer {
return $untransformed; return $untransformed;
} }
} }
// End of AnimeListTransformer.php // End of AnimeListTransformer.php

View File

@ -30,7 +30,6 @@ final class AnimeTransformer extends AbstractTransformer {
* logical and workable structure * logical and workable structure
* *
* @param array|object $item API library item * @param array|object $item API library item
* @return AnimePage
*/ */
public function transform(array|object $item): AnimePage public function transform(array|object $item): AnimePage
{ {
@ -47,7 +46,7 @@ final class AnimeTransformer extends AbstractTransformer {
$titles = Kitsu::getTitles($base['titles']); $titles = Kitsu::getTitles($base['titles']);
$titles_more = Kitsu::filterLocalizedTitles($base['titles']); $titles_more = Kitsu::filterLocalizedTitles($base['titles']);
if (count($base['characters']['nodes']) > 0) if ((is_countable($base['characters']['nodes']) ? count($base['characters']['nodes']) : 0) > 0)
{ {
foreach ($base['characters']['nodes'] as $rawCharacter) foreach ($base['characters']['nodes'] as $rawCharacter)
{ {
@ -80,7 +79,7 @@ final class AnimeTransformer extends AbstractTransformer {
krsort($characters); krsort($characters);
} }
if (count($base['staff']['nodes']) > 0) if ((is_countable($base['staff']['nodes']) ? count($base['staff']['nodes']) : 0) > 0)
{ {
foreach ($base['staff']['nodes'] as $staffing) foreach ($base['staff']['nodes'] as $staffing)
{ {
@ -113,7 +112,7 @@ final class AnimeTransformer extends AbstractTransformer {
ksort($staff); ksort($staff);
} }
if (count($base['mappings']['nodes']) > 0) if ((is_countable($base['mappings']['nodes']) ? count($base['mappings']['nodes']) : 0) > 0)
{ {
$links = Kitsu::mappingsToUrls($base['mappings']['nodes'], "https://kitsu.io/anime/{$base['slug']}"); $links = Kitsu::mappingsToUrls($base['mappings']['nodes'], "https://kitsu.io/anime/{$base['slug']}");
} }

View File

@ -27,10 +27,6 @@ use Locale;
*/ */
final class CharacterTransformer extends AbstractTransformer { final class CharacterTransformer extends AbstractTransformer {
/**
* @param array|object $item
* @return Character
*/
public function transform(array|object $item): Character public function transform(array|object $item): Character
{ {
$item = (array)$item; $item = (array)$item;
@ -42,10 +38,7 @@ final class CharacterTransformer extends AbstractTransformer {
]; ];
$names = array_unique( $names = array_unique(
array_merge( [...[$data['names']['canonical']], ...array_values($data['names']['localized'])]
[$data['names']['canonical']],
array_values($data['names']['localized'])
)
); );
$name = array_shift($names); $name = array_shift($names);
@ -66,6 +59,9 @@ final class CharacterTransformer extends AbstractTransformer {
]); ]);
} }
/**
* @return array<int, mixed[]>
*/
protected function organizeMediaAndVoices (array $data): array protected function organizeMediaAndVoices (array $data): array
{ {
if (empty($data)) if (empty($data))
@ -106,7 +102,7 @@ final class CharacterTransformer extends AbstractTransformer {
]; ];
// And now, reorganize voice actor relationships // And now, reorganize voice actor relationships
$rawVoices = array_filter($data, fn($item) => (! empty($item['voices'])) && count((array)$item['voices']['nodes']) > 0); $rawVoices = array_filter($data, fn($item) => (! empty($item['voices'])) && (array)$item['voices']['nodes'] !== []);
if (empty($rawVoices)) if (empty($rawVoices))
{ {

View File

@ -51,13 +51,10 @@ abstract class HistoryTransformer {
/** /**
* @var array The mapping of api status to display status * @var array The mapping of api status to display status
*/ */
protected array $statusMap; protected array $statusMap = [];
/** /**
* Convert raw history * Convert raw history
*
* @param array $data
* @return array
*/ */
public function transform(array $data): array public function transform(array $data): array
{ {
@ -99,9 +96,6 @@ abstract class HistoryTransformer {
/** /**
* Combine consecutive 'progressed' events * Combine consecutive 'progressed' events
*
* @param array $singles
* @return array
*/ */
protected function aggregate (array $singles): array protected function aggregate (array $singles): array
{ {
@ -143,6 +137,7 @@ abstract class HistoryTransformer {
$items[] = array_pop($progressItem); $items[] = array_pop($progressItem);
$updated[] = $e['updated']; $updated[] = $e['updated'];
} }
$firstItem = min($items); $firstItem = min($items);
$lastItem = max($items); $lastItem = max($items);
$firstUpdate = min($updated); $firstUpdate = min($updated);

View File

@ -140,4 +140,5 @@ final class MangaListTransformer extends AbstractTransformer {
return $map; return $map;
} }
} }
// End of MangaListTransformer.php // End of MangaListTransformer.php

View File

@ -30,7 +30,6 @@ final class MangaTransformer extends AbstractTransformer {
* logical and workable structure * logical and workable structure
* *
* @param array|object $item API library item * @param array|object $item API library item
* @return MangaPage
*/ */
public function transform(array|object $item): MangaPage public function transform(array|object $item): MangaPage
{ {
@ -46,7 +45,7 @@ final class MangaTransformer extends AbstractTransformer {
$titles = Kitsu::getTitles($base['titles']); $titles = Kitsu::getTitles($base['titles']);
$titles_more = Kitsu::filterLocalizedTitles($base['titles']); $titles_more = Kitsu::filterLocalizedTitles($base['titles']);
if (count($base['characters']['nodes']) > 0) if ((is_countable($base['characters']['nodes']) ? count($base['characters']['nodes']) : 0) > 0)
{ {
foreach ($base['characters']['nodes'] as $rawCharacter) foreach ($base['characters']['nodes'] as $rawCharacter)
{ {
@ -79,7 +78,7 @@ final class MangaTransformer extends AbstractTransformer {
krsort($characters); krsort($characters);
} }
if (count($base['staff']['nodes']) > 0) if ((is_countable($base['staff']['nodes']) ? count($base['staff']['nodes']) : 0) > 0)
{ {
foreach ($base['staff']['nodes'] as $staffing) foreach ($base['staff']['nodes'] as $staffing)
{ {
@ -112,7 +111,7 @@ final class MangaTransformer extends AbstractTransformer {
ksort($staff); ksort($staff);
} }
if (count($base['mappings']['nodes']) > 0) if ((is_countable($base['mappings']['nodes']) ? count($base['mappings']['nodes']) : 0) > 0)
{ {
$links = Kitsu::mappingsToUrls($base['mappings']['nodes'], "https://kitsu.io/manga/{$base['slug']}"); $links = Kitsu::mappingsToUrls($base['mappings']['nodes'], "https://kitsu.io/manga/{$base['slug']}");
} }

View File

@ -25,10 +25,6 @@ use Aviat\Ion\Transformer\AbstractTransformer;
*/ */
final class PersonTransformer extends AbstractTransformer { final class PersonTransformer extends AbstractTransformer {
/**
* @param array|object $item
* @return Person
*/
public function transform(array|object $item): Person public function transform(array|object $item): Person
{ {
$item = (array)$item; $item = (array)$item;
@ -49,6 +45,9 @@ final class PersonTransformer extends AbstractTransformer {
]); ]);
} }
/**
* @return array<string, array<int|string, array<int|string, array<int|string, array<int|string, mixed>>>>>
*/
protected function organizeData(array $data): array protected function organizeData(array $data): array
{ {
$output = [ $output = [
@ -59,13 +58,14 @@ final class PersonTransformer extends AbstractTransformer {
$characters = []; $characters = [];
$staff = []; $staff = [];
if (count($data['mediaStaff']['nodes']) > 0) if ((is_countable($data['mediaStaff']['nodes']) ? count($data['mediaStaff']['nodes']) : 0) > 0)
{ {
$roles = array_unique(array_column($data['mediaStaff']['nodes'], 'role')); $roles = array_unique(array_column($data['mediaStaff']['nodes'], 'role'));
foreach ($roles as $role) foreach ($roles as $role)
{ {
$staff[$role] = []; $staff[$role] = [];
} }
ksort($staff); ksort($staff);
foreach ($data['mediaStaff']['nodes'] as $staffing) foreach ($data['mediaStaff']['nodes'] as $staffing)
@ -94,7 +94,7 @@ final class PersonTransformer extends AbstractTransformer {
$output['staff'] = $staff; $output['staff'] = $staff;
} }
if (count($data['voices']['nodes']) > 0) if ((is_countable($data['voices']['nodes']) ? count($data['voices']['nodes']) : 0) > 0)
{ {
foreach ($data['voices']['nodes'] as $voicing) foreach ($data['voices']['nodes'] as $voicing)
{ {

View File

@ -56,8 +56,7 @@ final class UserTransformer extends AbstractTransformer {
/** /**
* Reorganize favorites data to be more useful * Reorganize favorites data to be more useful
* *
* @param array $rawFavorites * @return array<string, array<int|string, mixed>>
* @return array
*/ */
private function organizeFavorites(array $rawFavorites): array private function organizeFavorites(array $rawFavorites): array
{ {
@ -72,6 +71,9 @@ final class UserTransformer extends AbstractTransformer {
return $output; return $output;
} }
/**
* @return array<string, string>
*/
private function organizeStats(array $stats, array $data = []): array private function organizeStats(array $stats, array $data = []): array
{ {
$animeStats = []; $animeStats = [];

View File

@ -30,17 +30,11 @@ final class ParallelAPIRequest {
/** /**
* Set of requests to make in parallel * Set of requests to make in parallel
*
* @var array
*/ */
private array $requests = []; private array $requests = [];
/** /**
* Add a request * Add a request
*
* @param string|Request $request
* @param string|int|null $key
* @return self
*/ */
public function addRequest(string|Request $request, string|int|null $key = NULL): self public function addRequest(string|Request $request, string|int|null $key = NULL): self
{ {
@ -58,7 +52,6 @@ final class ParallelAPIRequest {
* Add multiple requests * Add multiple requests
* *
* @param string[]|Request[] $requests * @param string[]|Request[] $requests
* @return self
*/ */
public function addRequests(array $requests): self public function addRequests(array $requests): self
{ {
@ -69,8 +62,8 @@ final class ParallelAPIRequest {
/** /**
* Make the requests, and return the body for each * Make the requests, and return the body for each
* *
* @return array
* @throws Throwable * @throws Throwable
* @return mixed[]
*/ */
public function makeRequests(): array public function makeRequests(): array
{ {
@ -80,7 +73,7 @@ final class ParallelAPIRequest {
foreach ($this->requests as $key => $url) foreach ($this->requests as $key => $url)
{ {
$promises[$key] = call(static function () use ($client, $url) { $promises[$key] = call(static function () use ($client, $url): \Generator {
$response = yield $client->request($url); $response = yield $client->request($url);
return yield $response->getBody()->buffer(); return yield $response->getBody()->buffer();
}); });
@ -92,8 +85,8 @@ final class ParallelAPIRequest {
/** /**
* Make the requests and return the response objects * Make the requests and return the response objects
* *
* @return array
* @throws Throwable * @throws Throwable
* @return mixed[]
*/ */
public function getResponses(): array public function getResponses(): array
{ {

View File

@ -34,13 +34,11 @@ use function Aviat\Ion\_dir;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
//! TOML Functions //! TOML Functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** /**
* Load configuration options from .toml files * Load configuration options from .toml files
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $path - Path to load config * @param string $path - Path to load config
* @return array
*/ */
function loadConfig(string $path): array function loadConfig(string $path): array
{ {
@ -82,8 +80,6 @@ function loadConfig(string $path): array
* Load config from one specific TOML file * Load config from one specific TOML file
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $filename
* @return array
*/ */
function loadTomlFile(string $filename): array function loadTomlFile(string $filename): array
{ {
@ -122,9 +118,6 @@ function _iterateToml(TomlBuilder $builder, iterable $data, mixed $parentKey = N
/** /**
* Serialize config data into a Toml file * Serialize config data into a Toml file
*
* @param iterable $data
* @return string
*/ */
function arrayToToml(iterable $data): string function arrayToToml(iterable $data): string
{ {
@ -137,9 +130,6 @@ function arrayToToml(iterable $data): string
/** /**
* Serialize toml back to an array * Serialize toml back to an array
*
* @param string $toml
* @return array
*/ */
function tomlToArray(string $toml): array function tomlToArray(string $toml): array
{ {
@ -156,8 +146,6 @@ if ( ! function_exists('array_is_list'))
* Polyfill for PHP 8 * Polyfill for PHP 8
* *
* @see https://www.php.net/manual/en/function.array-is-list * @see https://www.php.net/manual/en/function.array-is-list
* @param array $a
* @return bool
*/ */
function array_is_list(array $a): bool function array_is_list(array $a): bool
{ {
@ -167,9 +155,6 @@ if ( ! function_exists('array_is_list'))
/** /**
* Is the array sequential, not associative? * Is the array sequential, not associative?
*
* @param mixed $array
* @return bool
*/ */
function isSequentialArray(mixed $array): bool function isSequentialArray(mixed $array): bool
{ {
@ -183,9 +168,6 @@ function isSequentialArray(mixed $array): bool
/** /**
* Check that folder permissions are correct for proper operation * Check that folder permissions are correct for proper operation
*
* @param ConfigInterface $config
* @return array
*/ */
function checkFolderPermissions(ConfigInterface $config): array function checkFolderPermissions(ConfigInterface $config): array
{ {
@ -224,8 +206,6 @@ function checkFolderPermissions(ConfigInterface $config): array
/** /**
* Get an API Client, with better defaults * Get an API Client, with better defaults
*
* @return HttpClient
*/ */
function getApiClient (): HttpClient function getApiClient (): HttpClient
{ {
@ -242,8 +222,6 @@ function getApiClient (): HttpClient
/** /**
* Simplify making a request with Http\Client * Simplify making a request with Http\Client
* *
* @param string|Request $request
* @return Response
* @throws Throwable * @throws Throwable
*/ */
function getResponse (Request|string $request): Response function getResponse (Request|string $request): Response
@ -260,10 +238,6 @@ function getResponse (Request|string $request): Response
/** /**
* Generate the path for the cached image from the original image * Generate the path for the cached image from the original image
*
* @param string $kitsuUrl
* @param bool $webp
* @return string
*/ */
function getLocalImg (string $kitsuUrl, bool $webp = TRUE): string function getLocalImg (string $kitsuUrl, bool $webp = TRUE): string
{ {
@ -297,11 +271,6 @@ function getLocalImg (string $kitsuUrl, bool $webp = TRUE): string
* Create a transparent placeholder image * Create a transparent placeholder image
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $path
* @param int $width
* @param int $height
* @param string $text
* @return bool
*/ */
function createPlaceholderImage (string $path, int $width = 200, int $height = 200, string $text = 'Image Unavailable'): bool function createPlaceholderImage (string $path, int $width = 200, int $height = 200, string $text = 'Image Unavailable'): bool
{ {
@ -322,22 +291,15 @@ function createPlaceholderImage (string $path, int $width = 200, int $height = 2
/** /**
* Check that there is a value for at least one item in a collection with the specified key * Check that there is a value for at least one item in a collection with the specified key
*
* @param array $search
* @param string $key
* @return bool
*/ */
function colNotEmpty(array $search, string $key): bool function colNotEmpty(array $search, string $key): bool
{ {
$items = array_filter(array_column($search, $key), static fn ($x) => ( ! empty($x))); $items = array_filter(array_column($search, $key), static fn ($x) => ( ! empty($x)));
return count($items) > 0; return $items !== [];
} }
/** /**
* Clear the cache, but save user auth data * Clear the cache, but save user auth data
*
* @param CacheInterface $cache
* @return bool
*/ */
function clearCache(CacheInterface $cache): bool function clearCache(CacheInterface $cache): bool
{ {
@ -350,9 +312,10 @@ function clearCache(CacheInterface $cache): bool
]); ]);
$userData = array_filter((array)$userData, static fn ($value) => $value !== NULL); $userData = array_filter((array)$userData, static fn ($value) => $value !== NULL);
$cleared = $cache->clear(); $cleared = $cache->clear();
$saved = ( ! empty($userData)) ? $cache->setMultiple($userData) : TRUE; $saved = ( empty($userData)) ? TRUE : $cache->setMultiple($userData);
return $cleared && $saved; return $cleared && $saved;
} }
@ -361,9 +324,6 @@ function clearCache(CacheInterface $cache): bool
* Render a PHP code template as a string * Render a PHP code template as a string
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $path
* @param array $data
* @return string
*/ */
function renderTemplate(string $path, array $data): string function renderTemplate(string $path, array $data): string
{ {

View File

@ -46,11 +46,6 @@ abstract class BaseCommand extends Command {
/** /**
* Echo text in a box * Echo text in a box
*
* @param string|array $message
* @param string|int|null $fgColor
* @param string|int|null $bgColor
* @return void
*/ */
public function echoBox(string|array $message, string|int|null $fgColor = NULL, string|int|null $bgColor = NULL): void public function echoBox(string|array $message, string|int|null $fgColor = NULL, string|int|null $bgColor = NULL): void
{ {
@ -63,6 +58,7 @@ abstract class BaseCommand extends Command {
{ {
$fgColor = (int)$fgColor; $fgColor = (int)$fgColor;
} }
if ($bgColor !== NULL) if ($bgColor !== NULL)
{ {
$bgColor = (int)$bgColor; $bgColor = (int)$bgColor;
@ -123,7 +119,7 @@ abstract class BaseCommand extends Command {
*/ */
public function setupContainer(): ContainerInterface public function setupContainer(): ContainerInterface
{ {
$APP_DIR = _dir(dirname(dirname(SRC_DIR)), 'app'); $APP_DIR = _dir(dirname(SRC_DIR, 2), 'app');
$APPCONF_DIR = _dir($APP_DIR, 'appConf'); $APPCONF_DIR = _dir($APP_DIR, 'appConf');
$CONF_DIR = _dir($APP_DIR, 'config'); $CONF_DIR = _dir($APP_DIR, 'config');
$baseConfig = require _dir($APPCONF_DIR, 'base_config.php'); $baseConfig = require _dir($APPCONF_DIR, 'base_config.php');
@ -146,6 +142,7 @@ abstract class BaseCommand extends Command {
{ {
$fgColor = (int)$fgColor; $fgColor = (int)$fgColor;
} }
if ($bgColor !== NULL) if ($bgColor !== NULL)
{ {
$bgColor = (int)$bgColor; $bgColor = (int)$bgColor;
@ -168,6 +165,7 @@ abstract class BaseCommand extends Command {
$appLogger = new Logger('animeclient'); $appLogger = new Logger('animeclient');
$appLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', 2, Logger::WARNING)); $appLogger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', 2, Logger::WARNING));
$container->setLogger($appLogger); $container->setLogger($appLogger);
foreach (['kitsu-request', 'anilist-request', 'anilist-request-cli', 'kitsu-request-cli'] as $channel) foreach (['kitsu-request', 'anilist-request', 'anilist-request-cli', 'kitsu-request-cli'] as $channel)
@ -184,7 +182,7 @@ abstract class BaseCommand extends Command {
$container->set('config', fn () => new Config($configArray)); $container->set('config', fn () => new Config($configArray));
// Create Cache Object // Create Cache Object
$container->set('cache', static function($container) { $container->set('cache', static function($container): \Aviat\Banker\Teller {
$logger = $container->getLogger(); $logger = $container->getLogger();
$config = $container->get('config')->get('cache'); $config = $container->get('config')->get('cache');
return new Teller($config, $logger); return new Teller($config, $logger);

View File

@ -27,11 +27,8 @@ final class CacheClear extends BaseCommand {
/** /**
* Clear the API cache * Clear the API cache
* *
* @param array $args
* @param array $options
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @return void
*/ */
public function execute(array $args, array $options = []): void public function execute(array $args, array $options = []): void
{ {

View File

@ -27,11 +27,8 @@ final class CachePrime extends BaseCommand {
/** /**
* Clear, then prime the API cache * Clear, then prime the API cache
* *
* @param array $args
* @param array $options
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @return void
*/ */
public function execute(array $args, array $options = []): void public function execute(array $args, array $options = []): void
{ {

View File

@ -124,8 +124,6 @@ final class SyncLists extends BaseCommand {
/** /**
* Get and display the count of items for each API * Get and display the count of items for each API
*
* @param string $type
*/ */
protected function fetchCount(string $type): void protected function fetchCount(string $type): void
{ {
@ -150,8 +148,7 @@ final class SyncLists extends BaseCommand {
/** /**
* Get the list data * Get the list data
* *
* @param string $type * @return array<string, mixed[]>
* @return array
*/ */
protected function fetch(string $type): array protected function fetch(string $type): array
{ {
@ -175,9 +172,7 @@ final class SyncLists extends BaseCommand {
/** /**
* Normalize the list data for comparison * Normalize the list data for comparison
* *
* @param string $type * @return array<string, mixed[]>
* @param array $data
* @return array
*/ */
protected function transform(string $type, array $data): array protected function transform(string $type, array $data): array
{ {
@ -201,9 +196,7 @@ final class SyncLists extends BaseCommand {
/** /**
* Compare the lists data * Compare the lists data
* *
* @param string $type * @return array<string, mixed[]>
* @param array $data
* @return array
*/ */
protected function compare(string $type, array $data): array protected function compare(string $type, array $data): array
{ {
@ -215,22 +208,20 @@ final class SyncLists extends BaseCommand {
/** /**
* Updated outdated list items * Updated outdated list items
* *
* @param string $type
* @param array $data
* @throws Throwable * @throws Throwable
*/ */
protected function update(string $type, array $data): void protected function update(string $type, array $data): void
{ {
if ( ! empty($data['addToAnilist'])) if ( ! empty($data['addToAnilist']))
{ {
$count = count($data['addToAnilist']); $count = is_countable($data['addToAnilist']) ? count($data['addToAnilist']) : 0;
$this->echoBox("Adding {$count} missing {$type} list items to Anilist"); $this->echoBox("Adding {$count} missing {$type} list items to Anilist");
$this->updateAnilistListItems($data['addToAnilist'], SyncAction::CREATE, $type); $this->updateAnilistListItems($data['addToAnilist'], SyncAction::CREATE, $type);
} }
if ( ! empty($data['updateAnilist'])) if ( ! empty($data['updateAnilist']))
{ {
$count = count($data['updateAnilist']); $count = is_countable($data['updateAnilist']) ? count($data['updateAnilist']) : 0;
$this->echoBox("Updating {$count} outdated Anilist {$type} list items"); $this->echoBox("Updating {$count} outdated Anilist {$type} list items");
$this->updateAnilistListItems($data['updateAnilist'], SyncAction::UPDATE, $type); $this->updateAnilistListItems($data['updateAnilist'], SyncAction::UPDATE, $type);
} }
@ -239,14 +230,14 @@ final class SyncLists extends BaseCommand {
{ {
if ( ! empty($data['addToKitsu'])) if ( ! empty($data['addToKitsu']))
{ {
$count = count($data['addToKitsu']); $count = is_countable($data['addToKitsu']) ? count($data['addToKitsu']) : 0;
$this->echoBox("Adding {$count} missing {$type} list items to Kitsu"); $this->echoBox("Adding {$count} missing {$type} list items to Kitsu");
$this->updateKitsuListItems($data['addToKitsu'], SyncAction::CREATE, $type); $this->updateKitsuListItems($data['addToKitsu'], SyncAction::CREATE, $type);
} }
if ( ! empty($data['updateKitsu'])) if ( ! empty($data['updateKitsu']))
{ {
$count = count($data['updateKitsu']); $count = is_countable($data['updateKitsu']) ? count($data['updateKitsu']) : 0;
$this->echoBox("Updating {$count} outdated Kitsu {$type} list items"); $this->echoBox("Updating {$count} outdated Kitsu {$type} list items");
$this->updateKitsuListItems($data['updateKitsu'], SyncAction::UPDATE, $type); $this->updateKitsuListItems($data['updateKitsu'], SyncAction::UPDATE, $type);
} }
@ -279,6 +270,9 @@ final class SyncLists extends BaseCommand {
return $count; return $count;
} }
/**
* @return mixed[]
*/
private function fetchAnilist(string $type): array private function fetchAnilist(string $type): array
{ {
static $list = [ static $list = [
@ -310,6 +304,9 @@ final class SyncLists extends BaseCommand {
return $this->kitsuModel->{"get{$uType}ListCount"}() ?? 0; return $this->kitsuModel->{"get{$uType}ListCount"}() ?? 0;
} }
/**
* @return mixed[]
*/
private function fetchKitsu(string $type): array private function fetchKitsu(string $type): array
{ {
return $this->kitsuModel->getSyncList($type); return $this->kitsuModel->getSyncList($type);
@ -318,7 +315,9 @@ final class SyncLists extends BaseCommand {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Transform Helpers // Transform Helpers
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/**
* @return mixed[]
*/
private function transformKitsu(string $type, array $data): array private function transformKitsu(string $type, array $data): array
{ {
if (empty($data)) if (empty($data))
@ -335,6 +334,7 @@ final class SyncLists extends BaseCommand {
{ {
continue; continue;
} }
$malId = NULL; $malId = NULL;
foreach ($listItem['media']['mappings']['nodes'] as $mapping) foreach ($listItem['media']['mappings']['nodes'] as $mapping)
@ -375,6 +375,9 @@ final class SyncLists extends BaseCommand {
return $output; return $output;
} }
/**
* @return array<int|string, mixed>
*/
private function transformAnilist(string $type, array $data): array private function transformAnilist(string $type, array $data): array
{ {
$uType = ucfirst($type); $uType = ucfirst($type);
@ -403,7 +406,9 @@ final class SyncLists extends BaseCommand {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Compare Helpers // Compare Helpers
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/**
* @return array<string, mixed[]>
*/
private function compareLists(string $type, array $anilistList, array $kitsuList): array private function compareLists(string $type, array $anilistList, array $kitsuList): array
{ {
$itemsToAddToAnilist = []; $itemsToAddToAnilist = [];
@ -486,10 +491,6 @@ final class SyncLists extends BaseCommand {
/** /**
* Compare two list items, and return the out of date one, if one exists * Compare two list items, and return the out of date one, if one exists
*
* @param array $kitsuItem
* @param array $anilistItem
* @return array|null
*/ */
private function compareListItems(array $kitsuItem, array $anilistItem): ?array private function compareListItems(array $kitsuItem, array $anilistItem): ?array
{ {
@ -708,13 +709,9 @@ final class SyncLists extends BaseCommand {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Update Helpers // Update Helpers
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** /**
* Create/Update list items on Kitsu * Create/Update list items on Kitsu
* *
* @param array $itemsToUpdate
* @param string $action
* @param string $type
* @throws Throwable * @throws Throwable
*/ */
private function updateKitsuListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void private function updateKitsuListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void
@ -736,6 +733,7 @@ final class SyncLists extends BaseCommand {
$this->echoWarning("Skipped creating Kitsu {$type} due to missing id ¯\_(ツ)_/¯"); $this->echoWarning("Skipped creating Kitsu {$type} due to missing id ¯\_(ツ)_/¯");
continue; continue;
} }
$requester->addRequest($maybeRequest); $requester->addRequest($maybeRequest);
} }
} }
@ -781,9 +779,6 @@ final class SyncLists extends BaseCommand {
/** /**
* Create/Update list items on Anilist * Create/Update list items on Anilist
* *
* @param array $itemsToUpdate
* @param string $action
* @param string $type
* @throws Throwable * @throws Throwable
*/ */
private function updateAnilistListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void private function updateAnilistListItems(array $itemsToUpdate, string $action = SyncAction::UPDATE, string $type = MediaType::ANIME): void
@ -806,11 +801,11 @@ final class SyncLists extends BaseCommand {
{ {
$requester->addRequest($this->anilistModel->createFullListItem($item, $type)); $requester->addRequest($this->anilistModel->createFullListItem($item, $type));
} }
catch (MissingIdException $e) catch (MissingIdException)
{ {
// Case where there's a MAL mapping from Kitsu, but no equivalent Anlist item // Case where there's a MAL mapping from Kitsu, but no equivalent Anlist item
$id = $item['mal_id']; $id = $item['mal_id'];
$this->echoWarning("Skipping Anilist ${type} with MAL id: {$id} due to missing mapping"); $this->echoWarning("Skipping Anilist {$type} with MAL id: {$id} due to missing mapping");
} }
} }
} }

View File

@ -26,7 +26,6 @@ use Aviat\AnimeClient\Controller\Images;
final class UpdateThumbnails extends ClearThumbnails { final class UpdateThumbnails extends ClearThumbnails {
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
* @var KitsuModel
*/ */
protected KitsuModel $kitsuModel; protected KitsuModel $kitsuModel;

View File

@ -28,10 +28,6 @@ trait ComponentTrait {
/** /**
* Render a template with common container values * Render a template with common container values
*
* @param string $path
* @param array $data
* @return string
*/ */
public function render(string $path, array $data): string public function render(string $path, array $data): string
{ {

View File

@ -26,9 +26,6 @@ final class Tabs {
* also used to generate id attributes * also used to generate id attributes
* @param array $tabData The data used to create the tab content, indexed by the tab label * @param array $tabData The data used to create the tab content, indexed by the tab label
* @param callable $cb The function to generate the tab content * @param callable $cb The function to generate the tab content
* @param string $className
* @param bool $hasSectionWrapper
* @return string
*/ */
public function __invoke( public function __invoke(
string $name, string $name,

View File

@ -26,8 +26,6 @@ final class VerticalTabs {
* also used to generate id attributes * also used to generate id attributes
* @param array $tabData The data used to create the tab content, indexed by the tab label * @param array $tabData The data used to create the tab content, indexed by the tab label
* @param callable $cb The function to generate the tab content * @param callable $cb The function to generate the tab content
* @param string $className
* @return string
*/ */
public function __invoke( public function __invoke(
string $name, string $name,

View File

@ -169,7 +169,6 @@ class Controller {
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function sessionRedirect(): void public function sessionRedirect(): void
{ {
@ -200,9 +199,6 @@ class Controller {
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param HtmlView $view * @param HtmlView $view
* @param string $template
* @param array $data
* @return string
*/ */
protected function loadPartial(HtmlView $view, string $template, array $data = []): string protected function loadPartial(HtmlView $view, string $template, array $data = []): string
{ {
@ -232,8 +228,6 @@ class Controller {
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param HtmlView $view * @param HtmlView $view
* @param string $template
* @param array $data
* @return HtmlView * @return HtmlView
*/ */
protected function renderFullPage(HtmlView $view, string $template, array $data): HtmlView protected function renderFullPage(HtmlView $view, string $template, array $data): HtmlView
@ -262,10 +256,7 @@ class Controller {
* 404 action * 404 action
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $title
* @param string $message
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function notFound( public function notFound(
string $title = 'Sorry, page not found', string $title = 'Sorry, page not found',
@ -283,12 +274,7 @@ class Controller {
* Display a generic error page * Display a generic error page
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param int $httpCode
* @param string $title
* @param string $message
* @param string $longMessage
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function errorPage(int $httpCode, string $title, string $message, string $longMessage = ''): void public function errorPage(int $httpCode, string $title, string $message, string $longMessage = ''): void
{ {
@ -304,7 +290,6 @@ class Controller {
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function redirectToDefaultRoute(): void public function redirectToDefaultRoute(): void
{ {
@ -317,9 +302,6 @@ class Controller {
* next page load * next page load
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $message
* @param string $type
* @return void
*/ */
public function setFlashMessage(string $message, string $type = 'info'): void public function setFlashMessage(string $message, string $type = 'info'): void
{ {
@ -342,7 +324,6 @@ class Controller {
* Helper for consistent page titles * Helper for consistent page titles
* *
* @param string ...$parts Title segments * @param string ...$parts Title segments
* @return string
*/ */
public function formatTitle(string ...$parts) : string public function formatTitle(string ...$parts) : string
{ {
@ -354,10 +335,7 @@ class Controller {
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param HtmlView $view * @param HtmlView $view
* @param string $type
* @param string $message
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return string
*/ */
protected function showMessage(HtmlView $view, string $type, string $message): string protected function showMessage(HtmlView $view, string $type, string $message): string
{ {
@ -371,11 +349,7 @@ class Controller {
* Output a template to HTML, using the provided data * Output a template to HTML, using the provided data
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $template
* @param array $data
* @param HtmlView|NULL $view * @param HtmlView|NULL $view
* @param int $code
* @return void
*@throws InvalidArgumentException *@throws InvalidArgumentException
*/ */
protected function outputHTML(string $template, array $data = [], HtmlView $view = NULL, int $code = 200): void protected function outputHTML(string $template, array $data = [], HtmlView $view = NULL, int $code = 200): void
@ -393,10 +367,8 @@ class Controller {
* Output a JSON Response * Output a JSON Response
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param mixed $data
* @param int $code - the http status code * @param int $code - the http status code
* @throws DoubleRenderException * @throws DoubleRenderException
* @return void
*/ */
protected function outputJSON(mixed $data, int $code): void protected function outputJSON(mixed $data, int $code): void
{ {
@ -410,9 +382,6 @@ class Controller {
* Redirect to the selected page * Redirect to the selected page
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* @param string $url
* @param int $code
* @return void
*/ */
protected function redirect(string $url, int $code): void protected function redirect(string $url, int $code): void
{ {
@ -423,4 +392,5 @@ class Controller {
catch (\Throwable) {} catch (\Throwable) {}
} }
} }
// End of BaseController.php // End of BaseController.php

View File

@ -39,14 +39,12 @@ final class Anime extends BaseController {
/** /**
* The anime list model * The anime list model
* @var AnimeModel $model
*/ */
protected AnimeModel $model; protected AnimeModel $model;
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -68,7 +66,6 @@ final class Anime extends BaseController {
* *
* @param int|string $status - The section of the list * @param int|string $status - The section of the list
* @param string|null $view - List or cover view * @param string|null $view - List or cover view
* @return void
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws Throwable * @throws Throwable
*/ */
@ -116,7 +113,6 @@ final class Anime extends BaseController {
* @throws RouteNotFound * @throws RouteNotFound
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function addForm(): void public function addForm(): void
{ {
@ -137,7 +133,6 @@ final class Anime extends BaseController {
* Add an anime to the list * Add an anime to the list
* *
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function add(): void public function add(): void
{ {
@ -172,9 +167,6 @@ final class Anime extends BaseController {
/** /**
* Form to edit details about a series * Form to edit details about a series
*
* @param string $id
* @param string $status
*/ */
public function edit(string $id, string $status = 'all'): void public function edit(string $id, string $status = 'all'): void
{ {
@ -198,8 +190,6 @@ final class Anime extends BaseController {
/** /**
* Search for anime * Search for anime
*
* @return void
*/ */
public function search(): void public function search(): void
{ {
@ -212,7 +202,6 @@ final class Anime extends BaseController {
* Update an anime item via a form submission * Update an anime item via a form submission
* *
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function formUpdate(): void public function formUpdate(): void
{ {
@ -243,7 +232,6 @@ final class Anime extends BaseController {
* Increase the watched count for an anime item * Increase the watched count for an anime item
* *
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function increment(): void public function increment(): void
{ {
@ -274,7 +262,6 @@ final class Anime extends BaseController {
* Remove an anime from the list * Remove an anime from the list
* *
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function delete(): void public function delete(): void
{ {
@ -299,9 +286,7 @@ final class Anime extends BaseController {
/** /**
* View details of an anime * View details of an anime
* *
* @param string $id
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function details(string $id): void public function details(string $id): void
{ {
@ -379,4 +364,5 @@ final class Anime extends BaseController {
} }
} }
} }
// End of AnimeController.php // End of AnimeController.php

View File

@ -49,7 +49,6 @@ final class AnimeCollection extends BaseController {
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -76,7 +75,6 @@ final class AnimeCollection extends BaseController {
* Search for anime * Search for anime
* *
* @throws DoubleRenderException * @throws DoubleRenderException
* @return void
*/ */
public function search(): void public function search(): void
{ {
@ -88,11 +86,9 @@ final class AnimeCollection extends BaseController {
/** /**
* Show the anime collection page * Show the anime collection page
* *
* @param string|null $view
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function view(?string $view = ''): void public function view(?string $view = ''): void
{ {
@ -120,7 +116,6 @@ final class AnimeCollection extends BaseController {
* @throws NotFoundException * @throws NotFoundException
* @throws RouteNotFound * @throws RouteNotFound
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function form($id = NULL): void public function form($id = NULL): void
{ {
@ -149,7 +144,6 @@ final class AnimeCollection extends BaseController {
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function edit(): void public function edit(): void
{ {
@ -163,7 +157,6 @@ final class AnimeCollection extends BaseController {
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function add(): void public function add(): void
{ {
@ -211,8 +204,6 @@ final class AnimeCollection extends BaseController {
/** /**
* Remove a collection item * Remove a collection item
*
* @return void
*/ */
public function delete(): void public function delete(): void
{ {
@ -237,8 +228,6 @@ final class AnimeCollection extends BaseController {
/** /**
* Update a collection item * Update a collection item
*
* @param array $data
*/ */
protected function update(array $data): void protected function update(array $data): void
{ {
@ -259,4 +248,5 @@ final class AnimeCollection extends BaseController {
$this->sessionRedirect(); $this->sessionRedirect();
} }
} }
// End of AnimeCollection.php // End of AnimeCollection.php

View File

@ -29,15 +29,11 @@ use Aviat\Ion\Di\Exception\NotFoundException;
*/ */
final class Character extends BaseController { final class Character extends BaseController {
/**
* @var Model
*/
private Model $model; private Model $model;
/** /**
* Character constructor. * Character constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -49,9 +45,6 @@ final class Character extends BaseController {
/** /**
* Show information about a character * Show information about a character
*
* @param string $slug
* @return void
*/ */
public function index(string $slug): void public function index(string $slug): void
{ {

View File

@ -29,20 +29,17 @@ use Aviat\Ion\Di\Exception\NotFoundException;
final class History extends BaseController { final class History extends BaseController {
/** /**
* The anime list model * The anime list model
* @var AnimeModel
*/ */
protected AnimeModel $animeModel; protected AnimeModel $animeModel;
/** /**
* The manga list model * The manga list model
* @var MangaModel
*/ */
protected MangaModel $mangaModel; protected MangaModel $mangaModel;
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */

View File

@ -34,7 +34,6 @@ final class Images extends BaseController {
* @param string $type The category of image * @param string $type The category of image
* @param string $file The filename to look for * @param string $file The filename to look for
* @param bool $display Whether to output the image to the server * @param bool $display Whether to output the image to the server
* @return void
* @throws Throwable * @throws Throwable
*/ */
public function cache(string $type, string $file, bool $display = TRUE): void public function cache(string $type, string $file, bool $display = TRUE): void
@ -123,6 +122,7 @@ final class Images extends BaseController {
{ {
createPlaceholderImage("{$baseSavePath}/{$type}", $width, $height); createPlaceholderImage("{$baseSavePath}/{$type}", $width, $height);
} }
return; return;
} }
@ -177,14 +177,10 @@ final class Images extends BaseController {
/** /**
* Get a placeholder for a missing image * Get a placeholder for a missing image
*
* @param string $path
* @param int|null $width
* @param int|null $height
*/ */
private function getPlaceholder (string $path, ?int $width = 200, ?int $height = NULL): void private function getPlaceholder (string $path, ?int $width = 200, ?int $height = NULL): void
{ {
$height = $height ?? $width; $height ??= $width;
$filename = $path . '/placeholder.png'; $filename = $path . '/placeholder.png';

View File

@ -36,14 +36,12 @@ final class Manga extends Controller {
/** /**
* The manga model * The manga model
* @var MangaModel $model
*/ */
protected MangaModel $model; protected MangaModel $model;
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -62,9 +60,7 @@ final class Manga extends Controller {
/** /**
* Get a section of the manga list * Get a section of the manga list
* *
* @param string $status
* @param string $view * @param string $view
* @return void
*@throws InvalidArgumentException *@throws InvalidArgumentException
*/ */
public function index(string $status = 'all', ?string $view = ''): void public function index(string $status = 'all', ?string $view = ''): void
@ -110,7 +106,6 @@ final class Manga extends Controller {
* @throws NotFoundException * @throws NotFoundException
* @throws RouteNotFound * @throws RouteNotFound
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function addForm(): void public function addForm(): void
{ {
@ -132,7 +127,6 @@ final class Manga extends Controller {
/** /**
* Add an manga to the list * Add an manga to the list
* *
* @return void
* @throws Throwable * @throws Throwable
*/ */
public function add(): void public function add(): void
@ -168,13 +162,10 @@ final class Manga extends Controller {
/** /**
* Show the manga edit form * Show the manga edit form
* *
* @param string $id
* @param string $status
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws RouteNotFound * @throws RouteNotFound
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return void
*/ */
public function edit(string $id, string $status = 'All'): void public function edit(string $id, string $status = 'All'): void
{ {
@ -199,8 +190,6 @@ final class Manga extends Controller {
/** /**
* Search for a manga to add to the list * Search for a manga to add to the list
*
* @return void
*/ */
public function search(): void public function search(): void
{ {
@ -212,7 +201,6 @@ final class Manga extends Controller {
/** /**
* Update an manga item via a form submission * Update an manga item via a form submission
* *
* @return void
* @throws Throwable * @throws Throwable
*/ */
public function formUpdate(): void public function formUpdate(): void
@ -270,7 +258,6 @@ final class Manga extends Controller {
* Remove an manga from the list * Remove an manga from the list
* *
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function delete(): void public function delete(): void
{ {
@ -295,10 +282,8 @@ final class Manga extends Controller {
/** /**
* View details of an manga * View details of an manga
* *
* @param string $id
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function details(string $id): void public function details(string $id): void
{ {
@ -329,7 +314,6 @@ final class Manga extends Controller {
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws Throwable * @throws Throwable
* @return void
*/ */
public function random(): void public function random(): void
{ {
@ -355,4 +339,5 @@ final class Manga extends Controller {
]); ]);
} }
} }
// End of MangaController.php // End of MangaController.php

View File

@ -27,8 +27,6 @@ use Aviat\Ion\View\HtmlView;
final class Misc extends BaseController { final class Misc extends BaseController {
/** /**
* Purges the API cache * Purges the API cache
*
* @return void
*/ */
public function clearCache(): void public function clearCache(): void
{ {
@ -43,9 +41,6 @@ final class Misc extends BaseController {
/** /**
* Show the login form * Show the login form
*
* @param string $status
* @return void
*/ */
public function login(string $status = ''): void public function login(string $status = ''): void
{ {
@ -69,8 +64,6 @@ final class Misc extends BaseController {
/** /**
* Attempt login authentication * Attempt login authentication
*
* @return void
*/ */
public function loginAction(): void public function loginAction(): void
{ {
@ -92,8 +85,6 @@ final class Misc extends BaseController {
/** /**
* Deauthorize the current user * Deauthorize the current user
*
* @return void
*/ */
public function logout(): void public function logout(): void
{ {

View File

@ -29,15 +29,11 @@ use Aviat\Ion\Di\Exception\NotFoundException;
*/ */
final class People extends BaseController { final class People extends BaseController {
/**
* @var Model
*/
private Model $model; private Model $model;
/** /**
* People constructor. * People constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -49,9 +45,6 @@ final class People extends BaseController {
/** /**
* Show information about a person * Show information about a person
*
* @param string $slug
* @return void
*/ */
public function index(string $slug): void public function index(string $slug): void
{ {

View File

@ -29,20 +29,13 @@ use Aviat\Ion\Di\Exception\NotFoundException;
*/ */
final class Settings extends BaseController { final class Settings extends BaseController {
/**
* @var AnilistModel
*/
private AnilistModel $anilistModel; private AnilistModel $anilistModel;
/**
* @var SettingsModel
*/
private SettingsModel $settingsModel; private SettingsModel $settingsModel;
/** /**
* Settings constructor. * Settings constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -147,6 +140,7 @@ final class Settings extends BaseController {
{ {
$newSettings[$key] = $value; $newSettings[$key] = $value;
} }
unset($newSettings['config']); unset($newSettings['config']);
$saved = $this->settingsModel->saveSettingsFile($newSettings); $saved = $this->settingsModel->saveSettingsFile($newSettings);

View File

@ -29,15 +29,11 @@ use Aviat\Ion\Di\Exception\NotFoundException;
*/ */
final class User extends BaseController { final class User extends BaseController {
/**
* @var Model
*/
private Model $kitsuModel; private Model $kitsuModel;
/** /**
* User constructor. * User constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -58,9 +54,6 @@ final class User extends BaseController {
/** /**
* Show the user profile page * Show the user profile page
*
* @param string $username
* @return void
*/ */
public function about(string $username): void public function about(string $username): void
{ {

View File

@ -53,26 +53,23 @@ final class Dispatcher extends RoutingBase {
/** /**
* Routing array * Routing array
* @var array
*/ */
protected array $routes; protected array $routes = [];
/** /**
* Routes added to router * Routes added to router
* @var array $outputRoutes
*/ */
protected array $outputRoutes; protected array $outputRoutes = [];
/** /**
* Constructor * Constructor
*
* @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
parent::__construct($container); parent::__construct($container);
$router = $this->container->get('aura-router'); $router = $this->container->get('aura-router');
$this->router = $router->getMap(); $this->router = $router->getMap();
$this->matcher = $router->getMatcher(); $this->matcher = $router->getMatcher();
$this->routes = $this->config->get('routes'); $this->routes = $this->config->get('routes');
$this->outputRoutes = $this->setupRoutes(); $this->outputRoutes = $this->setupRoutes();
@ -104,7 +101,7 @@ final class Dispatcher extends RoutingBase {
/** /**
* Get list of routes applied * Get list of routes applied
* *
* @return array * @return mixed[]
*/ */
public function getOutputRoutes(): array public function getOutputRoutes(): array
{ {
@ -115,7 +112,6 @@ final class Dispatcher extends RoutingBase {
* Handle the current route * Handle the current route
* *
* @param object|null $route * @param object|null $route
* @return void
* @throws ReflectionException * @throws ReflectionException
*/ */
public function __invoke(object $route = NULL): void public function __invoke(object $route = NULL): void
@ -157,9 +153,8 @@ final class Dispatcher extends RoutingBase {
* Parse out the arguments for the appropriate controller for * Parse out the arguments for the appropriate controller for
* the current route * the current route
* *
* @param Friend $route
* @throws LogicException * @throws LogicException
* @return array * @return array<string, mixed>
*/ */
protected function processRoute(Friend $route): array protected function processRoute(Friend $route): array
{ {
@ -193,6 +188,7 @@ final class Dispatcher extends RoutingBase {
} }
} }
} }
$logger = $this->container->getLogger(); $logger = $this->container->getLogger();
if ($logger !== NULL) if ($logger !== NULL)
{ {
@ -208,8 +204,6 @@ final class Dispatcher extends RoutingBase {
/** /**
* Get the type of route, to select the current controller * Get the type of route, to select the current controller
*
* @return string
*/ */
public function getController(): string public function getController(): string
{ {
@ -237,7 +231,7 @@ final class Dispatcher extends RoutingBase {
/** /**
* Get the list of controllers in the default namespace * Get the list of controllers in the default namespace
* *
* @return array * @return mixed[]
*/ */
public function getControllerList(): array public function getControllerList(): array
{ {
@ -247,6 +241,7 @@ final class Dispatcher extends RoutingBase {
$path = str_replace($find, $replace, $defaultNamespace); $path = str_replace($find, $replace, $defaultNamespace);
$path = trim($path, '/'); $path = trim($path, '/');
$actualPath = realpath(_dir(SRC_DIR, $path)); $actualPath = realpath(_dir(SRC_DIR, $path));
$classFiles = glob("{$actualPath}/*.php"); $classFiles = glob("{$actualPath}/*.php");
if ($classFiles === FALSE) if ($classFiles === FALSE)
@ -273,9 +268,6 @@ final class Dispatcher extends RoutingBase {
* method * method
* *
* @param string $controllerName - The full namespace of the controller class * @param string $controllerName - The full namespace of the controller class
* @param string $method
* @param array $params
* @return void
*/ */
protected function call(string $controllerName, string $method, array $params): void protected function call(string $controllerName, string $method, array $params): void
{ {
@ -299,6 +291,7 @@ final class Dispatcher extends RoutingBase {
'API request timed out', 'API request timed out',
'Failed to retrieve data from API (╯°□°)╯︵ ┻━┻'); 'Failed to retrieve data from API (╯°□°)╯︵ ┻━┻');
} }
/* finally /* finally
{ {
// Log out on session/api token expiration // Log out on session/api token expiration
@ -312,6 +305,7 @@ final class Dispatcher extends RoutingBase {
/** /**
* Get the appropriate params for the error page * Get the appropriate params for the error page
* passed on the failed route * passed on the failed route
* @return mixed[][]
*/ */
protected function getErrorParams(): array protected function getErrorParams(): array
{ {
@ -360,7 +354,7 @@ final class Dispatcher extends RoutingBase {
/** /**
* Select controller based on the current url, and apply its relevant routes * Select controller based on the current url, and apply its relevant routes
* *
* @return array * @return mixed[]
*/ */
protected function setupRoutes(): array protected function setupRoutes(): array
{ {
@ -415,4 +409,5 @@ final class Dispatcher extends RoutingBase {
return $routes; return $routes;
} }
} }
// End of Dispatcher.php // End of Dispatcher.php

View File

@ -27,15 +27,12 @@ use Aviat\Ion\Di\Exception\NotFoundException;
final class FormGenerator { final class FormGenerator {
/** /**
* Html generation helper * Html generation helper
*
* @var HelperLocator
*/ */
private HelperLocator $helper; private HelperLocator $helper;
/** /**
* FormGenerator constructor. * FormGenerator constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -46,9 +43,6 @@ final class FormGenerator {
/** /**
* Create a new FormGenerator * Create a new FormGenerator
*
* @param ContainerInterface $container
* @return self
*/ */
public static function new(ContainerInterface $container): self public static function new(ContainerInterface $container): self
{ {
@ -57,10 +51,6 @@ final class FormGenerator {
/** /**
* Generate the html structure of the form * Generate the html structure of the form
*
* @param string $name
* @param array $form
* @return string
*/ */
public function generate(string $name, array $form): string public function generate(string $name, array $form): string
{ {

View File

@ -29,8 +29,6 @@ final class Form {
/** /**
* Create the html for the specified form * Create the html for the specified form
* *
* @param string $name
* @param array $form
* @return string * @return string
*/ */
public function __invoke(string $name, array $form) public function __invoke(string $name, array $form)

View File

@ -29,13 +29,13 @@ final class Menu {
/** /**
* Create the html for the selected menu * Create the html for the selected menu
* *
* @param string $menuName
* @return string * @return string
*/ */
public function __invoke($menuName) public function __invoke(string $menuName)
{ {
return MenuGenerator::new($this->container)->generate($menuName); return MenuGenerator::new($this->container)->generate($menuName);
} }
} }
// End of Menu.php // End of Menu.php

View File

@ -35,12 +35,6 @@ final class Picture {
/** /**
* Create the html for an html picture element. * Create the html for an html picture element.
* Uses .webp images with fallback * Uses .webp images with fallback
*
* @param string $uri
* @param string $fallbackExt
* @param array $picAttrs
* @param array $imgAttrs
* @return string
*/ */
public function __invoke(string $uri, string $fallbackExt = 'jpg', array $picAttrs = [], array $imgAttrs = []): string public function __invoke(string $uri, string $fallbackExt = 'jpg', array $picAttrs = [], array $imgAttrs = []): string
{ {
@ -119,4 +113,5 @@ final class Picture {
return $helper->elementRaw('picture', $sources, $picAttrs); return $helper->elementRaw('picture', $sources, $picAttrs);
} }
} }
// End of Picture.php // End of Picture.php

View File

@ -44,7 +44,6 @@ final class Kitsu {
* *
* @param string|null $startDate * @param string|null $startDate
* @param string|null $endDate * @param string|null $endDate
* @return string
*/ */
public static function getAiringStatus(string $startDate = NULL, string $endDate = NULL): string public static function getAiringStatus(string $startDate = NULL, string $endDate = NULL): string
{ {
@ -73,7 +72,6 @@ final class Kitsu {
* *
* @param string|null $startDate * @param string|null $startDate
* @param string|null $endDate * @param string|null $endDate
* @return string
*/ */
public static function formatAirDates(string $startDate = NULL, string $endDate = NULL): string public static function formatAirDates(string $startDate = NULL, string $endDate = NULL): string
{ {
@ -101,7 +99,7 @@ final class Kitsu {
if ($startDate === $endDate) if ($startDate === $endDate)
{ {
return "{$monthMap[$startMonth]} $startDay, $startYear"; return "{$monthMap[$startMonth]} {$startDay}, {$startYear}";
} }
if (empty($endDate)) if (empty($endDate))
@ -113,7 +111,7 @@ final class Kitsu {
if ($startYear === $endYear) if ($startYear === $endYear)
{ {
return "{$monthMap[$startMonth]} - {$monthMap[$endMonth]} $startYear"; return "{$monthMap[$startMonth]} - {$monthMap[$endMonth]} {$startYear}";
} }
return "{$monthMap[$startMonth]} {$startYear} - {$monthMap[$endMonth]} {$endYear}"; return "{$monthMap[$startMonth]} {$startYear} - {$monthMap[$endMonth]} {$endYear}";
@ -141,6 +139,9 @@ final class Kitsu {
return MangaPublishingStatus::NOT_YET_PUBLISHED; return MangaPublishingStatus::NOT_YET_PUBLISHED;
} }
/**
* @return array<string, string>
*/
public static function mappingsToUrls(array $mappings, string $kitsuLink = ''): array public static function mappingsToUrls(array $mappings, string $kitsuLink = ''): array
{ {
$output = []; $output = [];
@ -212,8 +213,7 @@ final class Kitsu {
/** /**
* Reorganize streaming links * Reorganize streaming links
* *
* @param array $nodes * @return mixed[]
* @return array
*/ */
public static function parseStreamingLinks(array $nodes): array public static function parseStreamingLinks(array $nodes): array
{ {
@ -257,8 +257,7 @@ final class Kitsu {
/** /**
* Get the list of titles * Get the list of titles
* *
* @param array $titles * @return mixed[]
* @return array
*/ */
public static function getTitles(array $titles): array public static function getTitles(array $titles): array
{ {
@ -273,8 +272,7 @@ final class Kitsu {
/** /**
* Filter out duplicate and very similar titles from a GraphQL response * Filter out duplicate and very similar titles from a GraphQL response
* *
* @param array $titles * @return mixed[]
* @return array
*/ */
public static function filterLocalizedTitles(array $titles): array public static function filterLocalizedTitles(array $titles): array
{ {
@ -304,8 +302,7 @@ final class Kitsu {
/** /**
* Filter out duplicate and very similar titles from a GraphQL response * Filter out duplicate and very similar titles from a GraphQL response
* *
* @param array $titles * @return mixed[]
* @return array
*/ */
public static function getFilteredTitles(array $titles): array public static function getFilteredTitles(array $titles): array
{ {
@ -338,10 +335,6 @@ final class Kitsu {
/** /**
* Get the url of the posterImage from Kitsu, with fallbacks * Get the url of the posterImage from Kitsu, with fallbacks
*
* @param array $base
* @param int $size
* @return string
*/ */
public static function getPosterImage(array $base, int $size = 1): string public static function getPosterImage(array $base, int $size = 1): string
{ {
@ -351,14 +344,14 @@ final class Kitsu {
$parts = explode('?', $rawUrl); $parts = explode('?', $rawUrl);
return ( ! empty($parts)) ? $parts[0] : $rawUrl; return ( empty($parts)) ? $rawUrl : $parts[0];
} }
/** /**
* Get the name and logo for the streaming service of the current link * Get the name and logo for the streaming service of the current link
* *
* @param string|null $hostname * @param string|null $hostname
* @return array * @return string[]|bool[]
*/ */
protected static function getServiceMetaData(string $hostname = NULL): array protected static function getServiceMetaData(string $hostname = NULL): array
{ {
@ -433,9 +426,6 @@ final class Kitsu {
/** /**
* Convert a time in seconds to a more human-readable format * Convert a time in seconds to a more human-readable format
*
* @param int $seconds
* @return string
*/ */
public static function friendlyTime(int $seconds): string public static function friendlyTime(int $seconds): string
{ {
@ -481,7 +471,7 @@ final class Kitsu {
if (empty($parts)) if (empty($parts))
{ {
return ($last !== NULL) ? $last : ''; return $last ?? '';
} }
return (count($parts) > 1) return (count($parts) > 1)
@ -491,10 +481,6 @@ final class Kitsu {
/** /**
* Determine if an alternate title is unique enough to list * Determine if an alternate title is unique enough to list
*
* @param string|null $title
* @param array $existingTitles
* @return bool
*/ */
protected static function titleIsUnique(?string $title = '', array $existingTitles = []): bool protected static function titleIsUnique(?string $title = '', array $existingTitles = []): bool
{ {

View File

@ -31,22 +31,14 @@ final class MenuGenerator extends UrlGenerator {
/** /**
* Html generation helper * Html generation helper
*
* @var HelperLocator
*/ */
protected HelperLocator $helper; protected HelperLocator $helper;
/** /**
* Request object * Request object
*
* @var ServerRequestInterface
*/ */
protected ServerRequestInterface $request; protected ServerRequestInterface $request;
/**
* @param ContainerInterface $container
* @return self
*/
public static function new(ContainerInterface $container): self public static function new(ContainerInterface $container): self
{ {
return new self($container); return new self($container);
@ -55,9 +47,7 @@ final class MenuGenerator extends UrlGenerator {
/** /**
* Generate the html structure of the menu selected * Generate the html structure of the menu selected
* *
* @param string $menu
* @throws ConfigException * @throws ConfigException
* @return string
*/ */
public function generate(string $menu) : string public function generate(string $menu) : string
{ {
@ -96,7 +86,6 @@ final class MenuGenerator extends UrlGenerator {
/** /**
* MenuGenerator constructor. * MenuGenerator constructor.
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -110,8 +99,7 @@ final class MenuGenerator extends UrlGenerator {
/** /**
* Generate the full menu structure from the config files * Generate the full menu structure from the config files
* *
* @param array $menus * @return array<mixed, array<string, string>>
* @return array
*/ */
private function parseConfig(array $menus) : array private function parseConfig(array $menus) : array
{ {
@ -130,4 +118,5 @@ final class MenuGenerator extends UrlGenerator {
return $parsed; return $parsed;
} }
} }
// End of MenuGenerator.php // End of MenuGenerator.php

View File

@ -22,10 +22,6 @@ namespace Aviat\AnimeClient\Model;
abstract class API { abstract class API {
/** /**
* Sort the list entries by their title * Sort the list entries by their title
*
* @param array $array
* @param string $sortKey
* @return void
*/ */
protected function sortByName(array &$array, string $sortKey): void protected function sortByName(array &$array, string $sortKey): void
{ {

View File

@ -30,8 +30,7 @@ class Anime extends API {
/** /**
* Get a category out of the full list * Get a category out of the full list
* *
* @param string $status * @return array<string, mixed>
* @return array
*/ */
public function getList(string $status): array public function getList(string $status): array
{ {
@ -49,7 +48,7 @@ class Anime extends API {
/** /**
* Get data for the 'all' anime page * Get data for the 'all' anime page
* *
* @return array * @return mixed[]
*/ */
public function getAllLists(): array public function getAllLists(): array
{ {
@ -65,9 +64,6 @@ class Anime extends API {
/** /**
* Get information about an anime from its slug * Get information about an anime from its slug
*
* @param string $slug
* @return AnimeType
*/ */
public function getAnime(string $slug): AnimeType public function getAnime(string $slug): AnimeType
{ {
@ -76,8 +72,6 @@ class Anime extends API {
/** /**
* Get information about a random anime * Get information about a random anime
*
* @return AnimeType
*/ */
public function getRandomAnime(): AnimeType public function getRandomAnime(): AnimeType
{ {
@ -86,9 +80,6 @@ class Anime extends API {
/** /**
* Get anime by its kitsu id * Get anime by its kitsu id
*
* @param string $animeId
* @return AnimeType
*/ */
public function getAnimeById(string $animeId): AnimeType public function getAnimeById(string $animeId): AnimeType
{ {
@ -98,7 +89,7 @@ class Anime extends API {
/** /**
* Get recent watch history * Get recent watch history
* *
* @return array * @return mixed[]
*/ */
public function getHistory(): array public function getHistory(): array
{ {

View File

@ -28,14 +28,11 @@ final class AnimeCollection extends Collection {
/** /**
* Anime API Model * Anime API Model
* @var Anime $animeModel
*/ */
protected Anime $animeModel; protected Anime $animeModel;
/** /**
* Create the collection model * Create the collection model
*
* @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -46,7 +43,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get collection from the database, and organize by media type * Get collection from the database, and organize by media type
* *
* @return array * @return mixed[]
*/ */
public function getCollection(): array public function getCollection(): array
{ {
@ -77,7 +74,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get the collection from the database * Get the collection from the database
* *
* @return array * @return mixed[]
*/ */
public function getFlatCollection(): array public function getFlatCollection(): array
{ {
@ -123,7 +120,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get list of media types * Get list of media types
* *
* @return array * @return array<string, mixed[]>
*/ */
public function getMediaTypeList(): array public function getMediaTypeList(): array
{ {
@ -173,9 +170,6 @@ final class AnimeCollection extends Collection {
/** /**
* Add an item to the anime collection * Add an item to the anime collection
*
* @param mixed $data
* @return void
*/ */
public function add(mixed $data): void public function add(mixed $data): void
{ {
@ -212,9 +206,6 @@ final class AnimeCollection extends Collection {
/** /**
* Verify that an item was added * Verify that an item was added
*
* @param array $data
* @return bool
*/ */
public function wasAdded(array $data): bool public function wasAdded(array $data): bool
{ {
@ -230,9 +221,6 @@ final class AnimeCollection extends Collection {
/** /**
* Update a collection item * Update a collection item
*
* @param array $data
* @return void
*/ */
public function update(array $data): void public function update(array $data): void
{ {
@ -269,9 +257,7 @@ final class AnimeCollection extends Collection {
/** /**
* Verify that the collection item was updated * Verify that the collection item was updated
* *
* @param array $data
* *
* @return bool
*/ */
public function wasUpdated(array $data): bool public function wasUpdated(array $data): bool
{ {
@ -300,9 +286,6 @@ final class AnimeCollection extends Collection {
/** /**
* Remove a collection item * Remove a collection item
*
* @param array $data
* @return void
*/ */
public function delete(array $data): void public function delete(array $data): void
{ {
@ -331,10 +314,6 @@ final class AnimeCollection extends Collection {
$this->db->commit(); $this->db->commit();
} }
/**
* @param array $data
* @return bool
*/
public function wasDeleted(array $data): bool public function wasDeleted(array $data): bool
{ {
if ($this->db === NULL) if ($this->db === NULL)
@ -348,8 +327,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get the details of a collection item * Get the details of a collection item
* *
* @param int|string $kitsuId * @return mixed[]
* @return array
*/ */
public function get(int|string $kitsuId): array public function get(int|string $kitsuId): array
{ {
@ -388,9 +366,6 @@ final class AnimeCollection extends Collection {
/** /**
* Does this anime already exist in the collection? * Does this anime already exist in the collection?
*
* @param int|string $kitsuId
* @return bool
*/ */
public function has(int|string $kitsuId): bool public function has(int|string $kitsuId): bool
{ {
@ -411,8 +386,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get genres for anime collection items * Get genres for anime collection items
* *
* @param array $filter * @return mixed[]
* @return array
*/ */
public function getGenreList(array $filter = []): array public function getGenreList(array $filter = []): array
{ {
@ -479,8 +453,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get media for anime collection items * Get media for anime collection items
* *
* @param array $filter * @return mixed[]
* @return array
*/ */
public function getMediaList(array $filter = []): array public function getMediaList(array $filter = []): array
{ {
@ -537,7 +510,7 @@ final class AnimeCollection extends Collection {
} }
} }
} }
catch (PDOException $e) {} catch (PDOException) {}
$this->db->resetQuery(); $this->db->resetQuery();
@ -576,7 +549,6 @@ final class AnimeCollection extends Collection {
* Update genre information for selected anime * Update genre information for selected anime
* *
* @param string $animeId The current anime * @param string $animeId The current anime
* @return void
*/ */
private function updateGenres(string $animeId): void private function updateGenres(string $animeId): void
{ {
@ -626,8 +598,6 @@ final class AnimeCollection extends Collection {
/** /**
* Add genres to the database * Add genres to the database
*
* @param array $genres
*/ */
private function addNewGenres(array $genres): void private function addNewGenres(array $genres): void
{ {
@ -661,7 +631,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get list of existing genres * Get list of existing genres
* *
* @return array * @return array<string, mixed[]>
*/ */
private function getGenreData(): array private function getGenreData(): array
{ {
@ -671,6 +641,9 @@ final class AnimeCollection extends Collection {
]; ];
} }
/**
* @return mixed[]
*/
private function getExistingGenres(): array private function getExistingGenres(): array
{ {
if ($this->db === NULL) if ($this->db === NULL)
@ -701,6 +674,9 @@ final class AnimeCollection extends Collection {
return $genres; return $genres;
} }
/**
* @return mixed[]
*/
private function getExistingGenreLinkEntries(): array private function getExistingGenreLinkEntries(): array
{ {
if ($this->db === NULL) if ($this->db === NULL)
@ -740,7 +716,7 @@ final class AnimeCollection extends Collection {
/** /**
* Get full collection from the database * Get full collection from the database
* *
* @return array * @return mixed[]
*/ */
private function getCollectionFromDatabase(): array private function getCollectionFromDatabase(): array
{ {
@ -782,4 +758,5 @@ final class AnimeCollection extends Collection {
return $rows; return $rows;
} }
} }
// End of AnimeCollectionModel.php // End of AnimeCollectionModel.php

View File

@ -29,14 +29,11 @@ class Collection extends DB {
/** /**
* The query builder object * The query builder object
* @var QueryBuilderInterface|null
*/ */
protected ?QueryBuilderInterface $db; protected ?QueryBuilderInterface $db;
/** /**
* Create a new collection object * Create a new collection object
*
* @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -69,4 +66,5 @@ class Collection extends DB {
} }
} }
} }
// End of Collection.php // End of Collection.php

View File

@ -26,7 +26,6 @@ abstract class DB {
/** /**
* The database connection information array * The database connection information array
* @var array $dbConfig
*/ */
protected array $dbConfig = []; protected array $dbConfig = [];
@ -41,4 +40,5 @@ abstract class DB {
$this->setContainer($container); $this->setContainer($container);
} }
} }
// End of DB.php // End of DB.php

View File

@ -35,8 +35,7 @@ class Manga extends API {
/** /**
* Get a category out of the full list * Get a category out of the full list
* *
* @param string $status * @return mixed[]
* @return array
*/ */
public function getList(string $status): array public function getList(string $status): array
{ {
@ -60,7 +59,6 @@ class Manga extends API {
/** /**
* Get the details of a manga * Get the details of a manga
* *
* @param string $manga_id
* @return MangaPage * @return MangaPage
*/ */
public function getManga(string $manga_id): MangaPage public function getManga(string $manga_id): MangaPage
@ -81,7 +79,6 @@ class Manga extends API {
/** /**
* Get anime by its kitsu id * Get anime by its kitsu id
* *
* @param string $animeId
* @return MangaPage * @return MangaPage
*/ */
public function getMangaById(string $animeId): MangaPage public function getMangaById(string $animeId): MangaPage
@ -92,7 +89,7 @@ class Manga extends API {
/** /**
* Get recent reading history * Get recent reading history
* *
* @return array * @return mixed[]
*/ */
public function getHistory(): array public function getHistory(): array
{ {
@ -102,8 +99,7 @@ class Manga extends API {
/** /**
* Map transformed anime data to be organized by reading status * Map transformed anime data to be organized by reading status
* *
* @param array $data * @return array<string, mixed[]>
* @return array
*/ */
private function mapByStatus(array $data): array private function mapByStatus(array $data): array
{ {
@ -126,4 +122,5 @@ class Manga extends API {
return $output; return $output;
} }
} }
// End of MangaModel.php // End of MangaModel.php

View File

@ -34,29 +34,21 @@ trait MediaTrait {
/** /**
* Is the Anilist API enabled? * Is the Anilist API enabled?
*
* @var boolean
*/ */
protected bool $anilistEnabled; protected bool $anilistEnabled;
/** /**
* Model for making requests to Anilist API * Model for making requests to Anilist API
*
* @var Anilist\Model
*/ */
protected Anilist\Model $anilistModel; protected Anilist\Model $anilistModel;
/** /**
* Model for making requests to Kitsu API * Model for making requests to Kitsu API
*
* @var Kitsu\Model
*/ */
protected Kitsu\Model $kitsuModel; protected Kitsu\Model $kitsuModel;
/** /**
* Anime constructor. * Anime constructor.
*
* @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -70,9 +62,7 @@ trait MediaTrait {
/** /**
* Search for anime by name * Search for anime by name
* *
* @param string $name * @return mixed[]
* @param bool $inCollection
* @return array
*/ */
public function search(string $name, bool $inCollection = false): array public function search(string $name, bool $inCollection = false): array
{ {
@ -89,9 +79,6 @@ trait MediaTrait {
/** /**
* Get information about a specific list item * Get information about a specific list item
* for editing/updating that item * for editing/updating that item
*
* @param string $itemId
* @return AnimeListItem|MangaListItem
*/ */
public function getLibraryItem(string $itemId): AnimeListItem|MangaListItem public function getLibraryItem(string $itemId): AnimeListItem|MangaListItem
{ {
@ -101,8 +88,6 @@ trait MediaTrait {
/** /**
* Add an anime to your list * Add an anime to your list
* *
* @param array $data
* @return bool
* @throws Throwable * @throws Throwable
*/ */
public function createLibraryItem(array $data): bool public function createLibraryItem(array $data): bool
@ -128,15 +113,14 @@ trait MediaTrait {
$results = $requester->makeRequests(); $results = $requester->makeRequests();
return count($results) > 0; return $results !== [];
} }
/** /**
* Increment progress for the specified anime * Increment progress for the specified anime
* *
* @param FormItem $data
* @return array
* @throws Throwable * @throws Throwable
* @return array<string, mixed>
*/ */
public function incrementLibraryItem(FormItem $data): array public function incrementLibraryItem(FormItem $data): array
{ {
@ -167,9 +151,8 @@ trait MediaTrait {
/** /**
* Update a list entry * Update a list entry
* *
* @param FormItem $data
* @return array
* @throws Throwable * @throws Throwable
* @return array<string, mixed>
*/ */
public function updateLibraryItem(FormItem $data): array public function updateLibraryItem(FormItem $data): array
{ {
@ -200,9 +183,7 @@ trait MediaTrait {
/** /**
* Delete a list entry * Delete a list entry
* *
* @param string $id
* @param string|null $malId * @param string|null $malId
* @return bool
* @throws Throwable * @throws Throwable
*/ */
public function deleteLibraryItem(string $id, string $malId = NULL): bool public function deleteLibraryItem(string $id, string $malId = NULL): bool
@ -222,6 +203,6 @@ trait MediaTrait {
$results = $requester->makeRequests(); $results = $requester->makeRequests();
return count($results) > 0; return $results !== [];
} }
} }

View File

@ -33,13 +33,13 @@ use Aviat\Ion\Di\ContainerAware;
final class Settings { final class Settings {
use ContainerAware; use ContainerAware;
private ConfigInterface $config; public function __construct(private ConfigInterface $config)
public function __construct(ConfigInterface $config)
{ {
$this->config = $config;
} }
/**
* @return array<string, mixed>
*/
public function getSettings(): array public function getSettings(): array
{ {
$settings = [ $settings = [
@ -65,13 +65,16 @@ final class Settings {
return $settings; return $settings;
} }
/**
* @return array<mixed, array<string, array<string[]|array<string, mixed>[]|class-string<\memcached>[]|class-string<\redis>[]|bool|float|int|string|null>>>
*/
public function getSettingsForm(): array public function getSettingsForm(): array
{ {
$output = []; $output = [];
foreach($this->getSettings() as $file => $values) foreach($this->getSettings() as $file => $values)
{ {
$values = $values ?? []; $values ??= [];
foreach(SETTINGS_MAP[$file] as $key => $value) foreach(SETTINGS_MAP[$file] as $key => $value)
{ {
@ -121,6 +124,9 @@ final class Settings {
return $output; return $output;
} }
/**
* @return mixed[]
*/
public function validateSettings(array $settings): array public function validateSettings(array $settings): array
{ {
$cfg = Config::check($settings); $cfg = Config::check($settings);

View File

@ -29,43 +29,31 @@ use Psr\Http\Message\ServerRequestInterface;
*/ */
class RoutingBase { class RoutingBase {
/**
* Injection Container
* @var ContainerInterface $container
*/
protected ContainerInterface $container;
/** /**
* Config Object * Config Object
* @var ConfigInterface
*/ */
protected ConfigInterface $config; protected ConfigInterface $config;
/** /**
* Class wrapper for input superglobals * Class wrapper for input superglobals
* @var ServerRequestInterface
*/ */
protected ServerRequestInterface $request; protected ServerRequestInterface $request;
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @throws ConfigException * @throws ConfigException
*/ */
public function __construct(ContainerInterface $container) public function __construct(protected ContainerInterface $container)
{ {
$this->container = $container;
$this->config = $container->get('config'); $this->config = $container->get('config');
$this->request = $container->get('request'); $this->request = $container->get('request');
} }
/** /**
* Get the current url path * Get the current url path
*
* @return string
*/ */
public function path(): string public function path(): string
{ {
@ -81,8 +69,6 @@ class RoutingBase {
/** /**
* Get the url segments * Get the url segments
*
* @return array
*/ */
public function segments(): array public function segments(): array
{ {
@ -93,9 +79,7 @@ class RoutingBase {
/** /**
* Get a segment of the current url * Get a segment of the current url
* *
* @param int $num
* *
* @return string|null
*/ */
public function getSegment(int $num): ?string public function getSegment(int $num): ?string
{ {
@ -105,8 +89,6 @@ class RoutingBase {
/** /**
* Retrieve the last url segment * Retrieve the last url segment
*
* @return string
*/ */
public function lastSegment(): string public function lastSegment(): string
{ {

View File

@ -19,12 +19,9 @@ namespace Aviat\AnimeClient\Types;
use ArrayAccess; use ArrayAccess;
use Countable; use Countable;
abstract class AbstractType implements ArrayAccess, Countable { abstract class AbstractType implements ArrayAccess, Countable, \Stringable {
/** /**
* Populate values for un-serializing data * Populate values for un-serializing data
*
* @param mixed $properties
* @return self
*/ */
public static function __set_state(mixed $properties): self public static function __set_state(mixed $properties): self
{ {
@ -33,9 +30,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Check the shape of the object, and return the array equivalent * Check the shape of the object, and return the array equivalent
*
* @param array $data
* @return array|null
*/ */
final public static function check(array $data = []): ?array final public static function check(array $data = []): ?array
{ {
@ -51,9 +45,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Static constructor * Static constructor
*
* @param mixed $data
* @return static
*/ */
final public static function from(mixed $data): static final public static function from(mixed $data): static
{ {
@ -62,8 +53,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Sets the properties by using the constructor * Sets the properties by using the constructor
*
* @param mixed $data
*/ */
final private function __construct(mixed $data = []) final private function __construct(mixed $data = [])
{ {
@ -86,9 +75,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* See if a property is set * See if a property is set
*
* @param string $name
* @return bool
*/ */
final public function __isset(string $name): bool final public function __isset(string $name): bool
{ {
@ -97,10 +83,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Set a property on the type object * Set a property on the type object
*
* @param string $name
* @param mixed $value
* @return void
*/ */
final public function __set(string $name, mixed $value): void final public function __set(string $name, mixed $value): void
{ {
@ -114,9 +96,9 @@ abstract class AbstractType implements ArrayAccess, Countable {
if ( ! property_exists($this, $name)) if ( ! property_exists($this, $name))
{ {
$existing = json_encode($this); $existing = json_encode($this, JSON_THROW_ON_ERROR);
throw new UndefinedPropertyException("Trying to set undefined property: '$name'. Existing properties: $existing"); throw new UndefinedPropertyException("Trying to set undefined property: '{$name}'. Existing properties: {$existing}");
} }
$this->$name = $value; $this->$name = $value;
@ -124,9 +106,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Get a property from the type object * Get a property from the type object
*
* @param string $name
* @return mixed
*/ */
final public function __get(string $name): mixed final public function __get(string $name): mixed
{ {
@ -137,8 +116,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Create a string representation of the object for debugging * Create a string representation of the object for debugging
*
* @return string
*/ */
public function __toString(): string public function __toString(): string
{ {
@ -147,9 +124,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Implementing ArrayAccess * Implementing ArrayAccess
*
* @param mixed $offset
* @return bool
*/ */
final public function offsetExists(mixed $offset): bool final public function offsetExists(mixed $offset): bool
{ {
@ -158,9 +132,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Implementing ArrayAccess * Implementing ArrayAccess
*
* @param mixed $offset
* @return mixed
*/ */
final public function offsetGet(mixed $offset): mixed final public function offsetGet(mixed $offset): mixed
{ {
@ -169,9 +140,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Implementing ArrayAccess * Implementing ArrayAccess
*
* @param mixed $offset
* @param mixed $value
*/ */
final public function offsetSet(mixed $offset, mixed $value): void final public function offsetSet(mixed $offset, mixed $value): void
{ {
@ -180,8 +148,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Implementing ArrayAccess * Implementing ArrayAccess
*
* @param mixed $offset
*/ */
final public function offsetUnset(mixed $offset): void final public function offsetUnset(mixed $offset): void
{ {
@ -194,8 +160,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Implementing Countable * Implementing Countable
*
* @return int
*/ */
final public function count(): int final public function count(): int
{ {
@ -209,7 +173,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
* Returns early on primitive values to work recursively. * Returns early on primitive values to work recursively.
* *
* @param mixed $parent * @param mixed $parent
* @return array
*/ */
final public function toArray(mixed $parent = null): array final public function toArray(mixed $parent = null): array
{ {
@ -219,8 +182,6 @@ abstract class AbstractType implements ArrayAccess, Countable {
/** /**
* Determine whether the type has any properties set * Determine whether the type has any properties set
*
* @return bool
*/ */
final public function isEmpty(): bool final public function isEmpty(): bool
{ {

View File

@ -22,45 +22,45 @@ use Aviat\AnimeClient\API\Kitsu\Enum\AnimeAiringStatus;
* Type representing an anime within a watch list * Type representing an anime within a watch list
*/ */
class Anime extends AbstractType { class Anime extends AbstractType {
public ?string $age_rating; public ?string $age_rating = null;
public ?string $age_rating_guide; public ?string $age_rating_guide = null;
public ?string $cover_image; public ?string $cover_image = null;
public ?int $episode_count; public ?int $episode_count = null;
public ?int $episode_length; public ?int $episode_length = null;
public array $genres = []; public array $genres = [];
public string $id = ''; public string $id = '';
public ?string $show_type; public ?string $show_type = null;
public ?string $slug; public ?string $slug = null;
public string $status = AnimeAiringStatus::FINISHED_AIRING; public string $status = AnimeAiringStatus::FINISHED_AIRING;
public ?array $streaming_links = []; public ?array $streaming_links = [];
public ?string $synopsis; public ?string $synopsis = null;
public ?string $title; public ?string $title = null;
public array $titles = []; public array $titles = [];
public array $titles_more = []; public array $titles_more = [];
public ?string $trailer_id; public ?string $trailer_id = null;
/** /**
* Length of the entire series in seconds * Length of the entire series in seconds
*/ */
public ?int $total_length; public ?int $total_length = null;
/** /**
* Kitsu detail page url * Kitsu detail page url
*/ */
public ?string $url; public ?string $url = null;
} }

View File

@ -20,9 +20,9 @@ namespace Aviat\AnimeClient\Types;
* Type representing an anime watch list item * Type representing an anime watch list item
*/ */
final class AnimeListItem extends AbstractType { final class AnimeListItem extends AbstractType {
public ?string $id; public ?string $id = null;
public ?string $mal_id; public ?string $mal_id = null;
public array $episodes = [ public array $episodes = [
'length' => 0, 'length' => 0,
@ -36,9 +36,9 @@ final class AnimeListItem extends AbstractType {
'ended' => '', 'ended' => '',
]; ];
public ?Anime $anime; public ?Anime $anime = null;
public ?string $notes; public ?string $notes = null;
public bool $private = FALSE; public bool $private = FALSE;

View File

@ -22,15 +22,15 @@ namespace Aviat\AnimeClient\Types;
final class Character extends AbstractType { final class Character extends AbstractType {
public array $castings = []; public array $castings = [];
public ?string $description; public ?string $description = null;
public string $id; public string $id;
public ?Media $media; public ?Media $media = null;
public string $image; public string $image;
public ?string $name; public ?string $name = null;
public array $names = []; public array $names = [];

View File

@ -45,29 +45,27 @@ class Config extends AbstractType {
* Default Anime list status page, values are listed in * Default Anime list status page, values are listed in
* Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Title * Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\Title
*/ */
public ?string $default_anime_list_path; public ?string $default_anime_list_path = null;
/** /**
* The list to redirect to from the root url * The list to redirect to from the root url
* 'anime' or 'manga' * 'anime' or 'manga'
*
* @var string|null
*/ */
public ?string $default_list; public ?string $default_list = null;
/** /**
* Default Manga list status page, values are listed in * Default Manga list status page, values are listed in
* Aviat\AnimeClient\API\Enum\MangaReadingStatus\Title * Aviat\AnimeClient\API\Enum\MangaReadingStatus\Title
*/ */
public ?string $default_manga_list_path; public ?string $default_manga_list_path = null;
/** /**
* Default list view type * Default list view type
* 'cover_view' or 'list_view' * 'cover_view' or 'list_view'
*/ */
public ?string $default_view_type; public ?string $default_view_type = null;
public ?string $kitsu_username; public ?string $kitsu_username = null;
public bool $secure_urls = TRUE; public bool $secure_urls = TRUE;

View File

@ -21,15 +21,15 @@ use Aviat\AnimeClient\Types\AbstractType;
class Anilist extends AbstractType { class Anilist extends AbstractType {
public bool|string $enabled = FALSE; public bool|string $enabled = FALSE;
public ?string $client_id; public ?string $client_id = null;
public ?string $client_secret; public ?string $client_secret = null;
public ?string $access_token; public ?string $access_token = null;
public int|string|null $access_token_expires; public int|string|null $access_token_expires;
public ?string $refresh_token; public ?string $refresh_token = null;
public ?string $username; public ?string $username = null;
} }

View File

@ -21,13 +21,13 @@ use Aviat\AnimeClient\Types\AbstractType;
class Cache extends AbstractType { class Cache extends AbstractType {
public string $driver = 'null'; public string $driver = 'null';
public ?string $host; public ?string $host = null;
public string|int|null $port; public string|int|null $port;
public ?string $database; public ?string $database = null;
public array $connection = []; public array $connection = [];
public ?array $options; public ?array $options = null;
} }

View File

@ -22,15 +22,15 @@ class Database extends AbstractType {
public string $type = 'sqlite'; public string $type = 'sqlite';
public ?string $host; public ?string $host = null;
public ?string $user; public ?string $user = null;
public ?string $pass; public ?string $pass = null;
public string|int|null $port; public string|int|null $port;
public ?string $database; public ?string $database = null;
public ?string $file; public ?string $file = null;
} }

View File

@ -24,7 +24,7 @@ class FormItem extends AbstractType {
public string|int|null $mal_id; public string|int|null $mal_id;
public ?FormItemData $data; public ?FormItemData $data = null;
public function setData(mixed $value): void public function setData(mixed $value): void
{ {

View File

@ -20,13 +20,13 @@ namespace Aviat\AnimeClient\Types;
* Type representing a Media object for editing/syncing * Type representing a Media object for editing/syncing
*/ */
class FormItemData extends AbstractType { class FormItemData extends AbstractType {
public ?string $notes; public ?string $notes = null;
public ?bool $private = FALSE; public ?bool $private = FALSE;
public ?int $progress = NULL; public ?int $progress = NULL;
public ?int $rating; public ?int $rating = null;
public ?int $ratingTwenty = NULL; public ?int $ratingTwenty = NULL;
@ -39,5 +39,5 @@ class FormItemData extends AbstractType {
/** /**
* W3C Format Date string * W3C Format Date string
*/ */
public ?string $updatedAt; public ?string $updatedAt = null;
} }

View File

@ -23,7 +23,7 @@ final class MangaListItem extends AbstractType {
public string $id; public string $id;
public ?string $mal_id; public ?string $mal_id = null;
public array $chapters = [ public array $chapters = [
'read' => 0, 'read' => 0,
@ -39,11 +39,11 @@ final class MangaListItem extends AbstractType {
public string $reading_status; public string $reading_status;
public ?string $notes; public ?string $notes = null;
public bool $rereading = false; public bool $rereading = false;
public ?int $reread; public ?int $reread = null;
public string|int|null $user_rating; public string|int|null $user_rating;
} }

View File

@ -32,7 +32,7 @@ final class MangaListItemDetail extends AbstractType {
public array $titles; public array $titles;
public ?string $type; public ?string $type = null;
public string $url; public string $url;
} }

View File

@ -22,15 +22,15 @@ use Aviat\AnimeClient\API\Kitsu\Enum\MangaPublishingStatus;
* Type representing an Anime object for display * Type representing an Anime object for display
*/ */
final class MangaPage extends AbstractType { final class MangaPage extends AbstractType {
public ?string $age_rating; public ?string $age_rating = null;
public ?string $age_rating_guide; public ?string $age_rating_guide = null;
public array $characters; public array $characters;
public ?int $chapter_count; public ?int $chapter_count = null;
public ?string $cover_image; public ?string $cover_image = null;
public array $genres; public array $genres;
@ -57,5 +57,5 @@ final class MangaPage extends AbstractType {
public string $url; public string $url;
public ?int $volume_count; public ?int $volume_count = null;
} }

View File

@ -23,13 +23,13 @@ final class Person extends AbstractType {
public string $id; public string $id;
public ?string $name; public ?string $name = null;
public string $image; public string $image;
public array $names = []; public array $names = [];
public ?string $description; public ?string $description = null;
public array $characters = []; public array $characters = [];

View File

@ -20,21 +20,21 @@ namespace Aviat\AnimeClient\Types;
* Type representing a Kitsu user for display * Type representing a Kitsu user for display
*/ */
final class User extends AbstractType { final class User extends AbstractType {
public ?string $about; public ?string $about = null;
public ?string $avatar; public ?string $avatar = null;
public ?array $favorites; public ?array $favorites = null;
public ?string $location; public ?string $location = null;
public ?string $name; public ?string $name = null;
public ?string $slug; public ?string $slug = null;
public ?array $stats; public ?array $stats = null;
public ?array $waifu; public ?array $waifu = null;
public ?string $website; public ?string $website = null;
} }

View File

@ -28,14 +28,12 @@ class UrlGenerator extends RoutingBase {
/** /**
* The current HTTP host * The current HTTP host
* @var string
*/ */
protected string $host; protected string $host;
/** /**
* Constructor * Constructor
* *
* @param ContainerInterface $container
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
*/ */
@ -48,9 +46,6 @@ class UrlGenerator extends RoutingBase {
/** /**
* Get the base url for css/js/images * Get the base url for css/js/images
*
* @param string ...$args
* @return string
*/ */
public function assetUrl(string ...$args): string public function assetUrl(string ...$args): string
{ {
@ -64,9 +59,6 @@ class UrlGenerator extends RoutingBase {
/** /**
* Generate a proper url from the path * Generate a proper url from the path
*
* @param string $path
* @return string
*/ */
public function url(string $path): string public function url(string $path): string
{ {
@ -89,6 +81,7 @@ class UrlGenerator extends RoutingBase {
$pathSegments[$i] = preg_replace('`{.*?}`', $segments[$i + 1], $pathSegments[$i] ?? ''); $pathSegments[$i] = preg_replace('`{.*?}`', $segments[$i + 1], $pathSegments[$i] ?? '');
} }
$path = implode('/', $pathSegments); $path = implode('/', $pathSegments);
$scheme = $this->config->get('secure_urls') !== FALSE ? 'https:' : 'http:'; $scheme = $this->config->get('secure_urls') !== FALSE ? 'https:' : 'http:';
@ -99,9 +92,7 @@ class UrlGenerator extends RoutingBase {
/** /**
* Full default path for the list pages * Full default path for the list pages
* *
* @param string $type
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @return string
*/ */
public function defaultUrl(string $type): string public function defaultUrl(string $type): string
{ {
@ -118,4 +109,5 @@ class UrlGenerator extends RoutingBase {
throw new InvalidArgumentException("Invalid default type: '{$type}'"); throw new InvalidArgumentException("Invalid default type: '{$type}'");
} }
} }
// End of UrlGenerator.php // End of UrlGenerator.php

View File

@ -28,7 +28,6 @@ class Util {
/** /**
* Routes that don't require a second navigation level * Routes that don't require a second navigation level
* @var array
*/ */
private static array $formPages = [ private static array $formPages = [
'edit', 'edit',
@ -54,10 +53,6 @@ class Util {
/** /**
* Absolutely equal? * Absolutely equal?
*
* @param mixed $left
* @param mixed $right
* @return bool
*/ */
public static function eq(mixed $left, mixed $right): bool public static function eq(mixed $left, mixed $right): bool
{ {
@ -66,9 +61,6 @@ class Util {
/** /**
* Set aria-current attribute based on a condition check * Set aria-current attribute based on a condition check
*
* @param bool $condition
* @return string
*/ */
public static function ariaCurrent(bool $condition): string public static function ariaCurrent(bool $condition): string
{ {
@ -80,7 +72,6 @@ class Util {
* *
* @param string $left - First item to compare * @param string $left - First item to compare
* @param string $right - Second item to compare * @param string $right - Second item to compare
* @return string
*/ */
public static function isSelected(string $left, string $right): string public static function isSelected(string $left, string $right): string
{ {
@ -92,7 +83,6 @@ class Util {
* *
* @param string $left - First item to compare * @param string $left - First item to compare
* @param string $right - Second item to compare * @param string $right - Second item to compare
* @return string
*/ */
public static function isNotSelected(string $left, string $right): string public static function isNotSelected(string $left, string $right): string
{ {
@ -104,7 +94,6 @@ class Util {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @return bool
*/ */
public function isViewPage(): bool public function isViewPage(): bool
{ {
@ -122,7 +111,6 @@ class Util {
* *
* @throws ContainerException * @throws ContainerException
* @throws NotFoundException * @throws NotFoundException
* @return bool
*/ */
public function isFormPage(): bool public function isFormPage(): bool
{ {

View File

@ -27,15 +27,11 @@ class Config implements ConfigInterface {
/** /**
* Config object * Config object
*
* @var ArrayType
*/ */
protected ArrayType $map; protected ArrayType $map;
/** /**
* Constructor * Constructor
*
* @param array $configArray
*/ */
public function __construct(array $configArray = []) public function __construct(array $configArray = [])
{ {
@ -44,9 +40,6 @@ class Config implements ConfigInterface {
/** /**
* Does the config item exist? * Does the config item exist?
*
* @param array|int|string $key
* @return bool
*/ */
public function has(array|int|string $key): bool public function has(array|int|string $key): bool
{ {
@ -57,7 +50,6 @@ class Config implements ConfigInterface {
* Get a config value * Get a config value
* *
* @param array|string|null $key * @param array|string|null $key
* @return mixed
* @throws ConfigException * @throws ConfigException
*/ */
public function get(array|string $key = NULL): mixed public function get(array|string $key = NULL): mixed
@ -72,9 +64,6 @@ class Config implements ConfigInterface {
/** /**
* Remove a config value * Remove a config value
*
* @param array|string $key
* @return void
*/ */
public function delete(array|string $key): void public function delete(array|string $key): void
{ {
@ -92,9 +81,6 @@ class Config implements ConfigInterface {
/** /**
* Set a config value * Set a config value
* *
* @param array|integer|string $key
* @param mixed $value
* @return ConfigInterface
*@throws InvalidArgumentException *@throws InvalidArgumentException
*/ */
public function set(array|int|string $key, mixed $value): ConfigInterface public function set(array|int|string $key, mixed $value): ConfigInterface
@ -115,4 +101,5 @@ class Config implements ConfigInterface {
return $this; return $this;
} }
} }
// End of config.php // End of config.php

View File

@ -22,9 +22,6 @@ namespace Aviat\Ion;
interface ConfigInterface { interface ConfigInterface {
/** /**
* Does the config item exist? * Does the config item exist?
*
* @param array|int|string $key
* @return bool
*/ */
public function has(array|int|string $key): bool; public function has(array|int|string $key): bool;
@ -32,25 +29,18 @@ interface ConfigInterface {
* Get a config value * Get a config value
* *
* @param array|string|null $key * @param array|string|null $key
* @return mixed
*/ */
public function get(array|string $key = NULL): mixed; public function get(array|string $key = NULL): mixed;
/** /**
* Set a config value * Set a config value
* *
* @param array|integer|string $key
* @param mixed $value
* @return ConfigInterface
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function set(array|int|string $key, mixed $value): self; public function set(array|int|string $key, mixed $value): self;
/** /**
* Remove a config value * Remove a config value
*
* @param array|string $key
* @return void
*/ */
public function delete(array|string $key): void; public function delete(array|string $key): void;
} }

View File

@ -92,7 +92,6 @@ class Container implements ContainerInterface {
* @param array|null $args - Optional arguments for the factory callable * @param array|null $args - Optional arguments for the factory callable
* @throws NotFoundException - No entry was found for this identifier. * @throws NotFoundException - No entry was found for this identifier.
* @throws ContainerException - Error while retrieving the entry. * @throws ContainerException - Error while retrieving the entry.
* @return mixed
*/ */
public function getNew(string $id, ?array $args = NULL): mixed public function getNew(string $id, ?array $args = NULL): mixed
{ {
@ -113,9 +112,7 @@ class Container implements ContainerInterface {
/** /**
* Add a factory to the container * Add a factory to the container
* *
* @param string $id
* @param Callable $value - a factory callable for the item * @param Callable $value - a factory callable for the item
* @return ContainerInterface
*/ */
public function set(string $id, Callable $value): ContainerInterface public function set(string $id, Callable $value): ContainerInterface
{ {
@ -126,10 +123,7 @@ class Container implements ContainerInterface {
/** /**
* Set a specific instance in the container for an existing factory * Set a specific instance in the container for an existing factory
* *
* @param string $id
* @param mixed $value
* @throws NotFoundException - No entry was found for this identifier. * @throws NotFoundException - No entry was found for this identifier.
* @return ContainerInterface
*/ */
public function setInstance(string $id, mixed $value): ContainerInterface public function setInstance(string $id, mixed $value): ContainerInterface
{ {
@ -147,7 +141,6 @@ class Container implements ContainerInterface {
* Returns false otherwise. * Returns false otherwise.
* *
* @param string $id Identifier of the entry to look for. * @param string $id Identifier of the entry to look for.
* @return boolean
*/ */
public function has(string $id): bool public function has(string $id): bool
{ {
@ -158,7 +151,6 @@ class Container implements ContainerInterface {
* Determine whether a logger channel is registered * Determine whether a logger channel is registered
* *
* @param string $id The logger channel * @param string $id The logger channel
* @return boolean
*/ */
public function hasLogger(string $id = 'default'): bool public function hasLogger(string $id = 'default'): bool
{ {
@ -168,9 +160,7 @@ class Container implements ContainerInterface {
/** /**
* Add a logger to the Container * Add a logger to the Container
* *
* @param LoggerInterface $logger
* @param string $id The logger 'channel' * @param string $id The logger 'channel'
* @return ContainerInterface
*/ */
public function setLogger(LoggerInterface $logger, string $id = 'default'): ContainerInterface public function setLogger(LoggerInterface $logger, string $id = 'default'): ContainerInterface
{ {
@ -182,7 +172,6 @@ class Container implements ContainerInterface {
* Retrieve a logger for the selected channel * Retrieve a logger for the selected channel
* *
* @param string $id The logger to retrieve * @param string $id The logger to retrieve
* @return LoggerInterface|null
*/ */
public function getLogger(string $id = 'default'): ?LoggerInterface public function getLogger(string $id = 'default'): ?LoggerInterface
{ {
@ -195,9 +184,6 @@ class Container implements ContainerInterface {
* Check if object implements ContainerAwareInterface * Check if object implements ContainerAwareInterface
* or uses ContainerAware trait, and if so, apply the container * or uses ContainerAware trait, and if so, apply the container
* to that object * to that object
*
* @param mixed $obj
* @return mixed
*/ */
private function applyContainer(mixed $obj): mixed private function applyContainer(mixed $obj): mixed
{ {
@ -220,4 +206,5 @@ class Container implements ContainerInterface {
return $obj; return $obj;
} }
} }
// End of Container.php // End of Container.php

View File

@ -23,16 +23,11 @@ trait ContainerAware {
/** /**
* Di Container * Di Container
*
* @var ContainerInterface
*/ */
protected ContainerInterface $container; protected ContainerInterface $container;
/** /**
* Set the container for the current object * Set the container for the current object
*
* @param ContainerInterface $container
* @return self
*/ */
public function setContainer(ContainerInterface $container): self public function setContainer(ContainerInterface $container): self
{ {
@ -42,12 +37,11 @@ trait ContainerAware {
/** /**
* Get the container object * Get the container object
*
* @return ContainerInterface
*/ */
public function getContainer(): ContainerInterface public function getContainer(): ContainerInterface
{ {
return $this->container; return $this->container;
} }
} }
// End of ContainerAware.php // End of ContainerAware.php

View File

@ -24,17 +24,15 @@ interface ContainerAwareInterface {
/** /**
* Set the container for the current object * Set the container for the current object
* *
* @param ContainerInterface $container
* @return void * @return void
*/ */
public function setContainer(ContainerInterface $container); public function setContainer(ContainerInterface $container);
/** /**
* Get the container object * Get the container object
*
* @return ContainerInterface
*/ */
public function getContainer(): ContainerInterface; public function getContainer(): ContainerInterface;
} }
// End of ContainerAwareInterface.php // End of ContainerAwareInterface.php

View File

@ -43,33 +43,23 @@ interface ContainerInterface {
* Returns false otherwise. * Returns false otherwise.
* *
* @param string $id Identifier of the entry to look for. * @param string $id Identifier of the entry to look for.
* @return boolean
*/ */
public function has(string $id): bool; public function has(string $id): bool;
/** /**
* Add a factory to the container * Add a factory to the container
* *
* @param string $id
* @param Callable $value - a factory callable for the item * @param Callable $value - a factory callable for the item
* @return ContainerInterface
*/ */
public function set(string $id, Callable $value): ContainerInterface; public function set(string $id, Callable $value): ContainerInterface;
/** /**
* Set a specific instance in the container for an existing factory * Set a specific instance in the container for an existing factory
*
* @param string $id
* @param mixed $value
* @return ContainerInterface
*/ */
public function setInstance(string $id, mixed $value): ContainerInterface; public function setInstance(string $id, mixed $value): ContainerInterface;
/** /**
* Get a new instance of the specified item * Get a new instance of the specified item
*
* @param string $id
* @return mixed
*/ */
public function getNew(string $id): mixed; public function getNew(string $id): mixed;
@ -77,16 +67,13 @@ interface ContainerInterface {
* Determine whether a logger channel is registered * Determine whether a logger channel is registered
* *
* @param string $id The logger channel * @param string $id The logger channel
* @return boolean
*/ */
public function hasLogger(string $id = 'default'): bool; public function hasLogger(string $id = 'default'): bool;
/** /**
* Add a logger to the Container * Add a logger to the Container
* *
* @param LoggerInterface $logger
* @param string $id The logger 'channel' * @param string $id The logger 'channel'
* @return ContainerInterface
*/ */
public function setLogger(LoggerInterface $logger, string $id = 'default'): ContainerInterface; public function setLogger(LoggerInterface $logger, string $id = 'default'): ContainerInterface;
@ -94,7 +81,6 @@ interface ContainerInterface {
* Retrieve a logger for the selected channel * Retrieve a logger for the selected channel
* *
* @param string $id The logger to retrieve * @param string $id The logger to retrieve
* @return LoggerInterface|null
*/ */
public function getLogger(string $id = 'default'): ?LoggerInterface; public function getLogger(string $id = 'default'): ?LoggerInterface;
} }

View File

@ -25,4 +25,5 @@ use Psr\Container\ContainerExceptionInterface;
class ContainerException extends Exception implements ContainerExceptionInterface { class ContainerException extends Exception implements ContainerExceptionInterface {
} }
// End of ContainerException.php // End of ContainerException.php

View File

@ -25,4 +25,5 @@ use Psr\Container\NotFoundExceptionInterface;
class NotFoundException extends ContainerException implements NotFoundExceptionInterface { class NotFoundException extends ContainerException implements NotFoundExceptionInterface {
} }
// End of NotFoundException.php // End of NotFoundException.php

View File

@ -27,7 +27,6 @@ abstract class Enum {
/** /**
* Return the list of constant values for the Enum * Return the list of constant values for the Enum
* *
* @return array
* @throws ReflectionException * @throws ReflectionException
*/ */
public static function getConstList(): array public static function getConstList(): array
@ -47,8 +46,6 @@ abstract class Enum {
/** /**
* Verify that a constant value is valid * Verify that a constant value is valid
* *
* @param mixed $key
* @return boolean
* @throws ReflectionException * @throws ReflectionException
*/ */
public static function isValid(mixed $key): bool public static function isValid(mixed $key): bool
@ -57,4 +54,5 @@ abstract class Enum {
return in_array($key, $values, TRUE); return in_array($key, $values, TRUE);
} }
} }
// End of Enum.php // End of Enum.php

View File

@ -24,9 +24,6 @@ class Event {
/** /**
* Subscribe to an event * Subscribe to an event
*
* @param string $eventName
* @param callable $handler
*/ */
public static function on(string $eventName, callable $handler): void public static function on(string $eventName, callable $handler): void
{ {
@ -40,9 +37,6 @@ class Event {
/** /**
* Fire off an event * Fire off an event
*
* @param string $eventName
* @param array $args
*/ */
public static function emit(string $eventName, array $args = []): void public static function emit(string $eventName, array $args = []): void
{ {

View File

@ -27,8 +27,6 @@ class DoubleRenderException extends LogicException {
/** /**
* DoubleRenderException constructor. * DoubleRenderException constructor.
* *
* @param string $message
* @param int $code
* @param Exception|null $previous * @param Exception|null $previous
*/ */
public function __construct(string $message = 'A view can only be rendered once, because headers can only be sent once.', int $code = 0, Exception $previous = NULL) public function __construct(string $message = 'A view can only be rendered once, because headers can only be sent once.', int $code = 0, Exception $previous = NULL)

View File

@ -29,20 +29,17 @@ class Friend {
/** /**
* Object to create a friend of * Object to create a friend of
* @var mixed
*/ */
private mixed $_friend_; private mixed $_friend_;
/** /**
* Reflection class of the object * Reflection class of the object
* @var ReflectionClass
*/ */
private ReflectionClass $_reflect_; private ReflectionClass $_reflect_;
/** /**
* Create a friend object * Create a friend object
* *
* @param mixed $obj
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws \ReflectionException * @throws \ReflectionException
*/ */
@ -59,9 +56,6 @@ class Friend {
/** /**
* Retrieve a friend's property * Retrieve a friend's property
*
* @param string $key
* @return mixed
*/ */
public function __get(string $key): mixed public function __get(string $key): mixed
{ {
@ -80,9 +74,6 @@ class Friend {
/** /**
* See if a property exists on the friend * See if a property exists on the friend
*
* @param string $name
* @return bool
*/ */
public function __isset(string $name): bool public function __isset(string $name): bool
{ {
@ -92,8 +83,6 @@ class Friend {
/** /**
* Set a friend's property * Set a friend's property
* *
* @param string $key
* @param mixed $value
* @return void * @return void
*/ */
public function __set(string $key, mixed $value) public function __set(string $key, mixed $value)
@ -112,8 +101,6 @@ class Friend {
/** /**
* Calls a protected or private method on the friend * Calls a protected or private method on the friend
* *
* @param string $method
* @param array $args
* @return mixed * @return mixed
* @throws BadMethodCallException * @throws BadMethodCallException
* @throws \ReflectionException * @throws \ReflectionException
@ -132,9 +119,6 @@ class Friend {
/** /**
* Iterates over parent classes to get a ReflectionProperty * Iterates over parent classes to get a ReflectionProperty
*
* @param string $name
* @return ReflectionProperty|null
*/ */
private function _get_property(string $name): ?ReflectionProperty private function _get_property(string $name): ?ReflectionProperty
{ {
@ -147,11 +131,13 @@ class Friend {
// Return NULL on any exception, so no further logic needed // Return NULL on any exception, so no further logic needed
// in the catch block // in the catch block
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
catch (\Exception $e) catch (\Exception)
{ {
return NULL; return NULL;
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
} }
// End of Friend.php // End of Friend.php

View File

@ -24,9 +24,7 @@ interface HttpViewInterface extends ViewInterface {
/** /**
* Set the status code of the request * Set the status code of the request
* *
* @param int $code
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self
*/ */
public function setStatusCode(int $code): self; public function setStatusCode(int $code): self;
} }

View File

@ -26,11 +26,7 @@ class Json {
/** /**
* Encode data in json format * Encode data in json format
* *
* @param mixed $data
* @param int $options
* @param int $depth
* @throws JsonException * @throws JsonException
* @return string
*/ */
public static function encode(mixed $data, int $options = 0, int $depth = 512): string public static function encode(mixed $data, int $options = 0, int $depth = 512): string
{ {
@ -43,12 +39,9 @@ class Json {
/** /**
* Encode data in json format and save to a file * Encode data in json format and save to a file
* *
* @param string $filename
* @param mixed $data
* @param int $jsonOptions - Options to pass to json_encode * @param int $jsonOptions - Options to pass to json_encode
* @param int $fileOptions - Options to pass to file_get_contents * @param int $fileOptions - Options to pass to file_get_contents
* @throws JsonException * @throws JsonException
* @return bool
*/ */
public static function encodeFile(string $filename, mixed $data, int $jsonOptions = 0, int $fileOptions = 0): bool public static function encodeFile(string $filename, mixed $data, int $jsonOptions = 0, int $fileOptions = 0): bool
{ {
@ -61,12 +54,7 @@ class Json {
/** /**
* Decode data from json * Decode data from json
* *
* @param string|null $json
* @param bool $assoc
* @param int $depth
* @param int $options
* @throws JsonException * @throws JsonException
* @return mixed
*/ */
public static function decode(?string $json, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed public static function decode(?string $json, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed
{ {
@ -85,12 +73,7 @@ class Json {
/** /**
* Decode json data loaded from the passed filename * Decode json data loaded from the passed filename
* *
* @param string $filename
* @param bool $assoc
* @param int $depth
* @param int $options
* @throws JsonException * @throws JsonException
* @return mixed
*/ */
public static function decodeFile(string $filename, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed public static function decodeFile(string $filename, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed
{ {
@ -103,9 +86,7 @@ class Json {
/** /**
* Determines whether a string is valid json * Determines whether a string is valid json
* *
* @param string $string
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return boolean
*/ */
public static function isJson(string $string): bool public static function isJson(string $string): bool
{ {
@ -116,7 +97,6 @@ class Json {
* Call the json error functions to check for errors encoding/decoding * Call the json error functions to check for errors encoding/decoding
* *
* @throws JsonException * @throws JsonException
* @return void
*/ */
protected static function check_json_error(): void protected static function check_json_error(): void
{ {
@ -141,4 +121,5 @@ class Json {
} }
} }
} }
// End of JSON.php // End of JSON.php

View File

@ -24,4 +24,5 @@ use InvalidArgumentException;
class JsonException extends InvalidArgumentException { class JsonException extends InvalidArgumentException {
} }
// End of JsonException.php // End of JsonException.php

View File

@ -21,4 +21,5 @@ namespace Aviat\Ion;
*/ */
class Model { class Model {
} }
// End of Model.php // End of Model.php

View File

@ -24,17 +24,11 @@ use BadMethodCallException;
abstract class AbstractTransformer implements TransformerInterface { abstract class AbstractTransformer implements TransformerInterface {
/** /**
* Mutate the data structure * Mutate the data structure
*
* @param array|object $item
* @return mixed
*/ */
abstract public function transform(array|object $item): mixed; abstract public function transform(array|object $item): mixed;
/** /**
* Transform a set of structures * Transform a set of structures
*
* @param iterable $collection
* @return array
*/ */
public function transformCollection(iterable $collection): array public function transformCollection(iterable $collection): array
{ {
@ -48,7 +42,6 @@ abstract class AbstractTransformer implements TransformerInterface {
* Requires an 'untransform' method in the extending class * Requires an 'untransform' method in the extending class
* *
* @param iterable $collection * @param iterable $collection
* @return array
*/ */
public function untransformCollection(iterable $collection): array public function untransformCollection(iterable $collection): array
{ {
@ -61,4 +54,5 @@ abstract class AbstractTransformer implements TransformerInterface {
return array_map([$this, 'untransform'], $list); return array_map([$this, 'untransform'], $list);
} }
} }
// End of AbstractTransformer.php // End of AbstractTransformer.php

View File

@ -23,9 +23,6 @@ interface TransformerInterface {
/** /**
* Mutate the data structure * Mutate the data structure
*
* @param array|object $item
* @return mixed
*/ */
public function transform(array|object $item): mixed; public function transform(array|object $item): mixed;
} }

View File

@ -29,15 +29,11 @@ class ArrayType {
/** /**
* The current array * The current array
*
* @var array
*/ */
protected array $arr; protected array $arr = [];
/** /**
* Map generated methods to their native implementations * Map generated methods to their native implementations
*
* @var array
*/ */
protected array $nativeMethods = [ protected array $nativeMethods = [
'chunk' => 'array_chunk', 'chunk' => 'array_chunk',
@ -61,8 +57,6 @@ class ArrayType {
/** /**
* Native methods that modify the passed in array * Native methods that modify the passed in array
*
* @var array
*/ */
protected array $nativeInPlaceMethods = [ protected array $nativeInPlaceMethods = [
'shuffle' => 'shuffle', 'shuffle' => 'shuffle',
@ -74,9 +68,6 @@ class ArrayType {
/** /**
* Create an ArrayType wrapper class from an array * Create an ArrayType wrapper class from an array
*
* @param array $arr
* @return ArrayType
*/ */
public static function from(array $arr): ArrayType public static function from(array $arr): ArrayType
{ {
@ -85,8 +76,6 @@ class ArrayType {
/** /**
* Create an ArrayType wrapper class * Create an ArrayType wrapper class
*
* @param array $arr
*/ */
private function __construct(array &$arr) private function __construct(array &$arr)
{ {
@ -96,9 +85,6 @@ class ArrayType {
/** /**
* Call one of the dynamically created methods * Call one of the dynamically created methods
* *
* @param string $method
* @param array $args
* @return mixed
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function __call(string $method, array $args): mixed public function __call(string $method, array $args): mixed
@ -124,9 +110,6 @@ class ArrayType {
/** /**
* Does the passed key exist in the current array? * Does the passed key exist in the current array?
*
* @param int|string|array $key
* @return bool
*/ */
public function hasKey(int|string|array $key): bool public function hasKey(int|string|array $key): bool
{ {
@ -153,10 +136,7 @@ class ArrayType {
/** /**
* Fill an array with the specified value * Fill an array with the specified value
* *
* @param int $start_index * @return mixed[]
* @param int $num
* @param mixed $value
* @return array
*/ */
public function fill(int $start_index, int $num, mixed $value): array public function fill(int $start_index, int $num, mixed $value): array
{ {
@ -166,8 +146,7 @@ class ArrayType {
/** /**
* Call a callback on each item of the array * Call a callback on each item of the array
* *
* @param callable $callback * @return mixed[]
* @return array
*/ */
public function map(callable $callback): array public function map(callable $callback): array
{ {
@ -176,10 +155,6 @@ class ArrayType {
/** /**
* Find an array key by its associated value * Find an array key by its associated value
*
* @param mixed $value
* @param bool $strict
* @return false|integer|string|null
*/ */
public function search(mixed $value, bool $strict = TRUE): int|string|false|null public function search(mixed $value, bool $strict = TRUE): int|string|false|null
{ {
@ -188,10 +163,6 @@ class ArrayType {
/** /**
* Determine if the array has the passed value * Determine if the array has the passed value
*
* @param mixed $value
* @param bool $strict
* @return bool
*/ */
public function has(mixed $value, bool $strict = TRUE): bool public function has(mixed $value, bool $strict = TRUE): bool
{ {
@ -200,9 +171,6 @@ class ArrayType {
/** /**
* Return the array, or a key * Return the array, or a key
*
* @param string|integer|null $key
* @return mixed
*/ */
public function &get(string|int|null $key = NULL): mixed public function &get(string|int|null $key = NULL): mixed
{ {
@ -224,10 +192,6 @@ class ArrayType {
/** /**
* Set a key on the array * Set a key on the array
*
* @param mixed $key
* @param mixed $value
* @return ArrayType
*/ */
public function set(mixed $key, mixed $value): ArrayType public function set(mixed $key, mixed $value): ArrayType
{ {
@ -242,7 +206,6 @@ class ArrayType {
* $val = $arr->getDeepKey([0, 'data', 'foo']); * $val = $arr->getDeepKey([0, 'data', 'foo']);
* // returns 'bar' * // returns 'bar'
* @param array $key An array of keys of the array * @param array $key An array of keys of the array
* @return mixed
*/ */
public function &getDeepKey(array $key): mixed public function &getDeepKey(array $key): mixed
{ {
@ -259,6 +222,7 @@ class ArrayType {
$pos = NULL; $pos = NULL;
return $pos; return $pos;
} }
$pos =& $pos[$level]; $pos =& $pos[$level];
} }
@ -269,9 +233,7 @@ class ArrayType {
* Sets the value of an arbitrarily deep key in the array * Sets the value of an arbitrarily deep key in the array
* and returns the modified array * and returns the modified array
* *
* @param array $key * @return mixed[]
* @param mixed $value
* @return array
*/ */
public function setDeepKey(array $key, mixed $value): array public function setDeepKey(array $key, mixed $value): array
{ {
@ -286,6 +248,7 @@ class ArrayType {
$pos = []; $pos = [];
$pos[$level] = []; $pos[$level] = [];
} }
$pos =& $pos[$level]; $pos =& $pos[$level];
} }
@ -294,4 +257,5 @@ class ArrayType {
return $this->arr; return $this->arr;
} }
} }
// End of ArrayType.php // End of ArrayType.php

View File

@ -25,9 +25,6 @@ class StringType extends Stringy {
/** /**
* Alias for `create` static constructor * Alias for `create` static constructor
*
* @param string $str
* @return self
*/ */
public static function from(string $str): self public static function from(string $str): self
{ {
@ -38,9 +35,7 @@ class StringType extends Stringy {
* See if two strings match, despite being delimited differently, * See if two strings match, despite being delimited differently,
* such as camelCase, PascalCase, kebab-case, or snake_case. * such as camelCase, PascalCase, kebab-case, or snake_case.
* *
* @param string $strToMatch
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return boolean
*/ */
public function fuzzyCaseMatch(string $strToMatch): bool public function fuzzyCaseMatch(string $strToMatch): bool
{ {
@ -50,4 +45,5 @@ class StringType extends Stringy {
return $firstStr === $secondStr; return $firstStr === $secondStr;
} }
} }
// End of StringType.php // End of StringType.php

View File

@ -29,15 +29,11 @@ class HtmlView extends HttpView {
/** /**
* Response mime type * Response mime type
*
* @var string
*/ */
protected string $contentType = 'text/html'; protected string $contentType = 'text/html';
/** /**
* Create the Html View * Create the Html View
*
* @param ContainerInterface $container
*/ */
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
@ -50,9 +46,6 @@ class HtmlView extends HttpView {
/** /**
* Render a basic html Template * Render a basic html Template
* *
* @param string $path
* @param array $data
* @return string
* @throws \Throwable * @throws \Throwable
*/ */
public function renderTemplate(string $path, array $data): string public function renderTemplate(string $path, array $data): string
@ -74,4 +67,5 @@ class HtmlView extends HttpView {
return preg_replace('/>\s+</', '> <', $buffer) ?? $buffer; return preg_replace('/>\s+</', '> <', $buffer) ?? $buffer;
} }
} }
// End of HtmlView.php // End of HtmlView.php

View File

@ -74,7 +74,6 @@ class HttpView implements HttpViewInterface{
* and any attempts to call again will result in a DoubleRenderException * and any attempts to call again will result in a DoubleRenderException
* *
* @throws DoubleRenderException * @throws DoubleRenderException
* @return string
*/ */
public function __toString(): string public function __toString(): string
{ {
@ -82,6 +81,7 @@ class HttpView implements HttpViewInterface{
{ {
throw new DoubleRenderException(); throw new DoubleRenderException();
} }
$this->hasRendered = TRUE; $this->hasRendered = TRUE;
return $this->getOutput(); return $this->getOutput();
} }
@ -89,9 +89,7 @@ class HttpView implements HttpViewInterface{
/** /**
* Add an http header * Add an http header
* *
* @param string $name
* @param string|string[] $value * @param string|string[] $value
* @return HttpView
*/ */
public function addHeader(string $name, array|string $value): self public function addHeader(string $name, array|string $value): self
{ {
@ -101,9 +99,6 @@ class HttpView implements HttpViewInterface{
/** /**
* Set the output string * Set the output string
*
* @param mixed $string
* @return HttpViewInterface
*/ */
public function setOutput(mixed $string): HttpViewInterface public function setOutput(mixed $string): HttpViewInterface
{ {
@ -115,9 +110,6 @@ class HttpView implements HttpViewInterface{
/** /**
* Append additional output. * Append additional output.
*
* @param string $string
* @return HttpViewInterface
*/ */
public function appendOutput(string $string): HttpViewInterface public function appendOutput(string $string): HttpViewInterface
{ {
@ -127,8 +119,6 @@ class HttpView implements HttpViewInterface{
/** /**
* Get the current output as a string. Does not * Get the current output as a string. Does not
* render view or send headers. * render view or send headers.
*
* @return string
*/ */
public function getOutput(): string public function getOutput(): string
{ {
@ -138,11 +128,7 @@ class HttpView implements HttpViewInterface{
/** /**
* Do a redirect * Do a redirect
* *
* @param string $url
* @param int $code
* @param array $headers
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self
*/ */
public function redirect(string $url, int $code = 302, array $headers = []): self public function redirect(string $url, int $code = 302, array $headers = []): self
{ {
@ -153,9 +139,7 @@ class HttpView implements HttpViewInterface{
/** /**
* Set the status code of the request * Set the status code of the request
* *
* @param int $code
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return HttpView
*/ */
public function setStatusCode(int $code): self public function setStatusCode(int $code): self
{ {
@ -170,7 +154,6 @@ class HttpView implements HttpViewInterface{
* *
* @throws DoubleRenderException * @throws DoubleRenderException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void
*/ */
public function send(): void public function send(): void
{ {
@ -183,7 +166,6 @@ class HttpView implements HttpViewInterface{
* @codeCoverageIgnore * @codeCoverageIgnore
* @throws DoubleRenderException * @throws DoubleRenderException
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return void
*/ */
protected function output(): void protected function output(): void
{ {

Some files were not shown because too many files have changed in this diff Show More