diff --git a/Algorithm/Clustering/Point.php b/Algorithm/Clustering/Point.php index 9b01a2aba..66a13b2f0 100644 --- a/Algorithm/Clustering/Point.php +++ b/Algorithm/Clustering/Point.php @@ -73,7 +73,7 @@ class Point implements PointInterface /** * {@inheritdoc} */ - public function getCoordinate(int $index) + public function getCoordinate(int $index) : int|float { return $this->coordinates[$index]; } diff --git a/Algorithm/Clustering/PointInterface.php b/Algorithm/Clustering/PointInterface.php index 99b6ea524..d3db932bd 100644 --- a/Algorithm/Clustering/PointInterface.php +++ b/Algorithm/Clustering/PointInterface.php @@ -46,7 +46,7 @@ interface PointInterface * * @since 1.0.0 */ - public function getCoordinate(int $index); + public function getCoordinate(int $index) : int|float; /** * Set the coordinate of the point diff --git a/Algorithm/Graph/DependencyResolver.php b/Algorithm/Graph/DependencyResolver.php index 5df540d32..729244f85 100644 --- a/Algorithm/Graph/DependencyResolver.php +++ b/Algorithm/Graph/DependencyResolver.php @@ -54,7 +54,7 @@ final class DependencyResolver * * @since 1.0.0 */ - private static function dependencyResolve($item, array $items, array &$resolved, array &$unresolved) : void + private static function dependencyResolve(int|string $item, array $items, array &$resolved, array &$unresolved) : void { $unresolved[] = $item; diff --git a/Config/OptionsTrait.php b/Config/OptionsTrait.php index 12a7c9d43..176bc8ede 100644 --- a/Config/OptionsTrait.php +++ b/Config/OptionsTrait.php @@ -37,13 +37,13 @@ trait OptionsTrait /** * Is this key set. * - * @param mixed $key Key to check for existence + * @param int|string $key Key to check for existence * * @return bool * * @since 1.0.0 */ - public function exists($key) : bool + public function exists(int|string $key) : bool { return isset($this->options[$key]); } @@ -51,13 +51,13 @@ trait OptionsTrait /** * Get option by key. * - * @param mixed $key Unique option key + * @param int|string $key Unique option key * * @return mixed Option value * * @since 1.0.0 */ - public function getOption($key) + public function getOption(int|string $key) : mixed { return $this->options[$key] ?? null; } @@ -65,13 +65,13 @@ trait OptionsTrait /** * Get options by keys. * - * @param array $key Unique option key + * @param array $key Unique option key * * @return array Option values * * @since 1.0.0 */ - public function getOptions(array $key) + public function getOptions(array $key) : array { $options = []; @@ -87,15 +87,15 @@ trait OptionsTrait /** * Updating or adding settings. * - * @param mixed $key Unique option key - * @param mixed $value Option value - * @param bool $overwrite Overwrite existing value + * @param int|string $key Unique option key + * @param mixed $value Option value + * @param bool $overwrite Overwrite existing value * * @return bool * * @since 1.0.0 */ - public function setOption($key, $value, bool $overwrite = true) : bool + public function setOption(int|string $key, mixed $value, bool $overwrite = true) : bool { if ($overwrite || !isset($this->options[$key])) { $this->options[$key] = $value; diff --git a/DataStorage/Cache/Connection/ConnectionInterface.php b/DataStorage/Cache/Connection/ConnectionInterface.php index 57bf90f80..a72ba2729 100644 --- a/DataStorage/Cache/Connection/ConnectionInterface.php +++ b/DataStorage/Cache/Connection/ConnectionInterface.php @@ -29,52 +29,52 @@ interface ConnectionInterface extends DataStorageConnectionInterface /** * Updating or adding cache data. * - * @param mixed $key Unique cache key - * @param mixed $value Cache value - * @param int $expire Valid duration (in s). Negative expiration means no expiration. + * @param int|string $key Unique cache key + * @param mixed $value Cache value + * @param int $expire Valid duration (in s). Negative expiration means no expiration. * * @return void * * @since 1.0.0 */ - public function set($key, $value, int $expire = -1) : void; + public function set(int|string $key, mixed $value, int $expire = -1) : void; /** * Adding new data if it doesn't exist. * - * @param mixed $key Unique cache key - * @param mixed $value Cache value - * @param int $expire Valid duration (in s) + * @param int|string $key Unique cache key + * @param mixed $value Cache value + * @param int $expire Valid duration (in s) * * @return bool * * @since 1.0.0 */ - public function add($key, $value, int $expire = -1) : bool; + public function add(int|string $key, mixed $value, int $expire = -1) : bool; /** * Get cache by key. * - * @param mixed $key Unique cache key - * @param int $expire Valid duration (in s). In case the data needs to be newer than the defined expiration time. If the expiration date is larger than the defined expiration time and supposed to be expired it will not remove the outdated cache. + * @param int|string $key Unique cache key + * @param int $expire Valid duration (in s). In case the data needs to be newer than the defined expiration time. If the expiration date is larger than the defined expiration time and supposed to be expired it will not remove the outdated cache. * * @return mixed Cache value * * @since 1.0.0 */ - public function get($key, int $expire = -1); + public function get(int|string $key, int $expire = -1) : mixed; /** * Remove value by key. * - * @param mixed $key Unique cache key - * @param int $expire Valid duration (in s) + * @param int|string $key Unique cache key + * @param int $expire Valid duration (in s) * * @return bool * * @since 1.0.0 */ - public function delete($key, int $expire = -1) : bool; + public function delete(int|string $key, int $expire = -1) : bool; /** * Removing all cache elements larger or equal to the expiration date. Call flushAll for removing persistent cache elements (expiration is negative) as well. @@ -99,15 +99,15 @@ interface ConnectionInterface extends DataStorageConnectionInterface /** * Updating existing value/key. * - * @param mixed $key Unique cache key - * @param mixed $value Cache value - * @param int $expire Valid duration (in s) + * @param int|string $key Unique cache key + * @param mixed $value Cache value + * @param int $expire Valid duration (in s) * * @return bool * * @since 1.0.0 */ - public function replace($key, $value, int $expire = -1) : bool; + public function replace(int|string $key, mixed $value, int $expire = -1) : bool; /** * Requesting cache stats. diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index d507d2ec5..038bf75eb 100644 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -147,7 +147,7 @@ final class FileCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) : void + public function set(int|string $key, mixed $value, int $expire = -1) : void { if ($this->status !== CacheStatus::OK) { return; @@ -161,7 +161,7 @@ final class FileCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function add($key, $value, int $expire = -1) : bool + public function add(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -188,7 +188,7 @@ final class FileCache extends ConnectionAbstract * * @since 1.0.0 */ - private function build($value, int $expire) : string + private function build(mixed $value, int $expire) : string { $type = $this->dataType($value); $raw = $this->stringify($value, $type); @@ -208,7 +208,7 @@ final class FileCache extends ConnectionAbstract * * @since 1.0.0 */ - private function stringify($value, int $type) : string + private function stringify(mixed $value, int $type) : string { if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) { return (string) $value; @@ -247,7 +247,7 @@ final class FileCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function get($key, int $expire = -1) + public function get(int|string $key, int $expire = -1) : mixed { if ($this->status !== CacheStatus::OK) { return null; @@ -348,7 +348,7 @@ final class FileCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function delete($key, int $expire = -1) : bool + public function delete(int|string $key, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -418,7 +418,7 @@ final class FileCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function replace($key, $value, int $expire = -1) : bool + public function replace(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -444,7 +444,7 @@ final class FileCache extends ConnectionAbstract * * @since 1.0.0 */ - private function getPath($key) : string + private function getPath(int|string $key) : string { $path = Directory::sanitize($key, self::SANITIZE); return $this->con . '/' . \trim($path, '/') . '.cache'; diff --git a/DataStorage/Cache/Connection/MemCached.php b/DataStorage/Cache/Connection/MemCached.php index d86a1e237..37d29b044 100644 --- a/DataStorage/Cache/Connection/MemCached.php +++ b/DataStorage/Cache/Connection/MemCached.php @@ -80,7 +80,7 @@ final class MemCached extends ConnectionAbstract /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) : void + public function set(int|string $key, mixed $value, int $expire = -1) : void { if ($this->status !== CacheStatus::OK) { return; @@ -96,7 +96,7 @@ final class MemCached extends ConnectionAbstract /** * {@inheritdoc} */ - public function add($key, $value, int $expire = -1) : bool + public function add(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -112,7 +112,7 @@ final class MemCached extends ConnectionAbstract /** * {@inheritdoc} */ - public function get($key, int $expire = -1) + public function get(int|string $key, int $expire = -1) : mixed { if ($this->status !== CacheStatus::OK) { return null; @@ -130,7 +130,7 @@ final class MemCached extends ConnectionAbstract /** * {@inheritdoc} */ - public function delete($key, int $expire = -1) : bool + public function delete(int|string $key, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -164,7 +164,7 @@ final class MemCached extends ConnectionAbstract /** * {@inheritdoc} */ - public function replace($key, $value, int $expire = -1) : bool + public function replace(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; diff --git a/DataStorage/Cache/Connection/NullCache.php b/DataStorage/Cache/Connection/NullCache.php index 945ddc089..93e454083 100644 --- a/DataStorage/Cache/Connection/NullCache.php +++ b/DataStorage/Cache/Connection/NullCache.php @@ -34,14 +34,14 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) : void + public function set(int|string $key, mixed $value, int $expire = -1) : void { } /** * {@inheritdoc} */ - public function add($key, $value, int $expire = -1) : bool + public function add(int|string $key, mixed $value, int $expire = -1) : bool { return true; } @@ -49,7 +49,7 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function get($key, int $expire = -1) + public function get(int|string $key, int $expire = -1) : mixed { return null; } @@ -57,7 +57,7 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function delete($key, int $expire = -1) : bool + public function delete(int|string $key, int $expire = -1) : bool { return true; } @@ -81,7 +81,7 @@ final class NullCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function replace($key, $value, int $expire = -1) : bool + public function replace(int|string $key, mixed $value, int $expire = -1) : bool { return true; } diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index d8a48872b..aef5f6ae2 100644 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -104,7 +104,7 @@ final class RedisCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) : void + public function set(int|string $key, mixed $value, int $expire = -1) : void { if ($this->status !== CacheStatus::OK) { return; @@ -122,7 +122,7 @@ final class RedisCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function add($key, $value, int $expire = -1) : bool + public function add(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -138,7 +138,7 @@ final class RedisCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function get($key, int $expire = -1) + public function get(int|string $key, int $expire = -1) : mixed { if ($this->status !== CacheStatus::OK || $this->con->exists($key) < 1) { return null; @@ -158,7 +158,7 @@ final class RedisCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function delete($key, int $expire = -1) : bool + public function delete(int|string $key, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -192,7 +192,7 @@ final class RedisCache extends ConnectionAbstract /** * {@inheritdoc} */ - public function replace($key, $value, int $expire = -1) : bool + public function replace(int|string $key, mixed $value, int $expire = -1) : bool { if ($this->status !== CacheStatus::OK) { return false; @@ -253,7 +253,7 @@ final class RedisCache extends ConnectionAbstract * * @since 1.0.0 */ - private function build($value) + private function build(mixed $value) { $type = $this->dataType($value); $raw = $this->cachify($value, $type); @@ -273,7 +273,7 @@ final class RedisCache extends ConnectionAbstract * * @since 1.0.0 */ - private function cachify($value, int $type) + private function cachify(mixed $value, int $type) { if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) { return (string) $value; @@ -303,7 +303,7 @@ final class RedisCache extends ConnectionAbstract * * @since 1.0.0 */ - private function reverseValue(int $type, $raw, int $start) + private function reverseValue(int $type, mixed $raw, int $start) { switch ($type) { case CacheValueType::_INT: diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index c0e9e5e63..93399c1ec 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -121,7 +121,7 @@ final class CookieJar * * @since 1.0.0 */ - public function get(string $id) + public function get(string $id) : mixed { return $this->cookies[$id] ?? null; } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index fb6891159..04e26a6d4 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -465,7 +465,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function create($obj, int $relations = RelationType::ALL) + public static function create($obj, int $relations = RelationType::ALL) : mixed { if (!isset($obj)) { return null; @@ -507,7 +507,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function createArray(array &$obj, int $relations = RelationType::ALL) + public static function createArray(array &$obj, int $relations = RelationType::ALL) : mixed { self::$relations = $relations; @@ -538,7 +538,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createModel(object $obj, \ReflectionClass $refClass) + private static function createModel(object $obj, \ReflectionClass $refClass) : mixed { $query = new Builder(self::$db); $query->into(static::$table); @@ -616,7 +616,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createModelArray(array &$obj) + private static function createModelArray(array &$obj) : mixed { $query = new Builder(self::$db); $query->into(static::$table); @@ -670,7 +670,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function getObjectId(object $obj, \ReflectionClass $refClass = null) + public static function getObjectId(object $obj, \ReflectionClass $refClass = null) : mixed { $refClass ??= new \ReflectionClass($obj); $propertyName = static::$columns[static::$primaryField]['internal']; @@ -943,7 +943,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createOwnsOne(string $propertyName, $obj) + private static function createOwnsOne(string $propertyName, $obj) : mixed { if (!\is_object($obj)) { return $obj; @@ -972,7 +972,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createOwnsOneArray(string $propertyName, array &$obj) + private static function createOwnsOneArray(string $propertyName, array &$obj) : mixed { /** @var self $mapper */ $mapper = static::$ownsOne[$propertyName]['mapper']; @@ -993,7 +993,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createBelongsTo(string $propertyName, $obj) + private static function createBelongsTo(string $propertyName, $obj) : mixed { if (!\is_object($obj)) { return $obj; @@ -1018,7 +1018,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function createBelongsToArray(string $propertyName, array $obj) + private static function createBelongsToArray(string $propertyName, array $obj) : mixed { /** @var self $mapper */ $mapper = static::$belongsTo[$propertyName]['mapper']; @@ -1081,7 +1081,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function parseValue(string $type, $value = null) + private static function parseValue(string $type, $value = null) : mixed { if ($value === null) { return null; @@ -1277,7 +1277,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function updateRelationTable(array $objsIds, $objId) + private static function updateRelationTable(array $objsIds, $objId) : mixed { $many = self::getHasManyRaw($objId); @@ -1339,7 +1339,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function updateOwnsOne(string $propertyName, $obj, int $depth = 1) + private static function updateOwnsOne(string $propertyName, $obj, int $depth = 1) : mixed { if (!\is_object($obj)) { return $obj; @@ -1364,7 +1364,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function updateOwnsOneArray(string $propertyName, array $obj, int $depth = 1) + private static function updateOwnsOneArray(string $propertyName, array $obj, int $depth = 1) : mixed { /** @var self $mapper */ $mapper = static::$ownsOne[$propertyName]['mapper']; @@ -1385,7 +1385,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function updateBelongsTo(string $propertyName, $obj, int $depth = 1) + private static function updateBelongsTo(string $propertyName, $obj, int $depth = 1) : mixed { if (!\is_object($obj)) { return $obj; @@ -1410,7 +1410,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function updateBelongsToArray(string $propertyName, $obj, int $depth = 1) + private static function updateBelongsToArray(string $propertyName, $obj, int $depth = 1) : mixed { if (!\is_array($obj)) { return $obj; @@ -1572,7 +1572,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function update($obj, int $relations = RelationType::ALL, int $depth = 3) + public static function update($obj, int $relations = RelationType::ALL, int $depth = 3) : mixed { if (!isset($obj)) { return null; @@ -1615,7 +1615,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function updateArray(array &$obj, int $relations = RelationType::ALL, int $depth = 1) + public static function updateArray(array &$obj, int $relations = RelationType::ALL, int $depth = 1) : mixed { if (empty($obj)) { return null; @@ -1731,7 +1731,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function deleteOwnsOne(string $propertyName, $obj) + private static function deleteOwnsOne(string $propertyName, $obj) : mixed { if (!\is_object($obj)) { return $obj; @@ -1761,7 +1761,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - private static function deleteBelongsTo(string $propertyName, $obj) + private static function deleteBelongsTo(string $propertyName, $obj) : mixed { if (!\is_object($obj)) { return $obj; @@ -1847,7 +1847,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function delete($obj, int $relations = RelationType::REFERENCE) + public static function delete($obj, int $relations = RelationType::REFERENCE) : mixed { // @todo: only do this if RelationType !== NONE if (\is_scalar($obj)) { @@ -2039,7 +2039,7 @@ class DataMapperAbstract implements DataMapperInterface * * @since 1.0.0 */ - public static function populateOwnsOne(string $member, array $result, int $depth = 3, $default = null) + public static function populateOwnsOne(string $member, array $result, int $depth = 3, $default = null) : mixed { /** @var self $mapper */ $mapper = static::$ownsOne[$member]['mapper']; diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 724021e80..d34a41d63 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -297,7 +297,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function selectAs($column, string $alias) : self + public function selectAs(mixed $column, string $alias) : self { $this->type = QueryType::SELECT; $this->selects[$alias] = $column; @@ -327,20 +327,18 @@ class Builder extends BuilderAbstract /** * Bind parameter. * - * @param mixed $binds Binds + * @param string|array $binds Binds * * @return Builder * * @since 1.0.0 */ - public function bind($binds) : self + public function bind(string|array $binds) : self { if (\is_array($binds)) { $this->binds += $binds; - } elseif (\is_string($binds)) { - $this->binds[] = $binds; } else { - throw new \InvalidArgumentException(); + $this->binds[] = $binds; } return $this; @@ -522,7 +520,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function fromAs($column, string $alias) : self + public function fromAs(mixed $column, string $alias) : self { $this->from[$alias] = $column; @@ -532,10 +530,10 @@ class Builder extends BuilderAbstract /** * Where. * - * @param array|string|Where $columns Columns - * @param array|string $operator Operator + * @param string|array|Where $columns Columns + * @param string|array $operator Operator * @param mixed $values Values - * @param array|string $boolean Boolean condition + * @param string|array $boolean Boolean condition * * @return Builder * @@ -543,7 +541,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function where($columns, $operator = null, $values = null, $boolean = 'and') : self + public function where(string|array|Where $columns, string|array $operator = null, mixed $values = null, string|array $boolean = 'and') : self { if (!\is_array($columns)) { $columns = [$columns]; @@ -574,15 +572,15 @@ class Builder extends BuilderAbstract /** * Where and sub condition. * - * @param array|string|Where $where Where sub condition - * @param mixed $operator Operator + * @param string|array|Where $where Where sub condition + * @param string|array $operator Operator * @param mixed $values Values * * @return Builder * * @since 1.0.0 */ - public function andWhere($where, $operator = null, $values = null) : self + public function andWhere(string|array|Where $where, string|array $operator = null, mixed $values = null) : self { return $this->where($where, $operator, $values, 'and'); } @@ -590,15 +588,15 @@ class Builder extends BuilderAbstract /** * Where or sub condition. * - * @param array|string|Where $where Where sub condition - * @param mixed $operator Operator + * @param string|array|Where $where Where sub condition + * @param string|array $operator Operator * @param mixed $values Values * * @return Builder * * @since 1.0.0 */ - public function orWhere($where, $operator = null, $values = null) : self + public function orWhere(string|array|Where $where, string|array $operator = null, mixed $values = null) : self { return $this->where($where, $operator, $values, 'or'); } @@ -606,15 +604,15 @@ class Builder extends BuilderAbstract /** * Where in. * - * @param array|string|Where $column Column - * @param mixed $values Values + * @param string|array|Where $column Column + * @param string|array $values Values * @param string $boolean Boolean condition * * @return Builder * * @since 1.0.0 */ - public function whereIn($column, $values = null, string $boolean = 'and') : self + public function whereIn(string|array|Where $column, mixed $values = null, string $boolean = 'and') : self { $this->where($column, 'in', $values, $boolean); @@ -624,14 +622,14 @@ class Builder extends BuilderAbstract /** * Where null. * - * @param array|string|Where $column Column + * @param string|array|Where $column Column * @param string $boolean Boolean condition * * @return Builder * * @since 1.0.0 */ - public function whereNull($column, string $boolean = 'and') : self + public function whereNull(string|array|Where $column, string $boolean = 'and') : self { $this->where($column, '=', null, $boolean); @@ -641,14 +639,14 @@ class Builder extends BuilderAbstract /** * Where not null. * - * @param array|string|Where $column Column + * @param string|array|Where $column Column * @param string $boolean Boolean condition * * @return Builder * * @since 1.0.0 */ - public function whereNotNull($column, string $boolean = 'and') : self + public function whereNotNull(string|array|Where $column, string $boolean = 'and') : self { $this->where($column, '!=', null, $boolean); @@ -714,14 +712,14 @@ class Builder extends BuilderAbstract /** * Order by oldest. * - * @param array|string $columns Columns + * @param string|array $columns Columns * @param string|string[] $order Orders * * @return Builder * * @since 1.0.0 */ - public function orderBy($columns, $order = 'DESC') : self + public function orderBy(string|array $columns, string|array $order = 'DESC') : self { if (\is_string($columns)) { if (!\is_string($order)) { @@ -733,12 +731,10 @@ class Builder extends BuilderAbstract } $this->orders[$order][] = $columns; - } elseif (\is_array($columns)) { + } else { foreach ($columns as $key => $column) { $this->orders[\is_string($order) ? $order : $order[$key]][] = $column; } - } else { - throw new \InvalidArgumentException(); } return $this; @@ -785,7 +781,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function union($query) : self + public function union(mixed $query) : self { if (!\is_array($query)) { $this->unions[] = $query; @@ -983,7 +979,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function value($value) : self + public function value(mixed $value) : self { \end($this->values); @@ -1026,7 +1022,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function set($set) : self + public function set(mixed $set) : self { $this->sets[\key($set)] = \current($set); @@ -1116,14 +1112,8 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function join($table, string $type = JoinType::JOIN, string $alias = null) : self + public function join(string|self $table, string $type = JoinType::JOIN, string $alias = null) : self { - if ((!\is_string($table) && !($table instanceof self)) - || ($alias === null && !\is_string($table)) - ) { - throw new \InvalidArgumentException(); - } - $this->joins[$alias ?? $table] = ['type' => $type, 'table' => $table, 'alias' => $alias]; return $this; @@ -1132,14 +1122,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function leftJoin($column, string $alias = null) : self + public function leftJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::LEFT_JOIN, $alias); } @@ -1147,14 +1137,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function leftOuterJoin($column, string $alias = null) : self + public function leftOuterJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::LEFT_OUTER_JOIN, $alias); } @@ -1162,14 +1152,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function leftInnerJoin($column, string $alias = null) : self + public function leftInnerJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::LEFT_INNER_JOIN, $alias); } @@ -1177,14 +1167,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function rightJoin($column, string $alias = null) : self + public function rightJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::RIGHT_JOIN, $alias); } @@ -1192,14 +1182,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function rightOuterJoin($column, string $alias = null) : self + public function rightOuterJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::RIGHT_OUTER_JOIN, $alias); } @@ -1207,14 +1197,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function rightInnerJoin($column, string $alias = null) : self + public function rightInnerJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::RIGHT_INNER_JOIN, $alias); } @@ -1222,14 +1212,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function outerJoin($column, string $alias = null) : self + public function outerJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::OUTER_JOIN, $alias); } @@ -1237,14 +1227,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function innerJoin($column, string $alias = null) : self + public function innerJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::INNER_JOIN, $alias); } @@ -1252,14 +1242,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function crossJoin($column, string $alias = null) : self + public function crossJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::CROSS_JOIN, $alias); } @@ -1267,14 +1257,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function fullJoin($column, string $alias = null) : self + public function fullJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::FULL_JOIN, $alias); } @@ -1282,14 +1272,14 @@ class Builder extends BuilderAbstract /** * Join. * - * @param mixed $column Join query + * @param string|self $column Join query * @param null|string $alias Alias name (empty = none) * * @return Builder * * @since 1.0.0 */ - public function fullOuterJoin($column, string $alias = null) : self + public function fullOuterJoin(string|self $column, string $alias = null) : self { return $this->join($column, JoinType::FULL_OUTER_JOIN, $alias); } @@ -1319,7 +1309,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function on($columns, $operator = null, $values = null, $boolean = 'and', string $table = null) : self + public function on(string|array $columns, string|array $operator = null, string|array $values = null, string|array $boolean = 'and', string $table = null) : self { if ($operator !== null && !\is_array($operator) && !\in_array(\strtolower($operator), self::OPERATORS)) { throw new \InvalidArgumentException('Unknown operator.'); @@ -1365,7 +1355,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function orOn($columns, $operator = null, $values = null) : self + public function orOn(string|array $columns, $operator = null, $values = null) : self { return $this->on($columns, $operator, $values, 'or'); } @@ -1381,7 +1371,7 @@ class Builder extends BuilderAbstract * * @since 1.0.0 */ - public function andOn($columns, $operator = null, $values = null) : self + public function andOn(string|array $columns, $operator = null, $values = null) : self { return $this->on($columns, $operator, $values, 'and'); } diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index 46bc8886c..b4e19088b 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -254,7 +254,7 @@ final class L11nManager * * @since 1.0.0 */ - public function getCurrency(Localization $l11n, $currency, string $format = null, string $symbol = null, int $divide = 1) : string + public function getCurrency(Localization $l11n, int|float $currency, string $format = null, string $symbol = null, int $divide = 1) : string { $language = $l11n->getLanguage() ?? 'en'; $symbol ??= $l11n->getCurrency(); diff --git a/Localization/Money.php b/Localization/Money.php index 7f57b762a..f0ad6ca53 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -83,7 +83,7 @@ final class Money implements \Serializable * * @since 1.0.0 */ - public function __construct($value = 0, string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) + public function __construct(int|float|string $value = 0, string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) { $this->value = \is_int($value) ? $value : self::toInt((string) $value); $this->thousands = $thousands; @@ -216,19 +216,19 @@ final class Money implements \Serializable /** * Add money. * - * @param int|float|Money|string $value Value to add + * @param int|float|string|Money $value Value to add * * @return Money * * @since 1.0.0 */ - public function add($value) : self + public function add(int|float|string|self $value) : self { if (\is_string($value) || \is_float($value)) { $this->value += self::toInt((string) $value, $this->thousands, $this->decimal); } elseif (\is_int($value)) { $this->value += $value; - } elseif ($value instanceof self) { + } else { $this->value += $value->getInt(); } @@ -250,19 +250,19 @@ final class Money implements \Serializable /** * Sub money. * - * @param int|float|Money|string $value Value to subtract + * @param int|float|string|Money $value Value to subtract * * @return Money * * @since 1.0.0 */ - public function sub($value) : self + public function sub(int|float|string|self $value) : self { if (\is_string($value) || \is_float($value)) { $this->value -= self::toInt((string) $value, $this->thousands, $this->decimal); } elseif (\is_int($value)) { $this->value -= $value; - } elseif ($value instanceof self) { + } else { $this->value -= $value->getInt(); } diff --git a/Math/Functions/Gamma.php b/Math/Functions/Gamma.php index ae6019707..c1b4473ba 100644 --- a/Math/Functions/Gamma.php +++ b/Math/Functions/Gamma.php @@ -43,7 +43,7 @@ final class Gamma * * @since 1.0.0 */ - public static function gamma($z) : float + public static function gamma(int|float $z) : float { return \exp(self::logGamma($z)); } @@ -68,7 +68,7 @@ final class Gamma * * @since 1.0.0 */ - public static function lanczosApproximationReal($z) : float + public static function lanczosApproximationReal(int|float $z) : float { if ($z < 0.5) { return \M_PI / (\sin(\M_PI * $z) * self::lanczosApproximationReal(1 - $z)); @@ -94,7 +94,7 @@ final class Gamma * * @since 1.0.0 */ - public static function stirlingApproximation($x) : float + public static function stirlingApproximation(int|float $x) : float { return \sqrt(2.0 * \M_PI / $x) * \pow($x / \M_E, $x); } @@ -108,7 +108,7 @@ final class Gamma * * @since 1.0.0 */ - public static function spougeApproximation($z) : float + public static function spougeApproximation(int|float $z) : float { $k1_fact = 1.0; $c = [\sqrt(2.0 * \M_PI)]; @@ -139,7 +139,7 @@ final class Gamma * * @since 1.0.0 */ - public static function logGamma($z) : float + public static function logGamma(int|float $z) : float { static $approx = [ 76.18009172947146,-86.50532032941677, diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index d775c10c2..5d37ef528 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -109,7 +109,7 @@ class Matrix implements \ArrayAccess, \Iterator * * @since 1.0.0 */ - public function set(int $m, int $n, $value) : void + public function set(int $m, int $n, int|float $value) : void { if (!isset($this->matrix[$m], $this->matrix[$m][$n])) { throw new InvalidDimensionException($m . 'x' . $n); @@ -130,7 +130,7 @@ class Matrix implements \ArrayAccess, \Iterator * * @since 1.0.0 */ - public function get(int $m, int $n = 0) + public function get(int $m, int $n = 0) : int|float { if (!isset($this->matrix[$m], $this->matrix[$m][$n])) { throw new InvalidDimensionException($m . 'x' . $n); diff --git a/Math/Matrix/Vector.php b/Math/Matrix/Vector.php index 5ef6cd74a..3e6225710 100644 --- a/Math/Matrix/Vector.php +++ b/Math/Matrix/Vector.php @@ -65,7 +65,7 @@ final class Vector extends Matrix * * @since 1.0.0 */ - public function getV(int $m) + public function getV(int $m) : int|float { return parent::get($m, 0); } diff --git a/Math/Number/Complex.php b/Math/Number/Complex.php index 092a25031..ce40e7cf9 100644 --- a/Math/Number/Complex.php +++ b/Math/Number/Complex.php @@ -48,7 +48,7 @@ final class Complex * * @since 1.0.0 */ - public function __construct($re = 0, $im = 0) + public function __construct(int|float $re = 0, int|float $im = 0) { $this->re = $re; $this->im = $im; @@ -61,7 +61,7 @@ final class Complex * * @since 1.0.0 */ - public function re() + public function re() : int|float { return $this->re; } @@ -73,7 +73,7 @@ final class Complex * * @since 1.0.0 */ - public function im() + public function im() : int|float { return $this->im; } @@ -129,7 +129,7 @@ final class Complex * * @since 1.0.0 */ - public function abs() + public function abs() : int|float { return \sqrt($this->re ** 2 + $this->im ** 2); } @@ -149,25 +149,21 @@ final class Complex /** * Pow opperator * - * @param mixed $value Value to pow + * @param int|float|self $value Value to pow * * @return Complex * - * @throws \InvalidArgumentException This exception is thrown if the argument has an invalid type - * * @since 1.0.0 */ - public function pow($value) : self + public function pow(int|float|self $value) : self { if (\is_int($value)) { return $this->powInteger($value); } elseif (\is_float($value)) { return $this->powScalar($value); - } elseif ($value instanceof self) { - return $this->powComplex($value); } - throw new \InvalidArgumentException(); + return $this->powComplex($value); } /** @@ -213,7 +209,7 @@ final class Complex * * @since 1.0.0 */ - public function powScalar($value) : self + public function powScalar(int|float $value) : self { return $this; } diff --git a/Math/Numerics/Interpolation/CubicSplineInterpolation.php b/Math/Numerics/Interpolation/CubicSplineInterpolation.php index 4063096ee..e43ca110f 100644 --- a/Math/Numerics/Interpolation/CubicSplineInterpolation.php +++ b/Math/Numerics/Interpolation/CubicSplineInterpolation.php @@ -144,7 +144,7 @@ final class CubicSplineInterpolation implements InterpolationInterface /** * {@inheritdoc} */ - public function interpolate($x) : float + public function interpolate(int|float $x) : float { $n = \count($this->points); $xPos = $n - 1; diff --git a/Math/Numerics/Interpolation/InterpolationInterface.php b/Math/Numerics/Interpolation/InterpolationInterface.php index 8d8ffc3b6..128ee73f8 100644 --- a/Math/Numerics/Interpolation/InterpolationInterface.php +++ b/Math/Numerics/Interpolation/InterpolationInterface.php @@ -33,5 +33,5 @@ interface InterpolationInterface * * @since 1.0.0 */ - public function interpolate($x) : float; + public function interpolate(int|float $x) : float; } diff --git a/Math/Numerics/Interpolation/LagrangeInterpolation.php b/Math/Numerics/Interpolation/LagrangeInterpolation.php index d85a2b128..df4abd206 100644 --- a/Math/Numerics/Interpolation/LagrangeInterpolation.php +++ b/Math/Numerics/Interpolation/LagrangeInterpolation.php @@ -46,7 +46,7 @@ final class LagrangeInterpolation implements InterpolationInterface /** * {@inheritdoc} */ - public function interpolate($x) : float + public function interpolate(int|float $x) : float { $n = \count($this->points); $result = 0.0; diff --git a/Math/Numerics/Interpolation/LinearInterpolation.php b/Math/Numerics/Interpolation/LinearInterpolation.php index 04fa6bda9..552c2cc66 100644 --- a/Math/Numerics/Interpolation/LinearInterpolation.php +++ b/Math/Numerics/Interpolation/LinearInterpolation.php @@ -96,7 +96,7 @@ final class LinearInterpolation implements InterpolationInterface /** * {@inheritdoc} */ - public function interpolate($x) : float + public function interpolate(int|float $x) : float { $n = \count($this->points); $xPos = $n - 1; diff --git a/Math/Statistic/Forecast/Error.php b/Math/Statistic/Forecast/Error.php index 0a06dcc90..1e587ec73 100644 --- a/Math/Statistic/Forecast/Error.php +++ b/Math/Statistic/Forecast/Error.php @@ -171,7 +171,7 @@ final class Error */ public static function getRootMeanSquaredError(array $errors) : float { - return \sqrt(Average::arithmeticMean(ArrayUtils::powerInt($errors, 2))); + return \sqrt(Average::arithmeticMean(ArrayUtils::power($errors, 2))); } /** @@ -290,7 +290,7 @@ final class Error */ public static function getMeanSquaredScaledError(array $scaledErrors) : float { - return Average::arithmeticMean(ArrayUtils::powerInt($scaledErrors, 2)); + return Average::arithmeticMean(ArrayUtils::power($scaledErrors, 2)); } /** diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 5ed67abb1..8d55d2acf 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -316,15 +316,17 @@ abstract class ModuleAbstract * * @since 1.0.0 */ - protected function updateModel(int $account, $old, $new, $mapper, string $trigger, string $ip) : void + protected function updateModel(int $account, mixed $old, mixed $new, string|\Closure $mapper, string $trigger, string $ip) : void { $this->app->eventManager->triggerSimilar('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-update', '', $old); $id = 0; + if (\is_string($mapper)) { $id = $mapper::update($new); - } elseif ($mapper instanceof \Closure) { + } else { $mapper(); } + $this->app->eventManager->triggerSimilar('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-update', '', [ $account, $old, $new, @@ -349,7 +351,7 @@ abstract class ModuleAbstract * * @since 1.0.0 */ - protected function deleteModel(int $account, $obj, string $mapper, string $trigger, string $ip) : void + protected function deleteModel(int $account, mixed $obj, string $mapper, string $trigger, string $ip) : void { $this->app->eventManager->triggerSimilar('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', $obj); $id = $mapper::delete($obj); @@ -379,7 +381,7 @@ abstract class ModuleAbstract * * @since 1.0.0 */ - protected function createModelRelation(int $account, $rel1, $rel2, string $mapper, string $field, string $trigger, string $ip) : void + protected function createModelRelation(int $account, mixed $rel1, mixed $rel2, string $mapper, string $field, string $trigger, string $ip) : void { $this->app->eventManager->triggerSimilar('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-relation', '', $rel1); $mapper::createRelation($field, $rel1, $rel2); diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 0f1c6525b..29167e11e 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -719,7 +719,7 @@ final class ModuleManager * * @since 1.0.0 */ - public function initModule($modules) : void + public function initModule(string|array $modules) : void { $modules = (array) $modules; foreach ($modules as $module) { diff --git a/Stdlib/Base/Enum.php b/Stdlib/Base/Enum.php index 13db871be..73aac083d 100644 --- a/Stdlib/Base/Enum.php +++ b/Stdlib/Base/Enum.php @@ -84,7 +84,7 @@ abstract class Enum * * @since 1.0.0 */ - public static function getByName(string $name) + public static function getByName(string $name) : mixed { if (!self::isValidName($name)) { throw new \UnexpectedValueException($name); @@ -102,7 +102,7 @@ abstract class Enum * * @since 1.0.0 */ - public static function getName(string $value) + public static function getName(string $value) : bool|int|string { $arr = self::getConstants(); diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index e1c166d1b..faae6dac4 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -88,7 +88,7 @@ class Graph * * @since 1.0.0 */ - public function getNode($key) : ?Node + public function getNode(mixed $key) : ?Node { return $this->nodes[$key] ?? null; } @@ -167,7 +167,7 @@ class Graph * * @since 1.0.0 */ - public function getCost() + public function getCost() : int|float { $edges = $this->getEdges(); $costs = 0; diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 1bc60ae07..4bb051c6d 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -334,7 +334,7 @@ final class ArrayUtils * * @since 1.0.0 */ - public static function arraySum(array $array, int $start = 0, int $count = 0) + public static function arraySum(array $array, int $start = 0, int $count = 0) : int|float { $count = $count === 0 ? \count($array) : $start + $count; $sum = 0; @@ -391,28 +391,7 @@ final class ArrayUtils * * @since 1.0.0 */ - public static function powerFloat(array $values, float $exp = 2.0) : array - { - $squared = []; - - foreach ($values as $value) { - $squared[] = $value ** $exp; - } - - return $squared; - } - - /** - * Power all values in array. - * - * @param array $values Values to square - * @param int $exp Exponent - * - * @return array - * - * @since 1.0.0 - */ - public static function powerInt(array $values, int $exp = 2) : array + public static function power(array $values, int|float $exp = 2) : array { $squared = []; diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 646df8210..1e0f252de 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -287,7 +287,7 @@ class Repository * * @since 1.0.0 */ - public function add($files = '*') : string + public function add(string|array $files = '*') : string { $files = $this->parseFileList($files); @@ -304,7 +304,7 @@ class Repository * * @since 1.0.0 */ - public function rm($files = '*', bool $cached = false) : string + public function rm(string|array $files = '*', bool $cached = false) : string { $files = $this->parseFileList($files); @@ -322,12 +322,10 @@ class Repository * * @since 1.0.0 */ - private function parseFileList($files) : string + private function parseFileList(string|array $files) : string { if (\is_array($files)) { return '"' . \implode('" "', $files) . '"'; - } elseif (!\is_string($files)) { - throw new \InvalidArgumentException('Wrong type for $files.'); } return $files; diff --git a/Utils/MbStringUtils.php b/Utils/MbStringUtils.php index 519a6809e..a89c7834f 100644 --- a/Utils/MbStringUtils.php +++ b/Utils/MbStringUtils.php @@ -112,7 +112,7 @@ final class MbStringUtils * * @since 1.0.0 */ - public static function mb_endsWith(string $haystack, $needles) : bool + public static function mb_endsWith(string $haystack, string|array $needles) : bool { if (\is_string($needles)) { $needles = [$needles]; diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index e5d498c9d..beff26b9b 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -82,7 +82,7 @@ final class StringUtils * * @since 1.0.0 */ - public static function endsWith(string $haystack, $needles) : bool + public static function endsWith(string $haystack, string|array $needles) : bool { if (\is_string($needles)) { $needles = [$needles]; @@ -114,7 +114,7 @@ final class StringUtils * * @since 1.0.0 */ - public static function startsWith(string $haystack, $needles) : bool + public static function startsWith(string $haystack, string|array $needles) : bool { if (\is_string($needles)) { $needles = [$needles]; diff --git a/Validation/Validator.php b/Validation/Validator.php index eff7f786a..741abb13d 100644 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -72,7 +72,7 @@ final class Validator extends ValidatorAbstract * * @since 1.0.0 */ - public static function isType($var, $constraint) : bool + public static function isType(mixed $var, string|array $constraint) : bool { if (!\is_array($constraint)) { $constraint = [$constraint]; @@ -119,7 +119,7 @@ final class Validator extends ValidatorAbstract * * @since 1.0.0 */ - public static function contains(string $var, $substr) : bool + public static function contains(string $var, string|array $substr) : bool { return \is_string($substr) ? \strpos($var, $substr) !== false : StringUtils::contains($var, $substr); } @@ -150,7 +150,7 @@ final class Validator extends ValidatorAbstract * * @since 1.0.0 */ - public static function hasLimit($var, $min = 0, $max = \PHP_INT_MAX) : bool + public static function hasLimit(int|float $var, int|float $min = 0, int|float $max = \PHP_INT_MAX) : bool { if ($var <= $max && $var >= $min) { return true; diff --git a/Views/View.php b/Views/View.php index d78f31009..054afc5d1 100644 --- a/Views/View.php +++ b/Views/View.php @@ -289,7 +289,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getHtml($translation, string $module = null, string $theme = null) : string + public function getHtml(mixed $translation, string $module = null, string $theme = null) : string { return \htmlspecialchars($this->getText($translation, $module, $theme)); } @@ -304,7 +304,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getNumeric($numeric, string $format = null) : string + public function getNumeric(int|float $numeric, string $format = null) : string { return $this->l11nManager->getNumeric($this->l11n, $numeric, $format); } @@ -336,7 +336,7 @@ class View extends ViewAbstract * * @since 1.0.0 */ - public function getCurrency($currency, string $format = null, string $symbol = null, int $divide = 1) : string + public function getCurrency(int|float $currency, string $format = null, string $symbol = null, int $divide = 1) : string { return $this->l11nManager->getCurrency($this->l11n, $currency, $format, $symbol, $divide); } diff --git a/tests/DataStorage/Database/Query/BuilderTest.php b/tests/DataStorage/Database/Query/BuilderTest.php index 84aa6346b..36a19b042 100644 --- a/tests/DataStorage/Database/Query/BuilderTest.php +++ b/tests/DataStorage/Database/Query/BuilderTest.php @@ -494,18 +494,6 @@ class BuilderTest extends \PHPUnit\Framework\TestCase $query->where('a', 'invalid', 'b'); } - /** - * @testdox Invalid join types throw a InvalidArgumentException - * @group framework - */ - public function testInvalidJoinTable() : void - { - $this->expectException(\InvalidArgumentException::class); - - $query = new Builder($this->con, true); - $query->join(null); - } - /** * @testdox Invalid join operators throw a InvalidArgumentException * @group framework @@ -518,18 +506,6 @@ class BuilderTest extends \PHPUnit\Framework\TestCase $query->join('b')->on('a', 'invalid', 'b'); } - /** - * @testdox Invalid order types throw a InvalidArgumentException - * @group framework - */ - public function testInvalidOrderType() : void - { - $this->expectException(\InvalidArgumentException::class); - - $query = new Builder($this->con, true); - $query->orderBy('a', 1); - } - /** * @testdox Invalid order column types throw a InvalidArgumentException * @group framework @@ -539,6 +515,6 @@ class BuilderTest extends \PHPUnit\Framework\TestCase $this->expectException(\InvalidArgumentException::class); $query = new Builder($this->con, true); - $query->orderBy(null, 'DESC'); + $query->orderBy('valid', ['invalid']); } } diff --git a/tests/Math/Number/ComplexTest.php b/tests/Math/Number/ComplexTest.php index 69376c622..5c50bebab 100644 --- a/tests/Math/Number/ComplexTest.php +++ b/tests/Math/Number/ComplexTest.php @@ -271,17 +271,4 @@ class ComplexTest extends \PHPUnit\Framework\TestCase $cpl = new Complex(4, 3); $cpl->div(true); } - - /** - * @testdox The power of a invalid type throws a InvalidArgumentException - * @covers phpOMS\Math\Number\Complex - * @group framework - */ - public function testInvalidPow() : void - { - $this->expectException(\InvalidArgumentException::class); - - $cpl = new Complex(4, 3); - $cpl->pow(true); - } } diff --git a/tests/Utils/ArrayUtilsTest.php b/tests/Utils/ArrayUtilsTest.php index e4075c0ce..c1a789861 100644 --- a/tests/Utils/ArrayUtilsTest.php +++ b/tests/Utils/ArrayUtilsTest.php @@ -280,27 +280,18 @@ class ArrayUtilsTest extends \PHPUnit\Framework\TestCase } /** - * @testdox All array values in an array can be potentiated by an integer + * @testdox All array values in an array can be potentiated by a numeric value * @covers phpOMS\Utils\ArrayUtils * * @group framework */ - public function testPowerInt() : void + public function test() : void { - self::assertEquals([4, 9, 16], ArrayUtils::powerInt([2, 3, 4], 2)); - self::assertEquals([8, 27, 64], ArrayUtils::powerInt([2, 3, 4], 3)); - } + self::assertEquals([4, 9, 16], ArrayUtils::power([2, 3, 4], 2)); + self::assertEquals([8, 27, 64], ArrayUtils::power([2, 3, 4], 3)); - /** - * @testdox All array values in an array can be potentiated by a float - * @covers phpOMS\Utils\ArrayUtils - * - * @group framework - */ - public function testPowerFloat() : void - { - self::assertEqualsWithDelta([2.0, 3.0, 4.0], ArrayUtils::powerFloat([4, 9, 16], 1 / 2), 0.0); - self::assertEqualsWithDelta([2.0, 3.0, 4.0], ArrayUtils::powerFloat([8, 27, 64], 1 / 3), 0.0); + self::assertEqualsWithDelta([2.0, 3.0, 4.0], ArrayUtils::power([4, 9, 16], 1 / 2), 0.0); + self::assertEqualsWithDelta([2.0, 3.0, 4.0], ArrayUtils::power([8, 27, 64], 1 / 3), 0.0); } /**