From 5aa0276f11a179c7e3ca11f07e906ac4eda61c8a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 24 Oct 2020 17:53:54 +0200 Subject: [PATCH] cs and phpstan fixes --- Ai/Ocr/BasicOcr.php | 10 +++--- Auth/OAuth2/Provider/GeneralResourceOwner.php | 2 +- .../Provider/ResourceOwnerInterface.php | 16 ++++++++- DataStorage/Cache/Connection/FileCache.php | 4 +-- DataStorage/Cache/Connection/MemCached.php | 4 +-- DataStorage/Cache/Connection/NullCache.php | 2 +- DataStorage/Cache/Connection/RedisCache.php | 4 +-- .../DataStorageConnectionInterface.php | 4 +-- .../Connection/ConnectionAbstract.php | 11 ++++-- .../Database/Connection/MysqlConnection.php | 2 +- DataStorage/Database/Connection/NullPDO.php | 36 +++++++++++++++++++ .../Connection/PostgresConnection.php | 2 +- .../Database/Connection/SQLiteConnection.php | 2 +- .../Connection/SqlServerConnection.php | 2 +- DataStorage/Database/DataMapperAbstract.php | 21 ++++++----- Localization/L11nManager.php | 2 ++ Math/Matrix/Matrix.php | 2 +- Math/Number/Prime.php | 19 ++++++---- Message/Console/ConsoleRequest.php | 20 ----------- Message/Http/HttpRequest.php | 20 ----------- Message/RequestAbstract.php | 21 +++++++++++ System/File/Ftp/Directory.php | 12 +++++++ System/File/Ftp/File.php | 28 ++++++++++----- System/File/Ftp/FileAbstract.php | 4 +-- System/File/Ftp/FtpStorage.php | 15 ++++++++ System/File/Local/Directory.php | 5 +-- System/File/Local/File.php | 7 ++++ Utils/Converter/File.php | 6 ++-- Views/ViewAbstract.php | 2 +- .../Database/TestModel/BaseModelMapper.php | 2 +- 30 files changed, 191 insertions(+), 96 deletions(-) create mode 100644 DataStorage/Database/Connection/NullPDO.php diff --git a/Ai/Ocr/BasicOcr.php b/Ai/Ocr/BasicOcr.php index 31cf13ef0..e920c4559 100644 --- a/Ai/Ocr/BasicOcr.php +++ b/Ai/Ocr/BasicOcr.php @@ -54,7 +54,7 @@ final class BasicOcr * * @param string $dataPath Impage path to read * @param string $labelPath Label path to read - * @param string $limit Limit (0 = unlimited) + * @param int $limit Limit (0 = unlimited) * * @return void * @@ -73,7 +73,7 @@ final class BasicOcr * Reat image from path * * @param string $path Image to read - * @param string $limit Limit + * @param int $limit Limit * * @return array * @@ -136,7 +136,7 @@ final class BasicOcr * Read labels from from path * * @param string $path Labels path - * @param string $limit Limit + * @param int $limit Limit * * @return array * @@ -244,8 +244,8 @@ final class BasicOcr * Categorize an unknown image * * @param string $path Path to the image to categorize/evaluate/match against the training data - * @param string $comparison Amount of comparisons - * @param string $limit Limit (0 = unlimited) + * @param int $comparison Amount of comparisons + * @param int $limit Limit (0 = unlimited) * * @return array * diff --git a/Auth/OAuth2/Provider/GeneralResourceOwner.php b/Auth/OAuth2/Provider/GeneralResourceOwner.php index d6623b37a..df87d641d 100644 --- a/Auth/OAuth2/Provider/GeneralResourceOwner.php +++ b/Auth/OAuth2/Provider/GeneralResourceOwner.php @@ -36,7 +36,7 @@ class GeneralResourceOwner implements ResourceOwnerInterface $this->resourceOwnerId = $resourceOwnerId; } - public function getId() + public function getId() : string { return $this->response[$this->resourceOwnerId]; } diff --git a/Auth/OAuth2/Provider/ResourceOwnerInterface.php b/Auth/OAuth2/Provider/ResourceOwnerInterface.php index 57126234f..0f91ddc6b 100644 --- a/Auth/OAuth2/Provider/ResourceOwnerInterface.php +++ b/Auth/OAuth2/Provider/ResourceOwnerInterface.php @@ -26,7 +26,21 @@ namespace phpOMS\Auth\OAuth2\Provider; */ interface ResourceOwnerInterface { - public function getId(); + /** + * Get id + * + * @return string + * + * @since 1.0.0 + */ + public function getId() : string; + /** + * Serialize as array + * + * @return array + * + * @since 1.0.0 + */ public function toArray() : array; } diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index 7340ba861..5f7b3f603 100644 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -94,9 +94,9 @@ final class FileCache extends ConnectionAbstract /** * Connect to cache * - * @param array{0:string} $data Cache data (path to cache directory) + * @param null|array{0:string} $data Cache data (path to cache directory) */ - public function connect(array $data) : void + public function connect(array $data = null) : void { $this->dbdata = $data; diff --git a/DataStorage/Cache/Connection/MemCached.php b/DataStorage/Cache/Connection/MemCached.php index b66c950a9..d86a1e237 100644 --- a/DataStorage/Cache/Connection/MemCached.php +++ b/DataStorage/Cache/Connection/MemCached.php @@ -57,13 +57,13 @@ final class MemCached extends ConnectionAbstract /** * Connect to cache * - * @param array{host:string, port:int} $data Cache data + * @param null|array{host:string, port:int} $data Cache data * * @return void * * @since 1.0.0 */ - public function connect(array $data) : void + public function connect(array $data = null) : void { $this->dbdata = isset($data) ? $data : $this->dbdata; diff --git a/DataStorage/Cache/Connection/NullCache.php b/DataStorage/Cache/Connection/NullCache.php index 055c0858f..945ddc089 100644 --- a/DataStorage/Cache/Connection/NullCache.php +++ b/DataStorage/Cache/Connection/NullCache.php @@ -27,7 +27,7 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $data) : void + public function connect(array $data = null) : void { } diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index d9dcbf23a..d8a48872b 100644 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -58,13 +58,13 @@ final class RedisCache extends ConnectionAbstract /** * Connect to cache * - * @param array{db:int, host:string, port:int} $data Cache data + * @param null|array{db:int, host:string, port:int} $data Cache data * * @return void * * @since 1.0.0 */ - public function connect(array $data) : void + public function connect(array $data = null) : void { $this->dbdata = isset($data) ? $data : $this->dbdata; diff --git a/DataStorage/DataStorageConnectionInterface.php b/DataStorage/DataStorageConnectionInterface.php index 57b6b04cc..46f40b581 100644 --- a/DataStorage/DataStorageConnectionInterface.php +++ b/DataStorage/DataStorageConnectionInterface.php @@ -29,13 +29,13 @@ interface DataStorageConnectionInterface * * Overwrites current connection if existing * - * @param string[] $data the basic datastorage information for establishing a connection + * @param null|array $data the basic datastorage information for establishing a connection * * @return void * * @since 1.0.0 */ - public function connect(array $data) : void; + public function connect(array $data = null) : void; /** * Get the datastorage type. diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index 22f5f7b5a..dbb36ebbb 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -25,6 +25,8 @@ use phpOMS\DataStorage\Database\Schema\Grammar\Grammar as SchemaGrammar; * Handles the database connection. * Implementing wrapper functions for multiple databases is planned (far away). * + * @property \PDO $con + * * @package phpOMS\DataStorage\Database\Connection * @license OMS License 1.0 * @link https://orange-management.org @@ -42,10 +44,10 @@ abstract class ConnectionAbstract implements ConnectionInterface * * This can be used externally to define queries and execute them. * - * @var null|\PDO + * @var \PDO * @since 1.0.0 */ - protected ?\PDO $con; + protected \PDO $con; /** * Database data. @@ -183,7 +185,7 @@ abstract class ConnectionAbstract implements ConnectionInterface */ public function close() : void { - $this->con = null; + $this->con = new NullPDO(); $this->status = DatabaseStatus::CLOSED; } @@ -194,6 +196,9 @@ abstract class ConnectionAbstract implements ConnectionInterface * * @return mixed Returns the value of the connection * + * @todo Orange-Management/phpOMS#218 + * As soon as readonly member variables are possible the magic methods should be removed. + * * @since 1.0.0 */ public function __get($name) diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index d996c0d19..66c2560c6 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -82,7 +82,7 @@ final class MysqlConnection extends ConnectionAbstract $this->status = DatabaseStatus::OK; } catch (\PDOException $e) { - $this->con = null; + $this->con = new NullPDO(); $this->status = DatabaseStatus::MISSING_DATABASE; } finally { $this->dbdata['password'] = '****'; diff --git a/DataStorage/Database/Connection/NullPDO.php b/DataStorage/Database/Connection/NullPDO.php new file mode 100644 index 000000000..d2f484e9f --- /dev/null +++ b/DataStorage/Database/Connection/NullPDO.php @@ -0,0 +1,36 @@ +status = DatabaseStatus::OK; } catch (\PDOException $e) { - $this->con = null; + $this->con = new NullPDO(); $this->status = DatabaseStatus::MISSING_DATABASE; throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata)); } finally { diff --git a/DataStorage/Database/Connection/SQLiteConnection.php b/DataStorage/Database/Connection/SQLiteConnection.php index 7281fe963..5e3f11a71 100644 --- a/DataStorage/Database/Connection/SQLiteConnection.php +++ b/DataStorage/Database/Connection/SQLiteConnection.php @@ -88,7 +88,7 @@ final class SQLiteConnection extends ConnectionAbstract $this->status = DatabaseStatus::OK; } catch (\PDOException $e) { - $this->con = null; + $this->con = new NullPDO(); $this->status = DatabaseStatus::MISSING_DATABASE; } finally { $this->dbdata['password'] = '****'; diff --git a/DataStorage/Database/Connection/SqlServerConnection.php b/DataStorage/Database/Connection/SqlServerConnection.php index 36b5444b9..688ba3a31 100644 --- a/DataStorage/Database/Connection/SqlServerConnection.php +++ b/DataStorage/Database/Connection/SqlServerConnection.php @@ -82,7 +82,7 @@ final class SqlServerConnection extends ConnectionAbstract $this->status = DatabaseStatus::OK; } catch (\PDOException $e) { - $this->con = null; + $this->con = new NullPDO(); $this->status = DatabaseStatus::MISSING_DATABASE; throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata)); } finally { diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 495828983..68c029676 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -161,7 +161,7 @@ class DataMapperAbstract implements DataMapperInterface * * Relation is defined in current mapper * - * @var array + * @var array * @since 1.0.0 */ protected static array $ownsOne = []; @@ -169,7 +169,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Belongs to. * - * @var array + * @var array * @since 1.0.0 */ protected static array $belongsTo = []; @@ -794,6 +794,7 @@ class DataMapperAbstract implements DataMapperInterface continue; } + /** @var \ReflectionClass $relReflectionClass */ $primaryKey = $mapper::getObjectId($value, $relReflectionClass); // already in db @@ -1022,7 +1023,6 @@ class DataMapperAbstract implements DataMapperInterface */ private static function createRelationTable(string $propertyName, array $objsIds, $objId) : void { - /** @var string $table */ if (empty($objsIds) || !isset(static::$hasMany[$propertyName]['external'])) { return; } @@ -1031,7 +1031,7 @@ class DataMapperAbstract implements DataMapperInterface $relQuery->into(static::$hasMany[$propertyName]['table']) ->insert(static::$hasMany[$propertyName]['external'], static::$hasMany[$propertyName]['self']); - foreach ($objsIds as $key => $src) { + foreach ($objsIds as $src) { if (\is_object($src)) { $mapper = (\stripos($mapper = \get_class($src), '\Null') !== false ? \str_replace('\Null', '\\', $mapper) @@ -1144,6 +1144,7 @@ class DataMapperAbstract implements DataMapperInterface continue; } + /** @var \ReflectionClass @relReflectionClass */ $primaryKey = $mapper::getObjectId($value, $relReflectionClass); // already in db @@ -2058,7 +2059,7 @@ class DataMapperAbstract implements DataMapperInterface * @param int $depth Relation depth * @param mixed $default Default value * - * @return void + * @return array * * @since 1.0.0 */ @@ -2138,7 +2139,7 @@ class DataMapperAbstract implements DataMapperInterface * @param int $depth Relation depth * @param mixed $default Default value * - * @return void + * @return array * * @since 1.0.0 */ @@ -2292,7 +2293,10 @@ class DataMapperAbstract implements DataMapperInterface continue; } - $value = $result[$alias]; + $value = $result[$alias]; + $hasPath = false; + $aValue = null; + $arrayPath = '/'; if (\stripos($member, '/') !== false) { $hasPath = true; @@ -2974,8 +2978,9 @@ class DataMapperAbstract implements DataMapperInterface $keys = $comparison === 'in' ? $keys : \reset($keys); $query ??= self::getQuery(null, [], $relations, $depth); + $hasBy = $ref === null ? false : isset(static::$columns[self::getColumnByMember($ref)]); - if ($ref === null || ($hasBy = isset(static::$columns[self::getColumnByMember($ref)]))) { + if ($ref === null || $hasBy) { $ref = $ref === null || !$hasBy ? static::$primaryField : static::$columns[self::getColumnByMember($ref)]['name']; if ($keys !== null && $keys !== false) { diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index bef84dbde..829c4f895 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -163,6 +163,8 @@ final class L11nManager try { /** @var ModuleAbstract $class */ $class = '\Modules\\' . $module . '\\Controller\\' . ($app ?? $this->appName) . 'Controller'; + + /** @var string $class */ if (!Autoloader::exists($class)) { return 'ERROR'; } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 677817059..8a656c6c5 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -738,7 +738,7 @@ class Matrix implements \ArrayAccess, \Iterator /** * {@inheritdoc} */ - public function valid() + public function valid() : bool { return $this->offsetExists($this->position); } diff --git a/Math/Number/Prime.php b/Math/Number/Prime.php index ee9a1c1ef..b936ef39c 100644 --- a/Math/Number/Prime.php +++ b/Math/Number/Prime.php @@ -76,25 +76,24 @@ final class Prime */ public static function rabinTest(int $n, int $k = 10000) : bool { - if ($n == 2) { + if ($n === 2) { return true; } - if ($n < 2 || $n % 2 == 0) { + if ($n < 2 || $n % 2 === 0) { return false; } $d = $n - 1; $s = 0; - while ($d % 2 == 0) { + while ($d % 2 === 0) { $d /= 2; ++$s; } for ($i = 0; $i < $k; ++$i) { $a = \mt_rand(2, $n - 1); - $x = \bcpowmod((string) $a, (string) $d, (string) $n); if ($x == 1 || $x == $n - 1) { @@ -102,9 +101,17 @@ final class Prime } for ($j = 1; $j < $s; ++$j) { - $x = \bcmod(\bcmul($x, $x), (string) $n); + if ($x === null) { + return false; + } - if ($x == 1) { + $mul = \bcmul($x, $x); + if ($mul === null) { + return false; + } + + $x = \bcmod($mul, (string) $n); + if ($x == 1 || $x === null) { return false; } diff --git a/Message/Console/ConsoleRequest.php b/Message/Console/ConsoleRequest.php index 1fab1883d..1d9980a19 100644 --- a/Message/Console/ConsoleRequest.php +++ b/Message/Console/ConsoleRequest.php @@ -47,14 +47,6 @@ final class ConsoleRequest extends RequestAbstract */ protected string $method; - /** - * Request hash. - * - * @var string[] - * @since 1.0.0 - */ - protected array $hash = []; - /** * OS type. * @@ -120,18 +112,6 @@ final class ConsoleRequest extends RequestAbstract } } - /** - * Get request hash. - * - * @return array - * - * @since 1.0.0 - */ - public function getHash() : array - { - return $this->hash; - } - /** * Set request method. * diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index bd9b10635..c2e1aeb1e 100644 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -64,14 +64,6 @@ final class HttpRequest extends RequestAbstract */ private array $info; - /** - * Request hash. - * - * @var string[] - * @since 1.0.0 - */ - protected array $hash = []; - /** * Constructor. * @@ -318,18 +310,6 @@ final class HttpRequest extends RequestAbstract } } - /** - * Get request hash. - * - * @return string[] - * - * @since 1.0.0 - */ - public function getHash() : array - { - return $this->hash; - } - /** * Set request method. * diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 66dae097e..d943257ff 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -66,6 +66,15 @@ abstract class RequestAbstract implements MessageInterface */ protected HeaderAbstract $header; + + /** + * Request hash. + * + * @var string[] + * @since 1.0.0 + */ + protected array $hash = []; + /** * Get data. * @@ -223,6 +232,18 @@ abstract class RequestAbstract implements MessageInterface return $this->header; } + /** + * Get request hash. + * + * @return string[] + * + * @since 1.0.0 + */ + public function getHash() : array + { + return $this->hash; + } + /** * Get the origin request source (IPv4/IPv6) * diff --git a/System/File/Ftp/Directory.php b/System/File/Ftp/Directory.php index 08299724f..6e9e34537 100644 --- a/System/File/Ftp/Directory.php +++ b/System/File/Ftp/Directory.php @@ -42,6 +42,14 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer */ private array $nodes = []; + /** + * Filter for directory listing + * + * @var string + * @since 1.0.0 + */ + private string $filter = '*'; + /** * Create ftp connection. * @@ -477,6 +485,10 @@ class Directory extends FileAbstract implements DirectoryInterface, FtpContainer } $list = \scandir($from); + if ($list === false) { + return false; + } + foreach ($list as $item) { if ($item === '.' || $item === '..') { continue; diff --git a/System/File/Ftp/File.php b/System/File/Ftp/File.php index 88f157a73..e9f8d1340 100644 --- a/System/File/Ftp/File.php +++ b/System/File/Ftp/File.php @@ -39,8 +39,8 @@ class File extends FileAbstract implements FileInterface /** * Create ftp connection * - * @param string $path Ftp path including username and password - * @param null|resource $con Connection + * @param HttpUri $uri Ftp uri/path including username and password + * @param null|resource $con Connection * * @since 1.0.0 */ @@ -162,15 +162,18 @@ class File extends FileAbstract implements FileInterface throw new PathException($path); } - $temp = \fopen('php://temp', 'r+'); - $content = ''; - - if (\ftp_fget($con, $temp, $path, \FTP_BINARY, 0)) { - \rewind($temp); - $content = \stream_get_contents($temp); + $fp = \fopen('php://temp', 'r+'); + if ($fp === false) { + return ''; } - return $content; + $content = ''; + if (\ftp_fget($con, $fp, $path, \FTP_BINARY, 0)) { + \rewind($fp); + $content = \stream_get_contents($fp); + } + + return $content === false ? '' : $content; } /** @@ -591,6 +594,13 @@ class File extends FileAbstract implements FileInterface return \dirname($this->path); } + /** + * Get directory of the file + * + * @return ContainerInterface + * + * @since 1.0.0 + */ public function getDirectory() : ContainerInterface { $uri = clone $this->uri; diff --git a/System/File/Ftp/FileAbstract.php b/System/File/Ftp/FileAbstract.php index a87dba0a3..8675688f5 100644 --- a/System/File/Ftp/FileAbstract.php +++ b/System/File/Ftp/FileAbstract.php @@ -40,7 +40,7 @@ abstract class FileAbstract implements ContainerInterface /** * Ftp uri * - * @var resource + * @var HttpUri * @since 1.0.0 */ protected HttpUri $uri; @@ -213,7 +213,7 @@ abstract class FileAbstract implements ContainerInterface $mtime = \ftp_mdtm($this->con, $this->path); $ctime = \ftp_mdtm($this->con, $this->path); - $this->createdAt->setTimestamp($mtime === false ? 0 : $mtime); + $this->createdAt = (new \DateTimeImmutable())->setTimestamp($mtime === false ? 0 : $mtime); $this->changedAt->setTimestamp($ctime === false ? 0 : $ctime); $owner = \fileowner($this->path); diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index ff2c32ec9..f42f08b26 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -29,8 +29,23 @@ use phpOMS\System\File\StorageAbstract; */ class FtpStorage extends StorageAbstract { + /** + * Connection + * + * @var resource + * @since 1.0.0 + */ private static $con = null; + /** + * Set connection + * + * @param resource $con Connection + * + * @return void + * + * @since 1.0.0 + */ public static function with($con) : void { self::$con = $con; diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 4ad35c27b..212a5df4b 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -42,7 +42,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * Directory nodes (files and directories). * - * @var FileAbstract[] + * @var ContainerInterface[] * @since 1.0.0 */ private array $nodes = []; @@ -400,6 +400,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC new \RecursiveDirectoryIterator($from, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item ) { + /** @var \RecursiveDirectoryIterator $iterator */ $subPath = $iterator->getSubPathname(); if ($item->isDir()) { @@ -563,7 +564,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC /** * {@inheritdoc} */ - public function valid() + public function valid() : bool { $key = \key($this->nodes); diff --git a/System/File/Local/File.php b/System/File/Local/File.php index adf44c2ea..8ef25b70c 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -515,6 +515,13 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn return new Directory(self::parent($this->path)); } + /** + * Get directory of the file + * + * @return ContainerInterface + * + * @since 1.0.0 + */ public function getDirectory() : ContainerInterface { return new Directory(self::dirpath($this->path)); diff --git a/Utils/Converter/File.php b/Utils/Converter/File.php index 0093142d9..7e64a14c6 100644 --- a/Utils/Converter/File.php +++ b/Utils/Converter/File.php @@ -49,9 +49,9 @@ final class File { if ($bytes < 1000) { return $bytes . 'b'; - } elseif ($bytes > 999 && $bytes < 1000000) { + } elseif ($bytes < 1000000) { return \rtrim(\rtrim(\number_format($bytes / 1000, 1, $decimal, $thousands), '0'), $decimal) . 'kb'; - } elseif ($bytes > 999999 && $bytes < 1000000000) { + } elseif ($bytes < 1000000000) { return \rtrim(\rtrim(\number_format($bytes / 1000000, 1, $decimal, $thousands), '0'), $decimal) . 'mb'; } @@ -73,7 +73,7 @@ final class File { if ($kilobytes < 1000) { return \rtrim(\rtrim(\number_format($kilobytes, 1, $decimal, $thousands), '0'), $decimal) . 'kb'; - } elseif ($kilobytes > 999 && $kilobytes < 1000000) { + } elseif ($kilobytes < 1000000) { return \rtrim(\rtrim(\number_format($kilobytes / 1000, 1, $decimal, $thousands), '0'), $decimal) . 'mb'; } diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index c91e89fe8..44d1fc0ec 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -210,7 +210,7 @@ abstract class ViewAbstract implements RenderableInterface /** * Get view/template response. * - * @param array ...$data Data to pass to renderer + * @param mixed ...$data Data to pass to renderer * * @return string * diff --git a/tests/DataStorage/Database/TestModel/BaseModelMapper.php b/tests/DataStorage/Database/TestModel/BaseModelMapper.php index f549ebcd3..7bf4dca58 100644 --- a/tests/DataStorage/Database/TestModel/BaseModelMapper.php +++ b/tests/DataStorage/Database/TestModel/BaseModelMapper.php @@ -41,7 +41,7 @@ class BaseModelMapper extends DataMapperAbstract /** * Belongs to. * - * @var array + * @var array * @since 1.0.0 */ protected static array $belongsTo = [