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

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
php:
- 8.0
- 8.1
- nightly
script:

View File

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

View File

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

View File

@ -46,13 +46,6 @@
value="<?= $item['chapters']['read'] ?>"/> / <?= $item['chapters']['total'] ?>
</td>
</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>
<td><label for="rereading_flag">Rereading?</label></td>
<td>

View File

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

View File

@ -25,7 +25,7 @@ setlocale(LC_CTYPE, 'en_US');
// Load composer autoloader
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::enable(Debugger::DEVELOPMENT, __DIR__ . '/app/logs');

View File

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

View File

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

View File

@ -123,7 +123,7 @@ final class Auth {
/**
* Retrieve the authentication token from the session
*
* @return string
* @return string|null
*/
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,
// 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;
}
@ -104,7 +104,7 @@ final class AnimeTransformer extends AbstractTransformer {
'id' => $person['id'],
'name' => $name,
'image' => [
'original' => $person['image']['original']['url'],
'original' => $person['image']['original']['url'] ?? '',
],
'slug' => $person['slug'],
];

View File

@ -105,7 +105,7 @@ final class CharacterTransformer extends AbstractTransformer {
];
// 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))
{

View File

@ -21,7 +21,7 @@ use Aviat\AnimeClient\Types\MangaPage;
use Aviat\Ion\Transformer\AbstractTransformer;
/**
* Transformer for anime description page
* Transformer for manga description page
*/
final class MangaTransformer extends AbstractTransformer {
@ -87,6 +87,13 @@ final class MangaTransformer extends AbstractTransformer {
$role = $staffing['role'];
$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))
{
$staff[$role] = [];
@ -97,7 +104,7 @@ final class MangaTransformer extends AbstractTransformer {
'slug' => $person['slug'],
'name' => $name,
'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)
{
if (empty($staffing['media']))
{
continue;
}
$media = $staffing['media'];
$role = $staffing['role'];
$title = $media['titles']['canonical'];
@ -79,7 +84,7 @@ final class PersonTransformer extends AbstractTransformer {
'title' => $title,
'titles' => array_merge([$title], Kitsu::getFilteredTitles($media['titles'])),
'image' => [
'original' => $media['posterImage']['views'][1]['url'],
'original' => $media['posterImage']['views'][1]['url'] ?? '',
],
'slug' => $media['slug'],
];
@ -120,7 +125,7 @@ final class PersonTransformer extends AbstractTransformer {
'id' => $character['id'],
'slug' => $character['slug'],
'image' => [
'original' => $character['image']['original']['url'],
'original' => $character['image']['original']['url'] ?? '',
],
'canonicalName' => $character['names']['canonical'],
],

View File

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

View File

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