diff --git a/src/AnimeClient/API/Kitsu/Transformer/AnimeListTransformer.php b/src/AnimeClient/API/Kitsu/Transformer/AnimeListTransformer.php index bc2992d3..0e493bf3 100644 --- a/src/AnimeClient/API/Kitsu/Transformer/AnimeListTransformer.php +++ b/src/AnimeClient/API/Kitsu/Transformer/AnimeListTransformer.php @@ -122,7 +122,6 @@ final class AnimeListTransformer extends AbstractTransformer { $untransformed = FormItem::from([ 'id' => $item['id'], - 'anilist_item_id' => $item['anilist_item_id'] ?? NULL, 'mal_id' => $item['mal_id'] ?? NULL, 'data' => [ 'status' => $item['watching_status'], diff --git a/src/AnimeClient/Kitsu.php b/src/AnimeClient/Kitsu.php index 03e53991..a1d0d18a 100644 --- a/src/AnimeClient/Kitsu.php +++ b/src/AnimeClient/Kitsu.php @@ -166,7 +166,7 @@ final class Kitsu { */ public static function parseStreamingLinks(array $nodes): array { - if (count($nodes) === 0) + if (empty($nodes)) { return []; } @@ -179,12 +179,16 @@ final class Kitsu { // 'Fix' links that start with the hostname, // rather than a protocol - if (strpos($url, '//') === FALSE) + if ( ! str_contains($url, '//')) { $url = '//' . $url; } $host = parse_url($url, \PHP_URL_HOST); + if ($host === FALSE) + { + return []; + } $links[] = [ 'meta' => self::getServiceMetaData($host), diff --git a/src/AnimeClient/MenuGenerator.php b/src/AnimeClient/MenuGenerator.php index 3951dacc..d8dfd23d 100644 --- a/src/AnimeClient/MenuGenerator.php +++ b/src/AnimeClient/MenuGenerator.php @@ -45,7 +45,7 @@ final class MenuGenerator extends UrlGenerator { /** * @param ContainerInterface $container - * @return static + * @return self */ public static function new(ContainerInterface $container): self { diff --git a/src/AnimeClient/Model/AnimeCollection.php b/src/AnimeClient/Model/AnimeCollection.php index 74301911..e489dc5a 100644 --- a/src/AnimeClient/Model/AnimeCollection.php +++ b/src/AnimeClient/Model/AnimeCollection.php @@ -92,6 +92,11 @@ final class AnimeCollection extends Collection { $genres = $this->getGenreList(); $media = $this->getMediaList(); + if ($rows === FALSE) + { + return []; + } + foreach($rows as &$row) { $id = $row['hummingbird_id']; @@ -128,7 +133,13 @@ final class AnimeCollection extends Collection { ->from('media') ->get(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + + foreach ($rows as $row) { $flatList[$row['id']] = $row['type']; } @@ -158,10 +169,10 @@ final class AnimeCollection extends Collection { /** * Add an item to the anime collection * - * @param array $data + * @param mixed $data * @return void */ - public function add($data): void + public function add(mixed $data): void { if ($this->validDatabase === FALSE) { @@ -197,10 +208,10 @@ final class AnimeCollection extends Collection { /** * Verify that an item was added * - * @param array|null|object $data + * @param array $data * @return bool */ - public function wasAdded($data): bool + public function wasAdded(array $data): bool { if ($this->validDatabase === FALSE) { @@ -218,7 +229,7 @@ final class AnimeCollection extends Collection { * @param array $data * @return void */ - public function update($data): void + public function update(array $data): void { if ($this->validDatabase === FALSE) { @@ -253,11 +264,11 @@ final class AnimeCollection extends Collection { /** * Verify that the collection item was updated * - * @param array|null|object $data + * @param array $data * * @return bool */ - public function wasUpdated($data): bool + public function wasUpdated(array $data): bool { if ($this->validDatabase === FALSE) { @@ -288,7 +299,7 @@ final class AnimeCollection extends Collection { * @param array $data * @return void */ - public function delete($data): void + public function delete(array $data): void { if ($this->validDatabase === FALSE) { @@ -316,10 +327,10 @@ final class AnimeCollection extends Collection { } /** - * @param array|null|object $data + * @param array $data * @return bool */ - public function wasDeleted($data): bool + public function wasDeleted(array $data): bool { if ($this->validDatabase === FALSE) { @@ -335,7 +346,7 @@ final class AnimeCollection extends Collection { * @param int|string $kitsuId * @return array */ - public function get($kitsuId): array + public function get(int|string $kitsuId): array { if ($this->validDatabase === FALSE) { @@ -348,6 +359,11 @@ final class AnimeCollection extends Collection { ->get() ->fetch(PDO::FETCH_ASSOC); + if ($row === FALSE) + { + return []; + } + // Get the media ids $mediaRows = $this->db->select('media_id') ->from('anime_set_media_link') @@ -355,6 +371,11 @@ final class AnimeCollection extends Collection { ->get() ->fetchAll(PDO::FETCH_ASSOC); + if ($mediaRows === FALSE) + { + return []; + } + $row['media_id'] = array_column($mediaRows, 'media_id'); return $row; @@ -366,7 +387,7 @@ final class AnimeCollection extends Collection { * @param int|string $kitsuId * @return bool */ - public function has($kitsuId): bool + public function has(int|string $kitsuId): bool { if ($this->validDatabase === FALSE) { @@ -416,7 +437,13 @@ final class AnimeCollection extends Collection { ->orderBy('genre') ->get(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + + foreach ($rows as $row) { $id = $row['hummingbird_id']; $genre = $row['genre']; @@ -437,7 +464,7 @@ final class AnimeCollection extends Collection { } } } - catch (PDOException $e) {} + catch (PDOException) {} $this->db->resetQuery(); @@ -478,7 +505,13 @@ final class AnimeCollection extends Collection { ->orderBy('media') ->get(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + + foreach ($rows as $row) { $id = $row['hummingbird_id']; $media = $row['media']; @@ -609,7 +642,7 @@ final class AnimeCollection extends Collection { { $this->db->insertBatch('genres', $insert); } - catch (PDOException $e) + catch (PDOException) { // dump($e); } @@ -642,7 +675,13 @@ final class AnimeCollection extends Collection { ->from('genres') ->get(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $genre) + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + + foreach ($rows as $genre) { $genres[$genre['id']] = $genre['genre']; } @@ -665,7 +704,13 @@ final class AnimeCollection extends Collection { ->from('anime_set_genre_link') ->get(); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $link) + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + + foreach ($rows as $link) { if (array_key_exists($link['hummingbird_id'], $links)) { @@ -706,6 +751,11 @@ final class AnimeCollection extends Collection { // Add genres associated with each item $rows = $query->fetchAll(PDO::FETCH_ASSOC); + if ($rows === FALSE) + { + return []; + } + $genres = $this->getGenreList(); foreach($rows as &$row) diff --git a/src/AnimeClient/Model/Collection.php b/src/AnimeClient/Model/Collection.php index 9d0bcb59..ae63d8f2 100644 --- a/src/AnimeClient/Model/Collection.php +++ b/src/AnimeClient/Model/Collection.php @@ -67,10 +67,11 @@ class Collection extends DB { { $dbFileName = $this->dbConfig['file']; - if ($dbFileName !== ':memory:' && file_exists($dbFileName)) + if ($dbFileName !== ':memory:') { - $dbFile = file_get_contents($dbFileName); - $this->validDatabase = (strpos($dbFile, 'SQLite format 3') === 0); + $rawFile = file_get_contents($dbFileName); + $dbFile = ($rawFile !== FALSE) ? $rawFile : ''; + $this->validDatabase = str_starts_with($dbFile, 'SQLite format 3'); } else { diff --git a/src/AnimeClient/Model/Settings.php b/src/AnimeClient/Model/Settings.php index 7d413cf5..fc7e600b 100644 --- a/src/AnimeClient/Model/Settings.php +++ b/src/AnimeClient/Model/Settings.php @@ -69,9 +69,7 @@ final class Settings { { $output = []; - $settings = $this->getSettings(); - - foreach($settings as $file => $values) + foreach($this->getSettings() as $file => $values) { $values = $values ?? []; diff --git a/src/AnimeClient/Types/AbstractType.php b/src/AnimeClient/Types/AbstractType.php index 7a3b6407..13f6bd73 100644 --- a/src/AnimeClient/Types/AbstractType.php +++ b/src/AnimeClient/Types/AbstractType.php @@ -23,10 +23,10 @@ abstract class AbstractType implements ArrayAccess, Countable { /** * Populate values for un-serializing data * - * @param $properties + * @param mixed $properties * @return self */ - public static function __set_state($properties): self + public static function __set_state(mixed $properties): self { return new static($properties); } @@ -43,7 +43,8 @@ abstract class AbstractType implements ArrayAccess, Countable { if (get_parent_class($currentClass) !== FALSE) { - return (new $currentClass($data))->toArray(); + $output = static::class::from($data)->toArray(); + return (is_array($output)) ? $output : []; } return NULL; @@ -55,7 +56,7 @@ abstract class AbstractType implements ArrayAccess, Countable { * @param mixed $data * @return static */ - final public static function from($data): self + final public static function from(mixed $data): static { return new static($data); } @@ -65,7 +66,7 @@ abstract class AbstractType implements ArrayAccess, Countable { * * @param mixed $data */ - final private function __construct($data = []) + final private function __construct(mixed $data = []) { $typeKeys = array_keys((array)$this); $dataKeys = array_keys((array)$data); @@ -87,10 +88,10 @@ abstract class AbstractType implements ArrayAccess, Countable { /** * See if a property is set * - * @param $name + * @param string $name * @return bool */ - final public function __isset($name): bool + final public function __isset(string $name): bool { return property_exists($this, $name) && isset($this->$name); } @@ -102,7 +103,7 @@ abstract class AbstractType implements ArrayAccess, Countable { * @param mixed $value * @return void */ - final public function __set($name, $value): void + final public function __set(string $name, mixed $value): void { $setterMethod = 'set' . ucfirst($name); @@ -128,7 +129,7 @@ abstract class AbstractType implements ArrayAccess, Countable { * @param string $name * @return mixed */ - final public function __get($name) + final public function __get(string $name): mixed { // Be a bit more lenient here, so that you can easily typecast missing // values to reasonable defaults, and not have to resort to array indexes @@ -148,46 +149,47 @@ abstract class AbstractType implements ArrayAccess, Countable { /** * Implementing ArrayAccess * - * @param $offset + * @param mixed $offset * @return bool */ - final public function offsetExists($offset): bool + final public function offsetExists(mixed $offset): bool { - return $this->__isset($offset); + return $this->__isset((string)$offset); } /** * Implementing ArrayAccess * - * @param $offset + * @param mixed $offset * @return mixed */ - final public function offsetGet($offset) + final public function offsetGet(mixed $offset): mixed { - return $this->__get($offset); + return $this->__get((string)$offset); } /** * Implementing ArrayAccess * - * @param $offset - * @param $value + * @param mixed $offset + * @param mixed $value */ - final public function offsetSet($offset, $value): void + final public function offsetSet(mixed $offset, mixed $value): void { - $this->__set($offset, $value); + $this->__set((string)$offset, $value); } /** * Implementing ArrayAccess * - * @param $offset + * @param mixed $offset */ - final public function offsetUnset($offset): void + final public function offsetUnset(mixed $offset): void { if ($this->offsetExists($offset)) { - unset($this->$offset); + $strOffset = (string)$offset; + unset($this->$strOffset); } } @@ -198,17 +200,19 @@ abstract class AbstractType implements ArrayAccess, Countable { */ final public function count(): int { - $keys = array_keys($this->toArray()); + $keys = array_keys((array)$this->toArray()); return count($keys); } /** * Recursively cast properties to an array * + * Returns early on primitive values to work recursively. + * * @param mixed $parent - * @return mixed + * @return float|bool|null|int|array|string */ - final public function toArray($parent = null) + final public function toArray(mixed $parent = null): float|null|bool|int|array|string { $object = $parent ?? $this; @@ -236,7 +240,8 @@ abstract class AbstractType implements ArrayAccess, Countable { */ final public function isEmpty(): bool { - foreach ($this as $value) + $self = (array)$this->toArray(); + foreach ($self as $value) { if ( ! empty($value)) { diff --git a/src/AnimeClient/Types/Anime.php b/src/AnimeClient/Types/Anime.php index 357345a7..115be3c5 100644 --- a/src/AnimeClient/Types/Anime.php +++ b/src/AnimeClient/Types/Anime.php @@ -35,9 +35,9 @@ class Anime extends AbstractType { public array $genres = []; /** - * @var string|int + * @var string */ - public $id = ''; + public string $id = ''; public array $included = []; diff --git a/src/AnimeClient/Types/AnimeListItem.php b/src/AnimeClient/Types/AnimeListItem.php index 2a2c484f..56d41c2d 100644 --- a/src/AnimeClient/Types/AnimeListItem.php +++ b/src/AnimeClient/Types/AnimeListItem.php @@ -24,11 +24,6 @@ final class AnimeListItem extends AbstractType { public ?string $mal_id; - /** - * @var string - */ - public $anilist_item_id; - public array $episodes = [ 'length' => 0, 'total' => 0, @@ -54,14 +49,14 @@ final class AnimeListItem extends AbstractType { /** * @var string|int */ - public $user_rating = ''; + public string|int $user_rating = ''; /** * One of Aviat\AnimeClient\API\Enum\AnimeWatchingStatus */ public string $watching_status; - public function setAnime($anime): void + public function setAnime(mixed $anime): void { $this->anime = Anime::from($anime); } diff --git a/src/AnimeClient/Types/Character.php b/src/AnimeClient/Types/Character.php index d9500914..e68c4259 100644 --- a/src/AnimeClient/Types/Character.php +++ b/src/AnimeClient/Types/Character.php @@ -27,7 +27,7 @@ final class Character extends AbstractType { /** * @var string */ - public $id; + public string $id; public array $included = []; @@ -39,7 +39,7 @@ final class Character extends AbstractType { public array $otherNames = []; - public function setMedia ($media): void + public function setMedia (mixed $media): void { $this->media = Media::from($media); } diff --git a/src/AnimeClient/Types/Config.php b/src/AnimeClient/Types/Config.php index d3f2d7d7..9de10ffd 100644 --- a/src/AnimeClient/Types/Config.php +++ b/src/AnimeClient/Types/Config.php @@ -47,8 +47,9 @@ class Config extends AbstractType { /** * The list to redirect to from the root url + * 'anime' or 'manga' * - * @var 'anime' | 'manga' + * @var string|null */ public ?string $default_list; @@ -59,7 +60,10 @@ class Config extends AbstractType { public ?string $default_manga_list_path; /** - * @var 'cover_view' | 'list_view' + * Default list view type + * 'cover_view' or 'list_view' + * + * @var string */ public ?string $default_view_type; @@ -70,17 +74,18 @@ class Config extends AbstractType { /** * @var string|bool */ - public $show_anime_collection = FALSE; + public string|bool $show_anime_collection = FALSE; /** * @var string|bool */ - public $show_manga_collection = FALSE; + public string|bool $show_manga_collection = FALSE; /** * CSS theme: light, dark, or auto-switching + * 'auto', 'light', or 'dark' * - * @var 'auto' | 'light' | 'dark' + * @var string|null */ public ?string $theme = 'auto'; @@ -116,17 +121,17 @@ class Config extends AbstractType { public ?string $view_path; - public function setAnilist ($data): void + public function setAnilist (mixed $data): void { $this->anilist = Config\Anilist::from($data); } - public function setCache ($data): void + public function setCache (mixed $data): void { $this->cache = Config\Cache::from($data); } - public function setDatabase ($data): void + public function setDatabase (mixed $data): void { $this->database = Config\Database::from($data); } diff --git a/src/AnimeClient/Types/FormItem.php b/src/AnimeClient/Types/FormItem.php index b8d1130a..47a0eb5a 100644 --- a/src/AnimeClient/Types/FormItem.php +++ b/src/AnimeClient/Types/FormItem.php @@ -23,18 +23,16 @@ class FormItem extends AbstractType { /** * @var string|int */ - public $id; - - public ?string $anilist_item_id; + public string|int $id; /** - * @var string|int + * @var string|int|null */ - public $mal_id; + public string|int|null $mal_id; public ?FormItemData $data; - public function setData($value): void + public function setData(mixed $value): void { $this->data = FormItemData::from($value); } diff --git a/src/AnimeClient/Types/MangaPage.php b/src/AnimeClient/Types/MangaPage.php index a889e120..08972090 100644 --- a/src/AnimeClient/Types/MangaPage.php +++ b/src/AnimeClient/Types/MangaPage.php @@ -23,12 +23,12 @@ use Aviat\AnimeClient\API\Kitsu\Enum\MangaPublishingStatus; */ final class MangaPage extends AbstractType { /** - * @var string + * @var string|null */ public ?string $age_rating; /** - * @var string + * @var string|null */ public ?string $age_rating_guide; @@ -38,14 +38,14 @@ final class MangaPage extends AbstractType { public array $characters; /** - * @var int + * @var int|null */ - public $chapter_count; + public ?int $chapter_count; /** - * @var string + * @var string|null */ - public $cover_image; + public ?string $cover_image; /** * @var array @@ -60,15 +60,15 @@ final class MangaPage extends AbstractType { /** * @var string */ - public $id; + public string $id; /** * @var string */ - public $manga_type; + public string $manga_type; /** - * @var MangaPublishingStatus + * @var string */ public string $status = MangaPublishingStatus::FINISHED; @@ -103,7 +103,7 @@ final class MangaPage extends AbstractType { public string $url; /** - * @var int + * @var int|null */ public ?int $volume_count; } diff --git a/src/AnimeClient/Types/Person.php b/src/AnimeClient/Types/Person.php index 675f2b56..d9afd8ee 100644 --- a/src/AnimeClient/Types/Person.php +++ b/src/AnimeClient/Types/Person.php @@ -21,7 +21,7 @@ namespace Aviat\AnimeClient\Types; */ final class Person extends AbstractType { - public $id; + public string $id; public ?string $name; diff --git a/src/AnimeClient/UrlGenerator.php b/src/AnimeClient/UrlGenerator.php index b4c99b56..77731bbf 100644 --- a/src/AnimeClient/UrlGenerator.php +++ b/src/AnimeClient/UrlGenerator.php @@ -49,7 +49,7 @@ class UrlGenerator extends RoutingBase { /** * Get the base url for css/js/images * - * @param array $args + * @param string ...$args * @return string */ public function assetUrl(string ...$args): string diff --git a/src/AnimeClient/Util.php b/src/AnimeClient/Util.php index 940b976e..fcb77751 100644 --- a/src/AnimeClient/Util.php +++ b/src/AnimeClient/Util.php @@ -57,11 +57,11 @@ class Util { /** * Absolutely equal? * - * @param $left - * @param $right + * @param mixed $left + * @param mixed $right * @return bool */ - public static function eq($left, $right): bool + public static function eq(mixed $left, mixed $right): bool { return $left === $right; } diff --git a/src/Ion/Di/Container.php b/src/Ion/Di/Container.php index cecafd1f..ac545d21 100644 --- a/src/Ion/Di/Container.php +++ b/src/Ion/Di/Container.php @@ -29,21 +29,21 @@ class Container implements ContainerInterface { * * @var Callable[] */ - protected $container = []; + protected array $container = []; /** * Array of object instances * * @var array */ - protected $instances = []; + protected array $instances = []; /** * Map of logger instances * * @var array */ - protected $loggers = []; + protected array $loggers = []; /** * Constructor @@ -66,7 +66,7 @@ class Container implements ContainerInterface { * * @return mixed Entry. */ - public function get($id) + public function get($id): mixed { if ( ! \is_string($id)) { @@ -99,7 +99,7 @@ class Container implements ContainerInterface { * @throws ContainerException - Error while retrieving the entry. * @return mixed */ - public function getNew($id, array $args = NULL) + public function getNew($id, array $args = NULL): mixed { if ( ! \is_string($id)) { @@ -141,7 +141,7 @@ class Container implements ContainerInterface { * @throws NotFoundException - No entry was found for this identifier. * @return ContainerInterface */ - public function setInstance(string $id, $value): ContainerInterface + public function setInstance(string $id, mixed $value): ContainerInterface { if ( ! $this->has($id)) { @@ -209,15 +209,20 @@ class Container implements ContainerInterface { * @param mixed $obj * @return mixed */ - private function applyContainer($obj) + private function applyContainer(mixed $obj): mixed { - $trait_name = ContainerAware::class; - $interface_name = ContainerAwareInterface::class; + $traitName = ContainerAware::class; + $interfaceName = ContainerAwareInterface::class; - $uses_trait = \in_array($trait_name, class_uses($obj), TRUE); - $implements_interface = \in_array($interface_name, class_implements($obj), TRUE); + $traits = class_uses($obj); + $traitsUsed = (is_array($traits)) ? $traits : []; + $usesTrait = in_array($traitName, $traitsUsed, TRUE); - if ($uses_trait || $implements_interface) + $interfaces = class_implements($obj); + $implemented = (is_array($interfaces)) ? $interfaces : []; + $implementsInterface = in_array($interfaceName, $implemented, TRUE); + + if ($usesTrait || $implementsInterface) { $obj->setContainer($this); } diff --git a/src/Ion/Json.php b/src/Ion/Json.php index 3711c2bb..fbfc5f3f 100644 --- a/src/Ion/Json.php +++ b/src/Ion/Json.php @@ -32,11 +32,12 @@ class Json { * @throws JsonException * @return string */ - public static function encode($data, $options = 0, $depth = 512): string + public static function encode(mixed $data, int $options = 0, int $depth = 512): string { $json = json_encode($data, $options, $depth); self::check_json_error(); - return $json; + + return ($json !== FALSE) ? $json : ''; } /** @@ -47,12 +48,14 @@ class Json { * @param int $jsonOptions - Options to pass to json_encode * @param int $fileOptions - Options to pass to file_get_contents * @throws JsonException - * @return int + * @return bool */ - public static function encodeFile(string $filename, $data, int $jsonOptions = 0, int $fileOptions = 0): int + public static function encodeFile(string $filename, mixed $data, int $jsonOptions = 0, int $fileOptions = 0): bool { $json = self::encode($data, $jsonOptions); - return file_put_contents($filename, $json, $fileOptions); + + $res = file_put_contents($filename, $json, $fileOptions); + return $res !== FALSE; } /** @@ -65,7 +68,7 @@ class Json { * @throws JsonException * @return mixed */ - public static function decode($json, bool $assoc = TRUE, int $depth = 512, int $options = 0) + public static function decode(?string $json, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed { // Don't try to decode null if ($json === NULL) @@ -89,9 +92,11 @@ class Json { * @throws JsonException * @return mixed */ - public static function decodeFile(string $filename, bool $assoc = TRUE, int $depth = 512, int $options = 0) + public static function decodeFile(string $filename, bool $assoc = TRUE, int $depth = 512, int $options = 0): mixed { - $json = file_get_contents($filename); + $rawJson = file_get_contents($filename); + $json = ($rawJson !== FALSE) ? $rawJson : ''; + return self::decode($json, $assoc, $depth, $options); } diff --git a/src/Ion/Type/StringType.php b/src/Ion/Type/StringType.php index a90da7d6..4a61c380 100644 --- a/src/Ion/Type/StringType.php +++ b/src/Ion/Type/StringType.php @@ -27,7 +27,7 @@ class StringType extends Stringy { * Alias for `create` static constructor * * @param string $str - * @return $this + * @return self */ public static function from(string $str): self { diff --git a/src/Ion/View/HtmlView.php b/src/Ion/View/HtmlView.php index bcc813d0..bfd1eb05 100644 --- a/src/Ion/View/HtmlView.php +++ b/src/Ion/View/HtmlView.php @@ -69,7 +69,8 @@ class HtmlView extends HttpView { ob_start(); extract($data, EXTR_OVERWRITE); include_once $path; - $buffer = ob_get_clean(); + $rawBuffer = ob_get_clean(); + $buffer = ($rawBuffer === FALSE) ? '' : $rawBuffer; // Very basic html minify, that won't affect content between html tags diff --git a/src/Ion/View/HttpView.php b/src/Ion/View/HttpView.php index 21a4b041..dd683a3b 100644 --- a/src/Ion/View/HttpView.php +++ b/src/Ion/View/HttpView.php @@ -103,9 +103,9 @@ class HttpView implements ViewInterface{ * Set the output string * * @param mixed $string - * @return HttpView + * @return ViewInterface */ - public function setOutput($string): self + public function setOutput($string): ViewInterface { $this->response->getBody()->write($string); @@ -117,9 +117,9 @@ class HttpView implements ViewInterface{ * Append additional output. * * @param string $string - * @return HttpView + * @return ViewInterface */ - public function appendOutput(string $string): self + public function appendOutput(string $string): ViewInterface { return $this->setOutput($string); } diff --git a/src/Ion/View/JsonView.php b/src/Ion/View/JsonView.php index 8f27801d..09856d47 100644 --- a/src/Ion/View/JsonView.php +++ b/src/Ion/View/JsonView.php @@ -17,6 +17,7 @@ namespace Aviat\Ion\View; use Aviat\Ion\Json; +use Aviat\Ion\ViewInterface; /** * View class to serialize Json @@ -34,9 +35,9 @@ class JsonView extends HttpView { * Set the output string * * @param mixed $string - * @return JsonView + * @return ViewInterface */ - public function setOutput($string): self + public function setOutput($string): ViewInterface { if ( ! is_string($string)) { diff --git a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 0__1.yml b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 0__1.yml index 22fb6164..814b33e9 100644 --- a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 0__1.yml +++ b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 0__1.yml @@ -1,6 +1,5 @@ empty: false id: 14047981 -anilist_item_id: null mal_id: null data: empty: false diff --git a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 1__1.yml b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 1__1.yml index 6769276d..6f631375 100644 --- a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 1__1.yml +++ b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 1__1.yml @@ -1,6 +1,5 @@ empty: false id: 14047981 -anilist_item_id: null mal_id: '12345' data: empty: false diff --git a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 2__1.yml b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 2__1.yml index adc5fcbe..98e0c061 100644 --- a/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 2__1.yml +++ b/tests/AnimeClient/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set 2__1.yml @@ -1,6 +1,5 @@ empty: false id: 14047983 -anilist_item_id: null mal_id: '12347' data: empty: false