Lots of little code fixes, hides notices shown on PHP 8.1
timw4mail/HummingBirdAnimeClient/pipeline/head There was a failure building this commit Details

This commit is contained in:
Timothy Warren 2021-12-02 16:06:34 -05:00
parent 5528589230
commit f9850be35c
15 changed files with 31 additions and 29 deletions

View File

@ -4,6 +4,8 @@ install:
- composer install --ignore-platform-reqs - composer install --ignore-platform-reqs
php: php:
- 8.0
- 8.1
- nightly - nightly
script: script:

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
## Version 5.3
* Updated to support PHP 8.1
## Version 5.2 ## Version 5.2
* Updated PHP requirement to 8 * Updated PHP requirement to 8

View File

@ -2,7 +2,6 @@
<?php if ($auth->isAuthenticated()): ?> <?php if ($auth->isAuthenticated()): ?>
<div class="edit-buttons" hidden> <div class="edit-buttons" hidden>
<button class="plus-one-chapter">+1 Chapter</button> <button class="plus-one-chapter">+1 Chapter</button>
<?php /* <button class="plus-one-volume">+1 Volume</button> */ ?>
</div> </div>
<?php endif ?> <?php endif ?>
<?= $helper->picture("images/manga/{$item['manga']['id']}.webp") ?> <?= $helper->picture("images/manga/{$item['manga']['id']}.webp") ?>
@ -64,11 +63,6 @@
Chapters: <span class="chapters_read"><?= $item['chapters']['read'] ?></span> / Chapters: <span class="chapters_read"><?= $item['chapters']['read'] ?></span> /
<span class="chapter_count"><?= $item['chapters']['total'] ?></span> <span class="chapter_count"><?= $item['chapters']['total'] ?></span>
</div> </div>
<?php /* </div>
<div class="row"> */ ?>
<div class="volume_completion">
Volumes: <span class="volume_count"><?= $item['volumes']['total'] ?></span>
</div>
</div> </div>
</div> </div>
</article> </article>

View File

@ -46,13 +46,6 @@
value="<?= $item['chapters']['read'] ?>"/> / <?= $item['chapters']['total'] ?> value="<?= $item['chapters']['read'] ?>"/> / <?= $item['chapters']['total'] ?>
</td> </td>
</tr> </tr>
<tr>
<td><label for="volumes_read">Volumes Read</label></td>
<td>
<?php /*<input type="number" disabled="disabled" min="0" name="volumes_read" id="volumes_read" value="" /> */ ?>
- / <?= $item['volumes']['total'] ?>
</td>
</tr>
<tr> <tr>
<td><label for="rereading_flag">Rereading?</label></td> <td><label for="rereading_flag">Rereading?</label></td>
<td> <td>

View File

@ -22,7 +22,6 @@
<th>Title</th> <th>Title</th>
<th>Rating</th> <th>Rating</th>
<th>Completed Chapters</th> <th>Completed Chapters</th>
<th># of Volumes</th>
<th>Attributes</th> <th>Attributes</th>
<th>Type</th> <th>Type</th>
</tr> </tr>
@ -49,7 +48,6 @@
</td> </td>
<td><?= $item['user_rating'] ?> / 10</td> <td><?= $item['user_rating'] ?> / 10</td>
<td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td> <td><?= $item['chapters']['read'] ?> / <?= $item['chapters']['total'] ?></td>
<td><?= $item['volumes']['total'] ?></td>
<td> <td>
<ul> <ul>
<?php if ($item['reread'] == 1): ?> <?php if ($item['reread'] == 1): ?>

View File

@ -25,7 +25,7 @@ setlocale(LC_CTYPE, 'en_US');
// Load composer autoloader // Load composer autoloader
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';
Debugger::$strictMode = true; Debugger::$strictMode = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; // all errors except deprecated notices
Debugger::$showBar = false; Debugger::$showBar = false;
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/app/logs'); Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/app/logs');

View File

