From 5242b95a0e83068851d20773801e17629c359e1d Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 19 May 2023 16:34:38 -0400 Subject: [PATCH] Fix a load of code cleanliness and style issues --- src/AnimeClient/API/Kitsu/Model.php | 10 ++--- src/AnimeClient/API/Kitsu/RequestBuilder.php | 41 +------------------ .../API/Kitsu/RequestBuilderTrait.php | 2 - .../Kitsu/Transformer/MangaTransformer.php | 2 +- src/AnimeClient/AnimeClient.php | 5 --- src/AnimeClient/Controller/Anime.php | 4 -- src/AnimeClient/Controller/Character.php | 2 - src/AnimeClient/Controller/Images.php | 20 +++++---- src/AnimeClient/Controller/Manga.php | 4 -- src/AnimeClient/Controller/Misc.php | 10 +---- src/AnimeClient/Controller/People.php | 2 - src/AnimeClient/Controller/Settings.php | 10 +---- src/AnimeClient/Controller/User.php | 2 - src/AnimeClient/Dispatcher.php | 24 +++-------- src/AnimeClient/Model/AnimeCollection.php | 16 ++++---- src/Ion/Json.php | 17 ++++++-- src/Ion/Type/StringType.php | 4 +- src/Ion/Type/Stringy.php | 2 +- src/Ion/View/HtmlView.php | 4 +- tests/AnimeClient/AnimeClientTest.php | 5 +++ tests/Ion/ConfigTest.php | 2 + tests/Ion/Type/StringTypeTest.php | 7 +++- tests/Ion/View/HttpViewTest.php | 1 + tests/Ion/functionsTest.php | 9 +++- 24 files changed, 78 insertions(+), 127 deletions(-) diff --git a/src/AnimeClient/API/Kitsu/Model.php b/src/AnimeClient/API/Kitsu/Model.php index b4293d7d..ae708394 100644 --- a/src/AnimeClient/API/Kitsu/Model.php +++ b/src/AnimeClient/API/Kitsu/Model.php @@ -283,7 +283,7 @@ final class Model if ($list === NULL) { - $data = $this->getList(MediaType::ANIME, $status) ?? []; + $data = $this->getList(MediaType::ANIME, $status); // Bail out on no data if (empty($data)) @@ -320,7 +320,7 @@ final class Model /** * Get all the anime entries, that are organized for output to html * - * @return array + * @return array */ public function getFullOrganizedAnimeList(): array { @@ -331,7 +331,7 @@ final class Model foreach ($statuses as $status) { $mappedStatus = AnimeWatchingStatus::KITSU_TO_TITLE[$status]; - $output[$mappedStatus] = $this->getAnimeList($status) ?? []; + $output[$mappedStatus] = $this->getAnimeList($status); } return $output; @@ -413,7 +413,7 @@ final class Model if ($list === NULL) { - $data = $this->getList(MediaType::MANGA, $status) ?? []; + $data = $this->getList(MediaType::MANGA, $status); // Bail out on no data if (empty($data)) @@ -787,7 +787,7 @@ final class Model } } - private function getUserId(): string + protected function getUserId(): string { static $userId = NULL; diff --git a/src/AnimeClient/API/Kitsu/RequestBuilder.php b/src/AnimeClient/API/Kitsu/RequestBuilder.php index f23dc727..204bedee 100644 --- a/src/AnimeClient/API/Kitsu/RequestBuilder.php +++ b/src/AnimeClient/API/Kitsu/RequestBuilder.php @@ -78,7 +78,7 @@ final class RequestBuilder extends APIRequestBuilder elseif ($url !== K::AUTH_URL && $sessionSegment->get('auth_token') !== NULL) { $token = $sessionSegment->get('auth_token'); - if ( ! (empty($token) || $cache->has(K::AUTH_TOKEN_CACHE_KEY))) + if ( ! empty($token)) { $cache->set(K::AUTH_TOKEN_CACHE_KEY, $token); } @@ -239,43 +239,4 @@ final class RequestBuilder extends APIRequestBuilder 'body' => $body, ]); } - - /** - * Make a request - */ - private function request(string $type, string $url, array $options = []): array - { - $logger = $this->container->getLogger('kitsu-request'); - $response = $this->getResponse($type, $url, $options); - $statusCode = $response->getStatus(); - - // Check for requests that are unauthorized - if ($statusCode === 401 || $statusCode === 403) - { - Event::emit(EventType::UNAUTHORIZED); - } - - $rawBody = wait($response->getBody()->buffer()); - - // Any other type of failed request - if ($statusCode > 299 || $statusCode < 200) - { - if ($logger !== NULL) - { - $logger->warning('Non 2xx response for api call', (array) $response); - } - } - - try - { - return Json::decode($rawBody); - } - catch (JsonException) - { - // dump($e); - dump($rawBody); - - exit(); - } - } } diff --git a/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php b/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php index 1ba17909..f6ce8c06 100644 --- a/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php +++ b/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php @@ -23,8 +23,6 @@ trait RequestBuilderTrait /** * Set the request builder object - * - * @return ListItem|Model|RequestBuilderTrait */ public function setRequestBuilder(RequestBuilder $requestBuilder): self { diff --git a/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php b/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php index ea0b2b69..668e08e1 100644 --- a/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php +++ b/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php @@ -54,7 +54,7 @@ final class MangaTransformer extends AbstractTransformer } $details = $rawCharacter['character']; - if (array_key_exists($details['id'], $characters[$type])) + if (array_key_exists($details['id'], (array)$characters[$type])) { $characters[$type][$details['id']] = [ 'image' => Kitsu::getImage($details), diff --git a/src/AnimeClient/AnimeClient.php b/src/AnimeClient/AnimeClient.php index 86e2cfb0..ca5e53d7 100644 --- a/src/AnimeClient/AnimeClient.php +++ b/src/AnimeClient/AnimeClient.php @@ -18,7 +18,6 @@ use Amp\Http\Client\{HttpClient, HttpClientBuilder, Request, Response}; use Aviat\Ion\{ConfigInterface, ImageBuilder}; use DateTimeImmutable; -use PHPUnit\Framework\Attributes\CodeCoverageIgnore; use Psr\SimpleCache\CacheInterface; use Throwable; @@ -40,7 +39,6 @@ const MINUTES_IN_YEAR = 525_600; * * @param string $path - Path to load config */ -#[CodeCoverageIgnore] function loadConfig(string $path): array { $output = []; @@ -80,7 +78,6 @@ function loadConfig(string $path): array /** * Load config from one specific TOML file */ -#[CodeCoverageIgnore] function loadTomlFile(string $filename): array { return Toml::parseFile($filename); @@ -250,7 +247,6 @@ function getLocalImg(string $kitsuUrl, bool $webp = TRUE): string /** * Create a transparent placeholder image */ -#[CodeCoverageIgnore] function createPlaceholderImage(string $path, int $width = 200, int $height = 200, string $text = 'Image Unavailable'): bool { $img = ImageBuilder::new($width, $height) @@ -303,7 +299,6 @@ function clearCache(CacheInterface $cache): bool /** * Render a PHP code template as a string */ -#[CodeCoverageIgnore] function renderTemplate(string $path, array $data): string { ob_start(); diff --git a/src/AnimeClient/Controller/Anime.php b/src/AnimeClient/Controller/Anime.php index be4c807d..ea0da284 100644 --- a/src/AnimeClient/Controller/Anime.php +++ b/src/AnimeClient/Controller/Anime.php @@ -306,8 +306,6 @@ final class Anime extends BaseController 'Anime not found', 'Anime Not Found' ); - - return; } $this->outputHTML('anime/details', [ @@ -345,8 +343,6 @@ final class Anime extends BaseController 'Anime not found', 'Anime Not Found' ); - - return; } $this->outputHTML('anime/details', [ diff --git a/src/AnimeClient/Controller/Character.php b/src/AnimeClient/Controller/Character.php index cc0685e6..8b681632 100644 --- a/src/AnimeClient/Controller/Character.php +++ b/src/AnimeClient/Controller/Character.php @@ -59,8 +59,6 @@ final class Character extends BaseController ), 'Character Not Found' ); - - return; } $data = (new CharacterTransformer())->transform($rawData)->toArray(); diff --git a/src/AnimeClient/Controller/Images.php b/src/AnimeClient/Controller/Images.php index 0abbb1ec..58b17ddb 100644 --- a/src/AnimeClient/Controller/Images.php +++ b/src/AnimeClient/Controller/Images.php @@ -96,7 +96,7 @@ final class Images extends BaseController $kitsuUrl .= $imageType['kitsuUrl']; $width = $imageType['width']; - $height = $imageType['height']; + $height = $imageType['height'] ?? 225; $filePrefix = "{$baseSavePath}/{$type}/{$id}"; $response = getResponse($kitsuUrl); @@ -120,11 +120,11 @@ final class Images extends BaseController if ($display) { - $this->getPlaceholder("{$baseSavePath}/{$type}", $width, $height); + $this->getPlaceholder("{$baseSavePath}/{$type}", $width ?? 225, $height); } else { - createPlaceholderImage("{$baseSavePath}/{$type}", $width, $height); + createPlaceholderImage("{$baseSavePath}/{$type}", $width ?? 225, $height); } return; @@ -132,7 +132,13 @@ final class Images extends BaseController $data = wait($response->getBody()->buffer()); - [$origWidth] = getimagesizefromstring($data); + $size = getimagesizefromstring($data); + if ($size === FALSE) + { + return; + } + + [$origWidth] = $size; $gdImg = imagecreatefromstring($data); if ($gdImg === FALSE) { @@ -182,15 +188,15 @@ final class Images extends BaseController /** * Get a placeholder for a missing image */ - private function getPlaceholder(string $path, ?int $width = 200, ?int $height = NULL): void + private function getPlaceholder(string $path, ?int $width = NULL, ?int $height = NULL): void { - $height ??= $width; + $height ??= $width ?? 200; $filename = $path . '/placeholder.png'; if ( ! file_exists($path . '/placeholder.png')) { - createPlaceholderImage($path, $width, $height); + createPlaceholderImage($path, $width ?? 200, $height); } header('Content-Type: image/png'); diff --git a/src/AnimeClient/Controller/Manga.php b/src/AnimeClient/Controller/Manga.php index cd69a825..84840e7b 100644 --- a/src/AnimeClient/Controller/Manga.php +++ b/src/AnimeClient/Controller/Manga.php @@ -277,8 +277,6 @@ final class Manga extends BaseController 'Manga not found', 'Manga Not Found' ); - - return; } $this->outputHTML('manga/details', [ @@ -306,8 +304,6 @@ final class Manga extends BaseController 'Manga not found', 'Manga Not Found' ); - - return; } $this->outputHTML('manga/details', [ diff --git a/src/AnimeClient/Controller/Misc.php b/src/AnimeClient/Controller/Misc.php index f4ba9fe2..f42fe70d 100644 --- a/src/AnimeClient/Controller/Misc.php +++ b/src/AnimeClient/Controller/Misc.php @@ -101,11 +101,7 @@ final class Misc extends BaseController } $this->setFlashMessage('Invalid username or password.'); - - $redirectUrl = $this->url->generate('login'); - $redirectUrl = ($redirectUrl !== FALSE) ? $redirectUrl : ''; - - $this->redirect($redirectUrl, 303); + $this->redirect($this->url->generate('login'), 303); } /** @@ -145,8 +141,6 @@ final class Misc extends BaseController ), 'Character Not Found' ); - - return; } $data = (new CharacterTransformer())->transform($rawData)->toArray(); @@ -178,8 +172,6 @@ final class Misc extends BaseController ), 'Person Not Found' ); - - return; } $this->outputHTML('person/details', [ diff --git a/src/AnimeClient/Controller/People.php b/src/AnimeClient/Controller/People.php index 5e7db3db..80dc8d3b 100644 --- a/src/AnimeClient/Controller/People.php +++ b/src/AnimeClient/Controller/People.php @@ -60,8 +60,6 @@ final class People extends BaseController ), 'Person Not Found' ); - - return; } $this->outputHTML('person/details', [ diff --git a/src/AnimeClient/Controller/Settings.php b/src/AnimeClient/Controller/Settings.php index a5ffe601..ab2979fc 100644 --- a/src/AnimeClient/Controller/Settings.php +++ b/src/AnimeClient/Controller/Settings.php @@ -86,10 +86,7 @@ final class Settings extends BaseController ? $this->setFlashMessage('Saved config settings.', 'success') : $this->setFlashMessage('Failed to save config file.', 'error'); - $redirectUrl = $this->url->generate('settings'); - $redirectUrl = ($redirectUrl !== FALSE) ? $redirectUrl : ''; - - $this->redirect($redirectUrl, 303); + $this->redirect($this->url->generate('settings'), 303); } /** @@ -152,9 +149,6 @@ final class Settings extends BaseController ? $this->setFlashMessage('Linked Anilist Account', 'success') : $this->setFlashMessage('Error Linking Anilist Account', 'error'); - $redirectUrl = $this->url->generate('settings'); - $redirectUrl = ($redirectUrl !== FALSE) ? $redirectUrl : ''; - - $this->redirect($redirectUrl, 303); + $this->redirect($this->url->generate('settings'), 303); } } diff --git a/src/AnimeClient/Controller/User.php b/src/AnimeClient/Controller/User.php index 249fd4ec..5983a610 100644 --- a/src/AnimeClient/Controller/User.php +++ b/src/AnimeClient/Controller/User.php @@ -72,8 +72,6 @@ final class User extends BaseController if ($rawData['data']['findProfileBySlug'] === NULL) { $this->notFound('Sorry, user not found', "The user '{$username}' does not seem to exist."); - - return; } $data = (new UserTransformer())->transform($rawData)->toArray(); diff --git a/src/AnimeClient/Dispatcher.php b/src/AnimeClient/Dispatcher.php index 230a0a61..97ad2a52 100644 --- a/src/AnimeClient/Dispatcher.php +++ b/src/AnimeClient/Dispatcher.php @@ -82,11 +82,8 @@ final class Dispatcher extends RoutingBase { $route = $this->getRoute(); - if ($logger !== NULL) - { - $logger->info('Dispatcher - Route invoke arguments'); - $logger->info(print_r($route, TRUE)); - } + $logger?->info('Dispatcher - Route invoke arguments'); + $logger?->info(print_r($route, TRUE)); } if ( ! $route) @@ -183,10 +180,7 @@ final class Dispatcher extends RoutingBase } $logger = $this->container->getLogger(); - if ($logger !== NULL) - { - $logger->info(Json::encode($params)); - } + $logger?->info(Json::encode($params)); return [ 'controller_name' => $controllerName, @@ -208,10 +202,7 @@ final class Dispatcher extends RoutingBase $controller = reset($segments); $logger = $this->container->getLogger(); - if ($logger !== NULL) - { - $logger->info('Controller: ' . $controller); - } + $logger?->info('Controller: ' . $controller); if (empty($controller)) { @@ -224,7 +215,7 @@ final class Dispatcher extends RoutingBase /** * Get the list of controllers in the default namespace * - * @return mixed[] + * @return array */ public function getControllerList(): array { @@ -300,7 +291,6 @@ final class Dispatcher extends RoutingBase /** * Get the appropriate params for the error page * passed on the failed route - * @return mixed[][] */ protected function getErrorParams(): array { @@ -317,7 +307,7 @@ final class Dispatcher extends RoutingBase $params = []; - switch ($failure->failedRule) + switch ($failure?->failedRule) { case Rule\Allows::class: $params = [ @@ -349,8 +339,6 @@ final class Dispatcher extends RoutingBase /** * Select controller based on the current url, and apply its relevant routes - * - * @return mixed[] */ protected function setupRoutes(): array { diff --git a/src/AnimeClient/Model/AnimeCollection.php b/src/AnimeClient/Model/AnimeCollection.php index 1ff1ff2f..8d8f7048 100644 --- a/src/AnimeClient/Model/AnimeCollection.php +++ b/src/AnimeClient/Model/AnimeCollection.php @@ -91,7 +91,7 @@ final class AnimeCollection extends Collection $genres = $this->getGenreList(); $media = $this->getMediaList(); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -133,7 +133,7 @@ final class AnimeCollection extends Collection ->get(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -349,7 +349,7 @@ final class AnimeCollection extends Collection ->get() ->fetchAll(PDO::FETCH_ASSOC); - if ($mediaRows === FALSE) + if (empty($mediaRows)) { return []; } @@ -411,7 +411,7 @@ final class AnimeCollection extends Collection ->get(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -479,7 +479,7 @@ final class AnimeCollection extends Collection ->get(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -659,7 +659,7 @@ final class AnimeCollection extends Collection ->get(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -691,7 +691,7 @@ final class AnimeCollection extends Collection ->get(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } @@ -737,7 +737,7 @@ final class AnimeCollection extends Collection // Add genres associated with each item $rows = $query->fetchAll(PDO::FETCH_ASSOC); - if ($rows === FALSE) + if (empty($rows)) { return []; } diff --git a/src/Ion/Json.php b/src/Ion/Json.php index 3861d322..781c77ea 100644 --- a/src/Ion/Json.php +++ b/src/Ion/Json.php @@ -25,7 +25,10 @@ class Json /** * Encode data in json format * - * @throws JsonException + * @param mixed $data + * @param int $options + * @param int<1, max> $depth + * @return string */ public static function encode(mixed $data, int $options = 0, int $depth = 512): string { @@ -54,7 +57,11 @@ class Json /** * Decode data from json * - * @throws JsonException + * @param string|null $json + * @param bool $assoc + * @param int<1, max> $depth + * @param int $options + * @return mixed */ public static function decode(?string $json, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed { @@ -74,7 +81,11 @@ class Json /** * Decode json data loaded from the passed filename * - * @throws JsonException + * @param string $filename + * @param bool $assoc + * @param int<1, max> $depth + * @param int $options + * @return mixed */ public static function decodeFile(string $filename, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed { diff --git a/src/Ion/Type/StringType.php b/src/Ion/Type/StringType.php index d8e3cfed..e91d402d 100644 --- a/src/Ion/Type/StringType.php +++ b/src/Ion/Type/StringType.php @@ -24,9 +24,9 @@ final class StringType extends Stringy /** * Alias for `create` static constructor */ - public static function from(string $str): self + public static function from(string $str = '', ?string $encoding = NULL): self { - return self::create($str); + return self::create($str, $encoding); } /** diff --git a/src/Ion/Type/Stringy.php b/src/Ion/Type/Stringy.php index 5491b6db..147f6435 100644 --- a/src/Ion/Type/Stringy.php +++ b/src/Ion/Type/Stringy.php @@ -66,7 +66,7 @@ abstract class Stringy implements Countable, IteratorAggregate, ArrayAccess * @throws InvalidArgumentException if an array or object without a * __toString method is passed as the first argument */ - public function __construct(mixed $str = '', ?string $encoding = NULL) + final public function __construct(mixed $str = '', ?string $encoding = NULL) { if (is_array($str)) { diff --git a/src/Ion/View/HtmlView.php b/src/Ion/View/HtmlView.php index c1fbe1bf..231ab556 100644 --- a/src/Ion/View/HtmlView.php +++ b/src/Ion/View/HtmlView.php @@ -34,11 +34,11 @@ class HtmlView extends HttpView /** * Create the Html View */ - public function __construct(ContainerInterface $container) + public function __construct() { parent::__construct(); - $this->setContainer($container); + $this->setContainer(func_get_arg(0)); $this->response = new HtmlResponse(''); } diff --git a/tests/AnimeClient/AnimeClientTest.php b/tests/AnimeClient/AnimeClientTest.php index 425b0281..8893eef3 100644 --- a/tests/AnimeClient/AnimeClientTest.php +++ b/tests/AnimeClient/AnimeClientTest.php @@ -15,12 +15,17 @@ namespace Aviat\AnimeClient\Tests; use DateTime; +use PHPUnit\Framework\Attributes\IgnoreFunctionForCodeCoverage; use function Aviat\AnimeClient\{arrayToToml, checkFolderPermissions, clearCache, colNotEmpty, friendlyTime, getLocalImg, getResponse, isSequentialArray, tomlToArray}; use const Aviat\AnimeClient\{MINUTES_IN_DAY, MINUTES_IN_HOUR, MINUTES_IN_YEAR, SECONDS_IN_MINUTE}; /** * @internal */ +#[IgnoreFunctionForCodeCoverage('Aviat\AnimeClient\loadConfig')] +#[IgnoreFunctionForCodeCoverage('Aviat\AnimeClient\createPlaceholderImage')] +#[IgnoreFunctionForCodeCoverage('Aviat\AnimeClient\renderTemplate')] +#[IgnoreFunctionForCodeCoverage('Aviat\AnimeClient\getLocalImg')] final class AnimeClientTest extends AnimeClientTestCase { public function testArrayToToml(): void diff --git a/tests/Ion/ConfigTest.php b/tests/Ion/ConfigTest.php index 6bc26181..c32d9010 100644 --- a/tests/Ion/ConfigTest.php +++ b/tests/Ion/ConfigTest.php @@ -16,10 +16,12 @@ namespace Aviat\Ion\Tests; use Aviat\Ion\Config; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreMethodForCodeCoverage; /** * @internal */ +#[IgnoreMethodForCodeCoverage(Config::class, 'set')] final class ConfigTest extends IonTestCase { protected Config $config; diff --git a/tests/Ion/Type/StringTypeTest.php b/tests/Ion/Type/StringTypeTest.php index 8535e342..1a762153 100644 --- a/tests/Ion/Type/StringTypeTest.php +++ b/tests/Ion/Type/StringTypeTest.php @@ -16,11 +16,15 @@ namespace Aviat\Ion\Tests\Type; use Aviat\Ion\Tests\IonTestCase; use Aviat\Ion\Type\StringType; +use Aviat\Ion\Type\Stringy; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\IgnoreClassForCodeCoverage; +use PHPUnit\Framework\Attributes\Test; /** * @internal */ +#[IgnoreClassForCodeCoverage(Stringy::class)] final class StringTypeTest extends IonTestCase { public static function dataFuzzyCaseMatch(): array @@ -55,7 +59,8 @@ final class StringTypeTest extends IonTestCase } #[DataProvider('dataFuzzyCaseMatch')] - public function testFuzzyCaseMatch(string $str1, string $str2, bool $expected): void + #[Test] + public function fuzzyCaseMatch(string $str1, string $str2, bool $expected): void { $actual = StringType::from($str1)->fuzzyCaseMatch($str2); $this->assertSame($expected, $actual); diff --git a/tests/Ion/View/HttpViewTest.php b/tests/Ion/View/HttpViewTest.php index ec8acf4f..918ecab5 100644 --- a/tests/Ion/View/HttpViewTest.php +++ b/tests/Ion/View/HttpViewTest.php @@ -27,6 +27,7 @@ class HttpViewTest extends IonTestCase { parent::setUp(); $this->view = new TestHttpView(); + $this->view = TestHttpView::new(); $this->friend = new Friend($this->view); } diff --git a/tests/Ion/functionsTest.php b/tests/Ion/functionsTest.php index 3e28bdb1..1d77b2f8 100644 --- a/tests/Ion/functionsTest.php +++ b/tests/Ion/functionsTest.php @@ -14,6 +14,8 @@ namespace Aviat\Ion\Tests; +use PHPUnit\Framework\Attributes\IgnoreClassForCodeCoverage; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function Aviat\Ion\_dir; @@ -22,9 +24,14 @@ use const DIRECTORY_SEPARATOR; /** * @internal */ +#[IgnoreClassForCodeCoverage(\Aviat\Ion\ImageBuilder::class)] +#[IgnoreClassForCodeCoverage(\Aviat\Ion\Attribute\Controller::class)] +#[IgnoreClassForCodeCoverage(\Aviat\Ion\Attribute\DefaultController::class)] +#[IgnoreClassForCodeCoverage(\Aviat\Ion\Attribute\Route::class)] final class functionsTest extends TestCase { - public function testDir() + #[Test] + public function dir(): void { $args = ['foo', 'bar', 'baz']; $expected = implode(DIRECTORY_SEPARATOR, $args);