From 6b6c37f015f620c3dda93d2ce8a6941de0412f4b Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 3 Feb 2021 09:46:36 -0500 Subject: [PATCH] Move to PHP 8 --- composer.json | 4 ++-- src/AnimeClient/API/Kitsu/schema.graphql | 25 ++++++++++++++------- src/AnimeClient/AnimeClient.php | 2 +- src/AnimeClient/Command/BaseCommand.php | 14 +++++++----- src/AnimeClient/Command/ClearThumbnails.php | 2 +- src/AnimeClient/Controller/Anime.php | 8 ++----- src/AnimeClient/Model/Settings.php | 2 +- src/AnimeClient/Types/Config/Anilist.php | 5 ++++- 8 files changed, 37 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index aae5227d..315f2f16 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "config": { "lock": false, "platform": { - "php": "7.4" + "php": "8" } }, "require": { @@ -53,7 +53,7 @@ "laminas/laminas-httphandlerrunner": "^1.1.0", "maximebf/consolekit": "^1.0.3", "monolog/monolog": "^2.0.2", - "php": "^7.4 || ~8.0.0", + "php": "^8.0.0", "psr/container": "^1.0.0", "psr/http-message": "^1.0.1", "psr/log": "^1.1.3", diff --git a/src/AnimeClient/API/Kitsu/schema.graphql b/src/AnimeClient/API/Kitsu/schema.graphql index a86dacf5..3d572188 100644 --- a/src/AnimeClient/API/Kitsu/schema.graphql +++ b/src/AnimeClient/API/Kitsu/schema.graphql @@ -152,8 +152,6 @@ interface Media { "Returns the last _n_ elements from the list." last: Int ): MediaReactionConnection! - "The season this was released in" - season: ReleaseSeasonEnum "Whether the media is Safe-for-Work" sfw: Boolean! "The URL-friendly identifier of this media" @@ -1256,8 +1254,6 @@ type Manga implements Media & WithTimestamps { "Returns the last _n_ elements from the list." last: Int ): MediaReactionConnection! - "The season this was released in" - season: ReleaseSeasonEnum "Whether the media is Safe-for-Work" sfw: Boolean! "The URL-friendly identifier of this media" @@ -1475,14 +1471,14 @@ type MediaEdge { "The role a company played in the creation or localization of a media" type MediaProduction implements WithTimestamps { + "The production company" + company: Producer! createdAt: ISO8601DateTime! id: ID! "The media" media: Media! - "The producer" - person: Producer! "The role this company played" - role: String! + role: MediaProductionRoleEnum! updatedAt: ISO8601DateTime! } @@ -1997,6 +1993,8 @@ type Query { findPersonById(id: ID!): Person "Find a single Person by Slug" findPersonBySlug(slug: String!): Person + "Find a single Post by ID" + findPostById(id: ID!): Post "Find a single User by ID" findProfileById(id: ID!): Profile "Find a single User by Slug" @@ -2112,7 +2110,7 @@ type Query { last: Int, title: String! ): MangaConnection! - "Search for any media (Anime, Manga) by title using Algolia. The most relevant results will be at the top." + "Search for any media (Anime, Manga) by title using Algolia. If no media_type is supplied, it will search for both. The most relevant results will be at the top." searchMediaByTitle( "Returns the elements in the list that come after the specified cursor." after: String, @@ -2122,6 +2120,8 @@ type Query { first: Int, "Returns the last _n_ elements from the list." last: Int, + "Dynamically choose a specific media_type. If left blank, it will return results for both." + mediaType: MediaTypeEnum, title: String! ): MediaConnection! "Search for User by username using Algolia. The most relevant results will be at the top." @@ -2217,6 +2217,8 @@ type QuoteLineEdge { type Session { "The account associated with this session" account: Account + "Single sign-on token for Nolt" + noltToken: String! "The profile associated with this session" profile: Profile } @@ -2539,6 +2541,13 @@ enum MappingItemEnum { PRODUCER } +enum MediaProductionRoleEnum { + LICENSOR + PRODUCER + SERIALIZATION + STUDIO +} + "これはアニメやマンガです" enum MediaTypeEnum { ANIME diff --git a/src/AnimeClient/AnimeClient.php b/src/AnimeClient/AnimeClient.php index 72f05bf8..f67bdbdc 100644 --- a/src/AnimeClient/AnimeClient.php +++ b/src/AnimeClient/AnimeClient.php @@ -237,7 +237,7 @@ function getApiClient (): HttpClient * @return Response * @throws Throwable */ -function getResponse ($request): Response +function getResponse (Request|string $request): Response { $client = getApiClient(); diff --git a/src/AnimeClient/Command/BaseCommand.php b/src/AnimeClient/Command/BaseCommand.php index e3cdf717..af695a0c 100644 --- a/src/AnimeClient/Command/BaseCommand.php +++ b/src/AnimeClient/Command/BaseCommand.php @@ -17,6 +17,10 @@ namespace Aviat\AnimeClient\Command; use Monolog\Formatter\JsonFormatter; + +use function Aviat\Ion\_dir; +use const Aviat\AnimeClient\SRC_DIR; + use function Aviat\AnimeClient\loadConfig; use function Aviat\AnimeClient\loadTomlFile; @@ -108,14 +112,14 @@ abstract class BaseCommand extends Command { */ public function setupContainer(): ContainerInterface { - $APP_DIR = realpath(__DIR__ . '/../../../app'); - $APPCONF_DIR = realpath("{$APP_DIR}/appConf/"); - $CONF_DIR = realpath("{$APP_DIR}/config/"); - $baseConfig = require $APPCONF_DIR . '/base_config.php'; + $APP_DIR = _dir(dirname(SRC_DIR), 'app'); + $APPCONF_DIR = realpath(_dir($APP_DIR, 'appConf')); + $CONF_DIR = realpath(_dir($APP_DIR, 'config')); + $baseConfig = require _dir($APPCONF_DIR, 'base_config.php'); $config = loadConfig($CONF_DIR); - $overrideFile = $CONF_DIR . '/admin-override.toml'; + $overrideFile = _dir($CONF_DIR, 'admin-override.toml'); $overrideConfig = file_exists($overrideFile) ? loadTomlFile($overrideFile) : []; diff --git a/src/AnimeClient/Command/ClearThumbnails.php b/src/AnimeClient/Command/ClearThumbnails.php index e8a5e5c1..965ca757 100644 --- a/src/AnimeClient/Command/ClearThumbnails.php +++ b/src/AnimeClient/Command/ClearThumbnails.php @@ -29,7 +29,7 @@ class ClearThumbnails extends BaseCommand { private function clearThumbs(): void { - $imgDir = realpath(__DIR__ . '/../../public/images'); + $imgDir = dirname(__DIR__, 3) . '/public/images'; $paths = [ 'anime/*.jpg', diff --git a/src/AnimeClient/Controller/Anime.php b/src/AnimeClient/Controller/Anime.php index 3aa2f4f4..ac0c3dd6 100644 --- a/src/AnimeClient/Controller/Anime.php +++ b/src/AnimeClient/Controller/Anime.php @@ -138,8 +138,6 @@ final class Anime extends BaseController { /** * Add an anime to the list * - * @throws ContainerException - * @throws NotFoundException * @throws Throwable * @return void */ @@ -215,8 +213,6 @@ final class Anime extends BaseController { /** * Update an anime item via a form submission * - * @throws ContainerException - * @throws NotFoundException * @throws Throwable * @return void */ @@ -338,7 +334,7 @@ final class Anime extends BaseController { 'data' => $data, ]); } - catch (TypeError $e) + catch (TypeError) { $this->notFound( $this->config->get('whose_list') . @@ -376,7 +372,7 @@ final class Anime extends BaseController { 'data' => $data, ]); } - catch (TypeError $e) + catch (TypeError) { $this->notFound( $this->config->get('whose_list') . diff --git a/src/AnimeClient/Model/Settings.php b/src/AnimeClient/Model/Settings.php index 0bc70b75..9848f703 100644 --- a/src/AnimeClient/Model/Settings.php +++ b/src/AnimeClient/Model/Settings.php @@ -206,7 +206,7 @@ final class Settings { return FALSE; } - $savePath = realpath(_dir(__DIR__, '..', '..', '..', 'app', 'config')); + $savePath = _dir(dirname(__DIR__, 3), 'app', 'config'); $saveFile = _dir($savePath, 'admin-override.toml'); $saved = file_put_contents($saveFile, arrayToToml($settings)); diff --git a/src/AnimeClient/Types/Config/Anilist.php b/src/AnimeClient/Types/Config/Anilist.php index e713cc62..263cba06 100644 --- a/src/AnimeClient/Types/Config/Anilist.php +++ b/src/AnimeClient/Types/Config/Anilist.php @@ -19,7 +19,10 @@ namespace Aviat\AnimeClient\Types\Config; use Aviat\AnimeClient\Types\AbstractType; class Anilist extends AbstractType { - public bool $enabled = FALSE; + /** + * @var bool|string + */ + public $enabled = FALSE; public ?string $client_id;