@ -318,7 +318,7 @@ abstract class APIRequestBuilder {
* @param string $type * @param string $type
* @return void * @return void
*/ */
private function resetState(?string $url, $type = 'GET'): void private function resetState(?string $url, string $type = 'GET'): void
{ {
$requestUrl = $url ?: $this->baseUrl; $requestUrl = $url ?: $this->baseUrl;

View File

@ -33,7 +33,7 @@ trait CacheTrait {
* Inject the cache object * Inject the cache object
* *
* @param CacheInterface $cache * @param CacheInterface $cache
* @return $this * @return self
*/ */
public function setCache(CacheInterface $cache): self public function setCache(CacheInterface $cache): self
{ {

View File

@ -123,7 +123,7 @@ final class Auth {
/** /**
* Retrieve the authentication token from the session * Retrieve the authentication token from the session
* *
* @return string * @return string|null
*/ */
public function getAuthToken(): ?string public function getAuthToken(): ?string
{ {

View File

@ -90,7 +90,7 @@ final class AnimeTransformer extends AbstractTransformer {
// If this person object is so broken as to not have a proper image object, // If this person object is so broken as to not have a proper image object,
// just skip it. No point in showing a role with nothing in it. // just skip it. No point in showing a role with nothing in it.
if ($person === null || $person['id'] === null || $person['image'] === null || $person['image']['original'] === null) if ($person === null || $person['id'] === null || $person['image'] === null)
{ {
continue; continue;
} }
@ -104,7 +104,7 @@ final class AnimeTransformer extends AbstractTransformer {
'id' => $person['id'], 'id' => $person['id'],
'name' => $name, 'name' => $name,
'image' => [ 'image' => [
'original' => $person['image']['original']['url'], 'original' => $person['image']['original']['url'] ?? '',
], ],
'slug' => $person['slug'], 'slug' => $person['slug'],
]; ];

View File

@ -105,7 +105,7 @@ final class CharacterTransformer extends AbstractTransformer {
]; ];
// And now, reorganize voice actor relationships // And now, reorganize voice actor relationships
$rawVoices = array_filter($data, fn($item) => count((array)$item['voices']['nodes']) > 0); $rawVoices = array_filter($data, fn($item) => (! empty($item['voices'])) && count((array)$item['voices']['nodes']) > 0);
if (empty($rawVoices)) if (empty($rawVoices))
{ {

View File

@ -21,7 +21,7 @@ use Aviat\AnimeClient\Types\MangaPage;
use Aviat\Ion\Transformer\AbstractTransformer; use Aviat\Ion\Transformer\AbstractTransformer;
/** /**
* Transformer for anime description page * Transformer for manga description page
*/ */
final class MangaTransformer extends AbstractTransformer { final class MangaTransformer extends AbstractTransformer {
@ -87,6 +87,13 @@ final class MangaTransformer extends AbstractTransformer {
$role = $staffing['role']; $role = $staffing['role'];
$name = $person['names']['localized'][$person['names']['canonical']]; $name = $person['names']['localized'][$person['names']['canonical']];
// If this person object is so broken as to not have a proper image object,
// just skip it. No point in showing a role with nothing in it.
if ($person === null || $person['id'] === null || $person['image'] === null)
{
continue;
}
if ( ! array_key_exists($role, $staff)) if ( ! array_key_exists($role, $staff))
{ {
$staff[$role] = []; $staff[$role] = [];
@ -97,7 +104,7 @@ final class MangaTransformer extends AbstractTransformer {
'slug' => $person['slug'], 'slug' => $person['slug'],
'name' => $name, 'name' => $name,
'image' => [ 'image' => [
'original' => $person['image']['original']['url'], 'original' => $person['image']['original']['url'] ?? '',
], ],
]; ];

View File

@ -69,6 +69,11 @@ final class PersonTransformer extends AbstractTransformer {
foreach ($data['mediaStaff']['nodes'] as $staffing) foreach ($data['mediaStaff']['nodes'] as $staffing)
{ {
if (empty($staffing['media']))
{
continue;
}
$media = $staffing['media']; $media = $staffing['media'];
$role = $staffing['role']; $role = $staffing['role'];
$title = $media['titles']['canonical']; $title = $media['titles']['canonical'];
@ -79,7 +84,7 @@ final class PersonTransformer extends AbstractTransformer {
'title' => $title, 'title' => $title,
'titles' => array_merge([$title], Kitsu::getFilteredTitles($media['titles'])), 'titles' => array_merge([$title], Kitsu::getFilteredTitles($media['titles'])),
'image' => [ 'image' => [
'original' => $media['posterImage']['views'][1]['url'], 'original' => $media['posterImage']['views'][1]['url'] ?? '',
], ],
'slug' => $media['slug'], 'slug' => $media['slug'],
]; ];
@ -120,7 +125,7 @@ final class PersonTransformer extends AbstractTransformer {
'id' => $character['id'], 'id' => $character['id'],
'slug' => $character['slug'], 'slug' => $character['slug'],
'image' => [ 'image' => [
'original' => $character['image']['original']['url'], 'original' => $character['image']['original']['url'] ?? '',
], ],
'canonicalName' => $character['names']['canonical'], 'canonicalName' => $character['names']['canonical'],
], ],

View File

@ -39,10 +39,10 @@ final class ParallelAPIRequest {
* Add a request * Add a request
* *
* @param string|Request $request * @param string|Request $request
* @param string|number $key * @param string|int|null $key
* @return self * @return self
*/ */
public function addRequest($request, $key = NULL): self public function addRequest(string|Request $request, string|int|null $key = NULL): self
{ {
if ($key !== NULL) if ($key !== NULL)
{ {

View File

@ -335,7 +335,7 @@ function createPlaceholderImage (string $path, ?int $width, ?int $height, $text
$fontSize = 10; $fontSize = 10;
$fontWidth = imagefontwidth($fontSize); $fontWidth = imagefontwidth($fontSize);
$fontHeight = imagefontheight($fontSize); $fontHeight = imagefontheight($fontSize);
$length = \strlen($text); $length = strlen($text);
$textWidth = $length * $fontWidth; $textWidth = $length * $fontWidth;
$fxPos = (int) ceil((imagesx($img) - $textWidth) / 2); $fxPos = (int) ceil((imagesx($img) - $textWidth) / 2);
$fyPos = (int) ceil((imagesy($img) - $fontHeight) / 2); $fyPos = (int) ceil((imagesy($img) - $fontHeight) / 2);