Browse Source

Lots of little code fixes, hides notices shown on PHP 8.1

pull/41/head
Timothy Warren 6 months ago
parent
commit
f9850be35c
  1. 2
      .travis.yml
  2. 3
      CHANGELOG.md
  3. 6
      app/templates/manga-cover.php
  4. 7
      app/views/manga/edit.php
  5. 2
      app/views/manga/list.php
  6. 2
      index.php
  7. 2
      src/AnimeClient/API/APIRequestBuilder.php
  8. 2
      src/AnimeClient/API/CacheTrait.php
  9. 2
      src/AnimeClient/API/Kitsu/Auth.php
  10. 4
      src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php
  11. 2
      src/AnimeClient/API/Kitsu/Transformer/CharacterTransformer.php
  12. 11
      src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php
  13. 9
      src/AnimeClient/API/Kitsu/Transformer/PersonTransformer.php
  14. 4
      src/AnimeClient/API/ParallelAPIRequest.php
  15. 2
      src/AnimeClient/AnimeClient.php

2
.travis.yml

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

3
CHANGELOG.md

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

6
app/templates/manga-cover.php

@ -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>

7
app/views/manga/edit.php

@ -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>

2
app/views/manga/list.php

@ -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): ?>

2
index.php

@ -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');

2
src/AnimeClient/API/APIRequestBuilder.php

@ -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;

2
src/AnimeClient/API/CacheTrait.php

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

2
src/AnimeClient/API/Kitsu/Auth.php

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

4
src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php

@ -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'],
];

2
src/AnimeClient/API/Kitsu/Transformer/CharacterTransformer.php

@ -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))
{

11
src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php

@ -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'] ?? '',
],
];

9
src/AnimeClient/API/Kitsu/Transformer/PersonTransformer.php

@ -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'],
],

4
src/AnimeClient/API/ParallelAPIRequest.php

@ -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)
{

2
src/AnimeClient/AnimeClient.php

@ -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);

Loading…
Cancel
Save