mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
implement php 8.0 types
This commit is contained in:
parent
2bfb2c1329
commit
0f1a799014
|
|
@ -109,7 +109,7 @@ class Account implements \JsonSerializable, ArrayableInterface
|
||||||
/**
|
/**
|
||||||
* Groups.
|
* Groups.
|
||||||
*
|
*
|
||||||
* @var int[]
|
* @var Group[]
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $groups = [];
|
protected array $groups = [];
|
||||||
|
|
@ -183,7 +183,7 @@ class Account implements \JsonSerializable, ArrayableInterface
|
||||||
* Every account can belong to multiple groups.
|
* Every account can belong to multiple groups.
|
||||||
* These groups usually are used for permissions and categorize accounts.
|
* These groups usually are used for permissions and categorize accounts.
|
||||||
*
|
*
|
||||||
* @return array Returns array of all groups
|
* @return Group[] Returns array of all groups
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -195,13 +195,13 @@ class Account implements \JsonSerializable, ArrayableInterface
|
||||||
/**
|
/**
|
||||||
* Add group.
|
* Add group.
|
||||||
*
|
*
|
||||||
* @param mixed $group Group to add
|
* @param Group $group Group to add
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function addGroup($group) : void
|
public function addGroup(Group $group) : void
|
||||||
{
|
{
|
||||||
$this->groups[] = $group;
|
$this->groups[] = $group;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace phpOMS\Account;
|
||||||
*/
|
*/
|
||||||
final class NullGroup extends Group
|
final class NullGroup extends Group
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ class Point implements PointInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setCoordinate(int $index, $value) : void
|
public function setCoordinate(int $index, int|float $value) : void
|
||||||
{
|
{
|
||||||
$this->coordinates[$index] = $value;
|
$this->coordinates[$index] = $value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,12 @@ interface PointInterface
|
||||||
/**
|
/**
|
||||||
* Set the coordinate of the point
|
* Set the coordinate of the point
|
||||||
*
|
*
|
||||||
* @param int $index Index of the coordinate (e.g. 0 = x);
|
* @param int $index Index of the coordinate (e.g. 0 = x);
|
||||||
* @param mixed $value Value of the coordinate
|
* @param int|float $value Value of the coordinate
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setCoordinate(int $index, $value) : void;
|
public function setCoordinate(int $index, int|float $value) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ class Backpack implements BackpackInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function addItem(ItemInterface $item, $quantity = 1) : void
|
public function addItem(ItemInterface $item, int|float $quantity = 1) : void
|
||||||
{
|
{
|
||||||
$this->items[] = ['item' => $item, 'quantity' => $quantity];
|
$this->items[] = ['item' => $item, 'quantity' => $quantity];
|
||||||
$this->value += $item->getValue() * $quantity;
|
$this->value += $item->getValue() * $quantity;
|
||||||
|
|
|
||||||
|
|
@ -65,11 +65,11 @@ interface BackpackInterface
|
||||||
* Add item to backpack
|
* Add item to backpack
|
||||||
*
|
*
|
||||||
* @param ItemInterface $item Item
|
* @param ItemInterface $item Item
|
||||||
* @param mixed $quantity Quantity of the item
|
* @param int|float $quantity Quantity of the item
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function addItem(ItemInterface $item, $quantity = 1) : void;
|
public function addItem(ItemInterface $item, int|float $quantity = 1) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,13 +190,13 @@ class ApplicationAbstract
|
||||||
* Set values
|
* Set values
|
||||||
*
|
*
|
||||||
* @param string $name Variable name
|
* @param string $name Variable name
|
||||||
* @param string $value Variable value
|
* @param mixed $value Variable value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value) : void
|
public function __set(string $name, mixed $value) : void
|
||||||
{
|
{
|
||||||
if (!empty($this->{$name})) {
|
if (!empty($this->{$name})) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -214,7 +214,7 @@ class ApplicationAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get(string $name) : mixed
|
||||||
{
|
{
|
||||||
return isset($this->{$name}) ? $this->{$name} : null;
|
return isset($this->{$name}) ? $this->{$name} : null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ final class ApplicationInfo
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set(string $path, $data, string $delim = '/') : void
|
public function set(string $path, mixed $data, string $delim = '/') : void
|
||||||
{
|
{
|
||||||
if (!\is_scalar($data) && !\is_array($data) && !($data instanceof \JsonSerializable)) {
|
if (!\is_scalar($data) && !\is_array($data) && !($data instanceof \JsonSerializable)) {
|
||||||
throw new \InvalidArgumentException('Type of $data "' . \gettype($data) . '" is not supported.');
|
throw new \InvalidArgumentException('Type of $data "' . \gettype($data) . '" is not supported.');
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ final class ArticleCorrelationAffinity
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getAffinity($item, int $resultSize = 0) : array
|
public function getAffinity(mixed $item, int $resultSize = 0) : array
|
||||||
{
|
{
|
||||||
if (!isset($this->affinity[$item])) {
|
if (!isset($this->affinity[$item])) {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
||||||
|
|
@ -27,26 +27,26 @@ interface OptionsInterface
|
||||||
/**
|
/**
|
||||||
* Is this key set.
|
* Is this key set.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key to check for existence
|
* @param int|string $key Key to check for existence
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function exists($key) : bool;
|
public function exists(int|string $key) : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updating or adding settings.
|
* Updating or adding settings.
|
||||||
*
|
*
|
||||||
* @param mixed $key Unique option key
|
* @param int|string $key Unique option key
|
||||||
* @param mixed $value Option value
|
* @param mixed $value Option value
|
||||||
* @param bool $overwrite Overwrite existing value
|
* @param bool $overwrite Overwrite existing value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updating or adding settings.
|
* Updating or adding settings.
|
||||||
|
|
@ -63,11 +63,11 @@ interface OptionsInterface
|
||||||
/**
|
/**
|
||||||
* Get option by key.
|
* Get option by key.
|
||||||
*
|
*
|
||||||
* @param mixed $key Unique option key
|
* @param int|string $key Unique option key
|
||||||
*
|
*
|
||||||
* @return mixed Option value
|
* @return mixed Option value
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getOption($key);
|
public function getOption(int|string $key) : mixed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ interface StreamInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setCustomData(string $key, $value) : self;
|
public function setCustomData(string $key, mixed $value) : self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get custom data from the stream
|
* Get custom data from the stream
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function dataType($value) : int
|
protected function dataType(mixed $value) : int
|
||||||
{
|
{
|
||||||
if (\is_int($value)) {
|
if (\is_int($value)) {
|
||||||
return CacheValueType::_INT;
|
return CacheValueType::_INT;
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ final class FileCache extends ConnectionAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function reverseValue(int $type, string $raw, int $expireEnd)
|
private function reverseValue(int $type, string $raw, int $expireEnd) : mixed
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case CacheValueType::_INT:
|
case CacheValueType::_INT:
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ final class RedisCache extends ConnectionAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function build(mixed $value)
|
private function build(mixed $value) : mixed
|
||||||
{
|
{
|
||||||
$type = $this->dataType($value);
|
$type = $this->dataType($value);
|
||||||
$raw = $this->cachify($value, $type);
|
$raw = $this->cachify($value, $type);
|
||||||
|
|
@ -273,7 +273,7 @@ final class RedisCache extends ConnectionAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function cachify(mixed $value, int $type)
|
private function cachify(mixed $value, int $type) : mixed
|
||||||
{
|
{
|
||||||
if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) {
|
if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
|
|
@ -303,7 +303,7 @@ final class RedisCache extends ConnectionAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function reverseValue(int $type, mixed $raw, int $start)
|
private function reverseValue(int $type, mixed $raw, int $start) : mixed
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case CacheValueType::_INT:
|
case CacheValueType::_INT:
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ final class CookieJar
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set(string $id, $value, int $expire = 86400, string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, bool $overwrite = true) : bool
|
public function set(string $id, mixed $value, int $expire = 86400, string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, bool $overwrite = true) : bool
|
||||||
{
|
{
|
||||||
if ($overwrite || !isset($this->cookies[$id])) {
|
if ($overwrite || !isset($this->cookies[$id])) {
|
||||||
$this->cookies[$id] = [
|
$this->cookies[$id] = [
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ interface DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function create($obj);
|
public static function create(mixed $obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update data.
|
* Update data.
|
||||||
|
|
@ -46,7 +46,7 @@ interface DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function update($obj);
|
public static function update(mixed $obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete data.
|
* Delete data.
|
||||||
|
|
@ -57,7 +57,7 @@ interface DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function delete($obj);
|
public static function delete(mixed $obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find data.
|
* Find data.
|
||||||
|
|
@ -90,5 +90,5 @@ interface DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function get($primaryKey);
|
public static function get(mixed $primaryKey);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get(string $name) : mixed
|
||||||
{
|
{
|
||||||
if ($name === 'con' && !isset($this->con)) {
|
if ($name === 'con' && !isset($this->con)) {
|
||||||
$this->connect($this->dbdata);
|
$this->connect($this->dbdata);
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function withConditional(string $id, $value, array $models = [], string $comparison = '=') /** @todo: return : static */
|
public static function withConditional(string $id, mixed $value, array $models = [], string $comparison = '=') /** @todo: return : static */
|
||||||
{
|
{
|
||||||
self::$conditionals[$id] = [
|
self::$conditionals[$id] = [
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
|
@ -465,7 +465,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function create($obj, int $relations = RelationType::ALL) : mixed
|
public static function create(mixed $obj, int $relations = RelationType::ALL) : mixed
|
||||||
{
|
{
|
||||||
if (!isset($obj)) {
|
if (!isset($obj)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -698,7 +698,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function setObjectId(\ReflectionClass $refClass, object $obj, $objId) : void
|
private static function setObjectId(\ReflectionClass $refClass, object $obj, mixed $objId) : void
|
||||||
{
|
{
|
||||||
$propertyName = static::$columns[static::$primaryField]['internal'];
|
$propertyName = static::$columns[static::$primaryField]['internal'];
|
||||||
$refProp = $refClass->getProperty($propertyName);
|
$refProp = $refClass->getProperty($propertyName);
|
||||||
|
|
@ -726,7 +726,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function createRelation(string $member, $id1, $id2) : bool
|
public static function createRelation(string $member, mixed $id1, mixed $id2) : bool
|
||||||
{
|
{
|
||||||
if (!isset(static::$hasMany[$member]) || !isset(static::$hasMany[$member]['external'])) {
|
if (!isset(static::$hasMany[$member]) || !isset(static::$hasMany[$member]['external'])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -751,7 +751,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createHasMany(\ReflectionClass $refClass, object $obj, $objId) : void
|
private static function createHasMany(\ReflectionClass $refClass, object $obj, mixed $objId) : void
|
||||||
{
|
{
|
||||||
foreach (static::$hasMany as $propertyName => $rel) {
|
foreach (static::$hasMany as $propertyName => $rel) {
|
||||||
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
||||||
|
|
@ -873,7 +873,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createHasManyArray(array &$obj, $objId) : void
|
private static function createHasManyArray(array &$obj, mixed $objId) : void
|
||||||
{
|
{
|
||||||
foreach (static::$hasMany as $propertyName => $rel) {
|
foreach (static::$hasMany as $propertyName => $rel) {
|
||||||
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
||||||
|
|
@ -943,7 +943,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createOwnsOne(string $propertyName, $obj) : mixed
|
private static function createOwnsOne(string $propertyName, mixed $obj) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -993,7 +993,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createBelongsTo(string $propertyName, $obj) : mixed
|
private static function createBelongsTo(string $propertyName, mixed $obj) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1040,7 +1040,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createRelationTable(string $propertyName, array $objsIds, $objId) : void
|
private static function createRelationTable(string $propertyName, array $objsIds, mixed $objId) : void
|
||||||
{
|
{
|
||||||
if (empty($objsIds) || !isset(static::$hasMany[$propertyName]['external'])) {
|
if (empty($objsIds) || !isset(static::$hasMany[$propertyName]['external'])) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1081,7 +1081,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function parseValue(string $type, $value = null) : mixed
|
private static function parseValue(string $type, mixed $value = null) : mixed
|
||||||
{
|
{
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -1120,7 +1120,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateHasMany(\ReflectionClass $refClass, object $obj, $objId, $depth = 1) : void
|
private static function updateHasMany(\ReflectionClass $refClass, object $obj, mixed $objId, int $depth = 1) : void
|
||||||
{
|
{
|
||||||
$objsIds = [];
|
$objsIds = [];
|
||||||
|
|
||||||
|
|
@ -1208,7 +1208,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateHasManyArray(array &$obj, $objId, $depth = 1) : void
|
private static function updateHasManyArray(array &$obj, mixed $objId, int $depth = 1) : void
|
||||||
{
|
{
|
||||||
$objsIds = [];
|
$objsIds = [];
|
||||||
|
|
||||||
|
|
@ -1273,11 +1273,11 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @param array $objsIds Object ids to insert
|
* @param array $objsIds Object ids to insert
|
||||||
* @param mixed $objId Model to reference
|
* @param mixed $objId Model to reference
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateRelationTable(array $objsIds, $objId) : mixed
|
private static function updateRelationTable(array $objsIds, mixed $objId) : void
|
||||||
{
|
{
|
||||||
$many = self::getHasManyRaw($objId);
|
$many = self::getHasManyRaw($objId);
|
||||||
|
|
||||||
|
|
@ -1306,7 +1306,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function deleteRelationTable(string $propertyName, array $objsIds, $objId) : void
|
private static function deleteRelationTable(string $propertyName, array $objsIds, mixed $objId) : void
|
||||||
{
|
{
|
||||||
if (empty($objsIds)
|
if (empty($objsIds)
|
||||||
|| static::$hasMany[$propertyName]['table'] === static::$table
|
|| static::$hasMany[$propertyName]['table'] === static::$table
|
||||||
|
|
@ -1339,7 +1339,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateOwnsOne(string $propertyName, $obj, int $depth = 1) : mixed
|
private static function updateOwnsOne(string $propertyName, mixed $obj, int $depth = 1) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1385,7 +1385,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateBelongsTo(string $propertyName, $obj, int $depth = 1) : mixed
|
private static function updateBelongsTo(string $propertyName, mixed $obj, int $depth = 1) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1410,7 +1410,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateBelongsToArray(string $propertyName, $obj, int $depth = 1) : mixed
|
private static function updateBelongsToArray(string $propertyName, mixed $obj, int $depth = 1) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_array($obj)) {
|
if (!\is_array($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1434,7 +1434,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateModel(object $obj, $objId, \ReflectionClass $refClass = null, int $depth = 1) : void
|
private static function updateModel(object $obj, mixed $objId, \ReflectionClass $refClass = null, int $depth = 1) : void
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->update(static::$table)
|
$query->update(static::$table)
|
||||||
|
|
@ -1508,7 +1508,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function updateModelArray(array $obj, $objId, int $depth = 1) : void
|
private static function updateModelArray(array $obj, mixed $objId, int $depth = 1) : void
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->update(static::$table)
|
$query->update(static::$table)
|
||||||
|
|
@ -1572,7 +1572,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function update($obj, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
public static function update(mixed $obj, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
if (!isset($obj)) {
|
if (!isset($obj)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -1664,7 +1664,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function deleteHasMany(\ReflectionClass $refClass, object $obj, $objId) : void
|
private static function deleteHasMany(\ReflectionClass $refClass, object $obj, mixed $objId) : void
|
||||||
{
|
{
|
||||||
foreach (static::$hasMany as $propertyName => $rel) {
|
foreach (static::$hasMany as $propertyName => $rel) {
|
||||||
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
if (!isset(static::$hasMany[$propertyName]['mapper'])) {
|
||||||
|
|
@ -1731,7 +1731,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function deleteOwnsOne(string $propertyName, $obj) : mixed
|
private static function deleteOwnsOne(string $propertyName, mixed $obj) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1761,7 +1761,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function deleteBelongsTo(string $propertyName, $obj) : mixed
|
private static function deleteBelongsTo(string $propertyName, mixed $obj) : mixed
|
||||||
{
|
{
|
||||||
if (!\is_object($obj)) {
|
if (!\is_object($obj)) {
|
||||||
return $obj;
|
return $obj;
|
||||||
|
|
@ -1784,7 +1784,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function deleteModel(object $obj, $objId, \ReflectionClass $refClass = null) : void
|
private static function deleteModel(object $obj, mixed $objId, \ReflectionClass $refClass = null) : void
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->delete()
|
$query->delete()
|
||||||
|
|
@ -1847,7 +1847,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function delete($obj, int $relations = RelationType::REFERENCE) : mixed
|
public static function delete(mixed $obj, int $relations = RelationType::REFERENCE) : mixed
|
||||||
{
|
{
|
||||||
// @todo: only do this if RelationType !== NONE
|
// @todo: only do this if RelationType !== NONE
|
||||||
if (\is_scalar($obj)) {
|
if (\is_scalar($obj)) {
|
||||||
|
|
@ -1961,7 +1961,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateManyToMany(array $result, &$obj, int $depth = 3) : void
|
public static function populateManyToMany(array $result, mixed &$obj, int $depth = 3) : void
|
||||||
{
|
{
|
||||||
$refClass = new \ReflectionClass($obj);
|
$refClass = new \ReflectionClass($obj);
|
||||||
|
|
||||||
|
|
@ -2039,7 +2039,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateOwnsOne(string $member, array $result, int $depth = 3, $default = null) : mixed
|
public static function populateOwnsOne(string $member, array $result, int $depth = 3, mixed $default = null) : mixed
|
||||||
{
|
{
|
||||||
/** @var self $mapper */
|
/** @var self $mapper */
|
||||||
$mapper = static::$ownsOne[$member]['mapper'];
|
$mapper = static::$ownsOne[$member]['mapper'];
|
||||||
|
|
@ -2079,7 +2079,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateOwnsOneArray(string $member, array $result, int $depth = 3, $default = null) : array
|
public static function populateOwnsOneArray(string $member, array $result, int $depth = 3, mixed $default = null) : array
|
||||||
{
|
{
|
||||||
/** @var self $mapper */
|
/** @var self $mapper */
|
||||||
$mapper = static::$ownsOne[$member]['mapper'];
|
$mapper = static::$ownsOne[$member]['mapper'];
|
||||||
|
|
@ -2119,7 +2119,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateBelongsTo(string $member, array $result, int $depth = 3, $default = null)
|
public static function populateBelongsTo(string $member, array $result, int $depth = 3, mixed $default = null) : mixed
|
||||||
{
|
{
|
||||||
/** @var self $mapper */
|
/** @var self $mapper */
|
||||||
$mapper = static::$belongsTo[$member]['mapper'];
|
$mapper = static::$belongsTo[$member]['mapper'];
|
||||||
|
|
@ -2159,7 +2159,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateBelongsToArray(string $member, array $result, int $depth = 3, $default = null) : array
|
public static function populateBelongsToArray(string $member, array $result, int $depth = 3, mixed $default = null) : array
|
||||||
{
|
{
|
||||||
/** @var self $mapper */
|
/** @var self $mapper */
|
||||||
$mapper = static::$belongsTo[$member]['mapper'];
|
$mapper = static::$belongsTo[$member]['mapper'];
|
||||||
|
|
@ -2198,7 +2198,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function populateAbstract(array $result, $obj, int $depth = 3)
|
public static function populateAbstract(array $result, mixed $obj, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
$refClass = new \ReflectionClass($obj);
|
$refClass = new \ReflectionClass($obj);
|
||||||
|
|
||||||
|
|
@ -2465,7 +2465,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function countBeforePivot($pivot, string $column = null) : int
|
public static function countBeforePivot(mixed $pivot, string $column = null) : int
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->where(static::$table . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '<', $pivot);
|
$query->where(static::$table . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '<', $pivot);
|
||||||
|
|
@ -2483,7 +2483,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function countAfterPivot($pivot, string $column = null) : int
|
public static function countAfterPivot(mixed $pivot, string $column = null) : int
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->where(static::$table . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '>', $pivot);
|
$query->where(static::$table . '.' . ($column !== null ? self::getColumnByMember($column) : static::$primaryField), '>', $pivot);
|
||||||
|
|
@ -2524,7 +2524,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getAfterPivot(
|
public static function getAfterPivot(
|
||||||
$pivot,
|
mixed $pivot,
|
||||||
string $column = null,
|
string $column = null,
|
||||||
int $limit = 50,
|
int $limit = 50,
|
||||||
string $order = 'ASC',
|
string $order = 'ASC',
|
||||||
|
|
@ -2559,7 +2559,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* It should just return the closes elements "before" the pivot element.
|
* It should just return the closes elements "before" the pivot element.
|
||||||
*/
|
*/
|
||||||
public static function getBeforePivot(
|
public static function getBeforePivot(
|
||||||
$pivot,
|
mixed $pivot,
|
||||||
string $column = null,
|
string $column = null,
|
||||||
int $limit = 50,
|
int $limit = 50,
|
||||||
string $order = 'ASC',
|
string $order = 'ASC',
|
||||||
|
|
@ -2588,7 +2588,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function get($primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null)
|
public static function get(mixed $primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null) : mixed
|
||||||
{
|
{
|
||||||
if ($depth < 1) {
|
if ($depth < 1) {
|
||||||
return self::createNullModel($primaryKey);
|
return self::createNullModel($primaryKey);
|
||||||
|
|
@ -2649,7 +2649,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getArray($primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null) : array
|
public static function getArray(mixed $primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null) : array
|
||||||
{
|
{
|
||||||
if ($depth < 1) {
|
if ($depth < 1) {
|
||||||
return $primaryKey;
|
return $primaryKey;
|
||||||
|
|
@ -2712,7 +2712,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @todo by and for look the same, this cannot be correct.
|
* @todo by and for look the same, this cannot be correct.
|
||||||
*/
|
*/
|
||||||
public static function getFor($forKey, string $for, int $relations = RelationType::ALL, int $depth = 3)
|
public static function getFor(mixed $forKey, string $for, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
return self::get($forKey, $relations, $depth, $for);
|
return self::get($forKey, $relations, $depth, $for);
|
||||||
}
|
}
|
||||||
|
|
@ -2730,7 +2730,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @todo by and for look the same, this cannot be correct.
|
* @todo by and for look the same, this cannot be correct.
|
||||||
*/
|
*/
|
||||||
public static function getBy($byKey, string $by, int $relations = RelationType::ALL, int $depth = 3)
|
public static function getBy(mixed $byKey, string $by, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
return self::get($byKey, $relations, $depth, $by);
|
return self::get($byKey, $relations, $depth, $by);
|
||||||
}
|
}
|
||||||
|
|
@ -2747,7 +2747,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getForArray($refKey, string $ref, int $relations = RelationType::ALL, int $depth = 3)
|
public static function getForArray(mixed $refKey, string $ref, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
return self::getArray($refKey, $relations, $depth, $ref);
|
return self::getArray($refKey, $relations, $depth, $ref);
|
||||||
}
|
}
|
||||||
|
|
@ -2764,7 +2764,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getByArray($byKey, string $by, int $relations = RelationType::ALL, int $depth = 3)
|
public static function getByArray(mixed $byKey, string $by, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
return self::getArray($byKey, $relations, $depth, $by);
|
return self::getArray($byKey, $relations, $depth, $by);
|
||||||
}
|
}
|
||||||
|
|
@ -2845,7 +2845,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getByParent($value, int $depth = 3) : array
|
public static function getByParent(mixed $value, int $depth = 3) : array
|
||||||
{
|
{
|
||||||
$query = self::getQuery();
|
$query = self::getQuery();
|
||||||
$query->where(static::$table . '_' . $depth . '.' . static::$parent, '=', $value);
|
$query->where(static::$table . '_' . $depth . '.' . static::$parent, '=', $value);
|
||||||
|
|
@ -2886,7 +2886,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getRandom(int $amount = 1, int $relations = RelationType::ALL, int $depth = 3)
|
public static function getRandom(int $amount = 1, int $relations = RelationType::ALL, int $depth = 3) : mixed
|
||||||
{
|
{
|
||||||
if ($depth < 1) {
|
if ($depth < 1) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -2910,7 +2910,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function fillRelations($obj, int $relations = RelationType::ALL, int $depth = 3) : void
|
public static function fillRelations(mixed $obj, int $relations = RelationType::ALL, int $depth = 3) : void
|
||||||
{
|
{
|
||||||
if ($depth < 1
|
if ($depth < 1
|
||||||
|| empty(static::$hasMany)
|
|| empty(static::$hasMany)
|
||||||
|
|
@ -2985,7 +2985,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getRaw($keys, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null) : array
|
public static function getRaw(mixed $keys, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null) : array
|
||||||
{
|
{
|
||||||
$comparison = \is_array($keys) && \count($keys) > 1 ? 'in' : '=';
|
$comparison = \is_array($keys) && \count($keys) > 1 ? 'in' : '=';
|
||||||
$keys = $comparison === 'in' ? $keys : \reset($keys);
|
$keys = $comparison === 'in' ? $keys : \reset($keys);
|
||||||
|
|
@ -3067,7 +3067,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getHasManyPrimaryKeys($refKey, string $ref) : array
|
public static function getHasManyPrimaryKeys(mixed $refKey, string $ref) : array
|
||||||
{
|
{
|
||||||
$query = new Builder(self::$db);
|
$query = new Builder(self::$db);
|
||||||
$query->select(static::$hasMany[$ref]['table'] . '.' . static::$hasMany[$ref]['self'])
|
$query->select(static::$hasMany[$ref]['table'] . '.' . static::$hasMany[$ref]['self'])
|
||||||
|
|
@ -3092,7 +3092,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getHasManyRaw($primaryKey, int $relations = RelationType::ALL) : array
|
public static function getHasManyRaw(mixed $primaryKey, int $relations = RelationType::ALL) : array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
$cachedTables = []; // used by conditionals
|
$cachedTables = []; // used by conditionals
|
||||||
|
|
@ -3278,7 +3278,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function addInitialized(string $mapper, $id, object $obj = null, int $depth = 3) : void
|
private static function addInitialized(string $mapper, mixed $id, object $obj = null, int $depth = 3) : void
|
||||||
{
|
{
|
||||||
if (!isset(self::$initObjects[$mapper])) {
|
if (!isset(self::$initObjects[$mapper])) {
|
||||||
self::$initObjects[$mapper] = [];
|
self::$initObjects[$mapper] = [];
|
||||||
|
|
@ -3303,7 +3303,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function addInitializedArray(string $mapper, $id, array $obj = null, int $depth = 3) : void
|
private static function addInitializedArray(string $mapper, mixed $id, array $obj = null, int $depth = 3) : void
|
||||||
{
|
{
|
||||||
if (!isset(self::$initArrays[$mapper])) {
|
if (!isset(self::$initArrays[$mapper])) {
|
||||||
self::$initArrays[$mapper] = [];
|
self::$initArrays[$mapper] = [];
|
||||||
|
|
@ -3326,7 +3326,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function isInitialized(string $mapper, $id, int $depth = 3) : bool
|
private static function isInitialized(string $mapper, mixed $id, int $depth = 3) : bool
|
||||||
{
|
{
|
||||||
return !empty($id)
|
return !empty($id)
|
||||||
&& isset(self::$initObjects[$mapper], self::$initObjects[$mapper][$id])
|
&& isset(self::$initObjects[$mapper], self::$initObjects[$mapper][$id])
|
||||||
|
|
@ -3345,7 +3345,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function isInitializedArray(string $mapper, $id, int $depth = 3) : bool
|
private static function isInitializedArray(string $mapper, mixed $id, int $depth = 3) : bool
|
||||||
{
|
{
|
||||||
return !empty($id)
|
return !empty($id)
|
||||||
&& isset(self::$initArrays[$mapper], self::$initArrays[$mapper][$id])
|
&& isset(self::$initArrays[$mapper], self::$initArrays[$mapper][$id])
|
||||||
|
|
@ -3364,7 +3364,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function getInitialized(string $mapper, $id, int $depth)
|
private static function getInitialized(string $mapper, mixed $id, int $depth) : mixed
|
||||||
{
|
{
|
||||||
if (!self::isInitialized($mapper, $id, $depth)) {
|
if (!self::isInitialized($mapper, $id, $depth)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -3384,7 +3384,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function getInitializedArray(string $mapper, $id, int $depth)
|
private static function getInitializedArray(string $mapper, mixed $id, int $depth) : mixed
|
||||||
{
|
{
|
||||||
if (!self::isInitializedArray($mapper, $id, $depth)) {
|
if (!self::isInitializedArray($mapper, $id, $depth)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -3399,11 +3399,11 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
* @param string $mapper Mapper name
|
* @param string $mapper Mapper name
|
||||||
* @param mixed $id Object id
|
* @param mixed $id Object id
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function removeInitialized(string $mapper, $id)
|
private static function removeInitialized(string $mapper, mixed $id) : void
|
||||||
{
|
{
|
||||||
if (isset(self::$initObjects[$mapper][$id])) {
|
if (isset(self::$initObjects[$mapper][$id])) {
|
||||||
unset(self::$initObjects[$mapper][$id]);
|
unset(self::$initObjects[$mapper][$id]);
|
||||||
|
|
@ -3417,11 +3417,11 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
/**
|
/**
|
||||||
* Clear cache
|
* Clear cache
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function clearCache()
|
public static function clearCache() : void
|
||||||
{
|
{
|
||||||
self::$initObjects = [];
|
self::$initObjects = [];
|
||||||
self::$initArrays = [];
|
self::$initArrays = [];
|
||||||
|
|
@ -3456,7 +3456,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function isNullModel($obj) : bool
|
private static function isNullModel(mixed $obj) : bool
|
||||||
{
|
{
|
||||||
return \is_object($obj) && \strpos(\get_class($obj), '\Null') !== false;
|
return \is_object($obj) && \strpos(\get_class($obj), '\Null') !== false;
|
||||||
}
|
}
|
||||||
|
|
@ -3470,7 +3470,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createNullModel($id = null)
|
private static function createNullModel(mixed $id = null) : mixed
|
||||||
{
|
{
|
||||||
$class = empty(static::$model) ? \substr(static::class, 0, -6) : static::$model;
|
$class = empty(static::$model) ? \substr(static::class, 0, -6) : static::$model;
|
||||||
$parts = \explode('\\', $class);
|
$parts = \explode('\\', $class);
|
||||||
|
|
@ -3488,7 +3488,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createBaseModel()
|
private static function createBaseModel() : mixed
|
||||||
{
|
{
|
||||||
$class = empty(static::$model) ? \substr(static::class, 0, -6) : static::$model;
|
$class = empty(static::$model) ? \substr(static::class, 0, -6) : static::$model;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1355,7 +1355,7 @@ class Builder extends BuilderAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function orOn(string|array $columns, $operator = null, $values = null) : self
|
public function orOn(string|array $columns, string|array $operator = null, string|array $values = null) : self
|
||||||
{
|
{
|
||||||
return $this->on($columns, $operator, $values, 'or');
|
return $this->on($columns, $operator, $values, 'or');
|
||||||
}
|
}
|
||||||
|
|
@ -1371,7 +1371,7 @@ class Builder extends BuilderAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function andOn(string|array $columns, $operator = null, $values = null) : self
|
public function andOn(string|array $columns, string|array $operator = null, string|array $values = null) : self
|
||||||
{
|
{
|
||||||
return $this->on($columns, $operator, $values, 'and');
|
return $this->on($columns, $operator, $values, 'and');
|
||||||
}
|
}
|
||||||
|
|
@ -1399,7 +1399,7 @@ class Builder extends BuilderAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute() : mixed
|
||||||
{
|
{
|
||||||
$sth = $this->connection->con->prepare($this->toSql());
|
$sth = $this->connection->con->prepare($this->toSql());
|
||||||
|
|
||||||
|
|
@ -1425,7 +1425,7 @@ class Builder extends BuilderAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getBindParamType($value) : int
|
public static function getBindParamType(mixed $value) : int
|
||||||
{
|
{
|
||||||
if (\is_int($value)) {
|
if (\is_int($value)) {
|
||||||
return \PDO::PARAM_INT;
|
return \PDO::PARAM_INT;
|
||||||
|
|
@ -1447,7 +1447,7 @@ class Builder extends BuilderAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getPublicColumnName($column) : string
|
public static function getPublicColumnName(mixed $column) : string
|
||||||
{
|
{
|
||||||
if (\is_string($column)) {
|
if (\is_string($column)) {
|
||||||
return $column;
|
return $column;
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ class Grammar extends GrammarAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileValue(Builder $query, $value) : string
|
protected function compileValue(Builder $query, mixed $value) : string
|
||||||
{
|
{
|
||||||
if (\is_string($value)) {
|
if (\is_string($value)) {
|
||||||
return $query->quote($value);
|
return $query->quote($value);
|
||||||
|
|
@ -389,7 +389,7 @@ class Grammar extends GrammarAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileOffset(Builder $query, $offset) : string
|
protected function compileOffset(Builder $query, int $offset) : string
|
||||||
{
|
{
|
||||||
return 'OFFSET ' . $offset;
|
return 'OFFSET ' . $offset;
|
||||||
}
|
}
|
||||||
|
|
@ -508,7 +508,7 @@ class Grammar extends GrammarAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileGroups(Builder $query, array $groups)
|
protected function compileGroups(Builder $query, array $groups) : string
|
||||||
{
|
{
|
||||||
$expression = '';
|
$expression = '';
|
||||||
|
|
||||||
|
|
@ -587,7 +587,7 @@ class Grammar extends GrammarAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function compileInto(Builder $query, $table) : string
|
protected function compileInto(Builder $query, string $table) : string
|
||||||
{
|
{
|
||||||
return 'INSERT INTO ' . $this->compileSystem($table);
|
return 'INSERT INTO ' . $this->compileSystem($table);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class FileSession implements SessionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct(int $liftetime = 3600, $sid = '', int $inactivityInterval = 0)
|
public function __construct(int $liftetime = 3600, string $sid = '', int $inactivityInterval = 0)
|
||||||
{
|
{
|
||||||
if (\session_id()) {
|
if (\session_id()) {
|
||||||
\session_write_close(); // @codeCoverageIgnore
|
\session_write_close(); // @codeCoverageIgnore
|
||||||
|
|
@ -105,7 +105,7 @@ class FileSession implements SessionInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function set(string $key, $value, bool $overwrite = false) : bool
|
public function set(string $key, mixed $value, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
if (!$this->isLocked && ($overwrite || !isset($this->sessionData[$key]))) {
|
if (!$this->isLocked && ($overwrite || !isset($this->sessionData[$key]))) {
|
||||||
$this->sessionData[$key] = $value;
|
$this->sessionData[$key] = $value;
|
||||||
|
|
@ -119,7 +119,7 @@ class FileSession implements SessionInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get(string $key)
|
public function get(string $key) : mixed
|
||||||
{
|
{
|
||||||
return $this->sessionData[$key] ?? null;
|
return $this->sessionData[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ final class HttpSession implements SessionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct(int $liftetime = 3600, $sid = '', int $inactivityInterval = 0)
|
public function __construct(int $liftetime = 3600, string $sid = '', int $inactivityInterval = 0)
|
||||||
{
|
{
|
||||||
if (\session_id()) {
|
if (\session_id()) {
|
||||||
\session_write_close(); // @codeCoverageIgnore
|
\session_write_close(); // @codeCoverageIgnore
|
||||||
|
|
@ -132,7 +132,7 @@ final class HttpSession implements SessionInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function set(string $key, $value, bool $overwrite = false) : bool
|
public function set(string $key, mixed $value, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
if (!$this->isLocked && ($overwrite || !isset($this->sessionData[$key]))) {
|
if (!$this->isLocked && ($overwrite || !isset($this->sessionData[$key]))) {
|
||||||
$this->sessionData[$key] = $value;
|
$this->sessionData[$key] = $value;
|
||||||
|
|
@ -146,7 +146,7 @@ final class HttpSession implements SessionInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get(string $key)
|
public function get(string $key) : mixed
|
||||||
{
|
{
|
||||||
return $this->sessionData[$key] ?? null;
|
return $this->sessionData[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ interface SessionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function get(string $key);
|
public function get(string $key) : mixed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store session value by key.
|
* Store session value by key.
|
||||||
|
|
@ -48,7 +48,7 @@ interface SessionInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set(string $key, $value, bool $overwrite = false) : bool;
|
public function set(string $key, mixed $value, bool $overwrite = false) : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove value from session by key.
|
* Remove value from session by key.
|
||||||
|
|
|
||||||
|
|
@ -62,31 +62,27 @@ final class Dispatcher implements DispatcherInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function dispatch($controller, ...$data) : array
|
public function dispatch(array|string|\Closure $controller, ...$data) : array
|
||||||
{
|
{
|
||||||
$views = [];
|
$views = [];
|
||||||
|
|
||||||
if (\is_array($controller)) {
|
if (\is_array($controller) && isset($controller['dest'])) {
|
||||||
if (isset($controller['dest'])) {
|
if (!empty($controller['data'])) {
|
||||||
if (!empty($controller['data'])) {
|
$data = \array_merge(
|
||||||
$data = \array_merge(
|
empty($data) ? [] : $data,
|
||||||
empty($data) ? [] : $data,
|
\is_array($controller['data']) ? $controller['data'] : [$controller['data']]
|
||||||
\is_array($controller['data']) ? $controller['data'] : [$controller['data']]
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$controller = $controller['dest'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$controller = $controller['dest'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_string($controller)) {
|
if (\is_string($controller)) {
|
||||||
$views += $this->dispatchString($controller, $data);
|
$views += $this->dispatchString($controller, $data);
|
||||||
} elseif (\is_array($controller)) {
|
} elseif (\is_array($controller)) {
|
||||||
$views += $this->dispatchArray($controller, $data);
|
$views += $this->dispatchArray($controller, $data);
|
||||||
} elseif ($controller instanceof \Closure) {
|
|
||||||
$views[] = $this->dispatchClosure($controller, $data);
|
|
||||||
} else {
|
} else {
|
||||||
throw new \UnexpectedValueException('Unexpected controller type.');
|
$views[] = $this->dispatchClosure($controller, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $views;
|
return $views;
|
||||||
|
|
@ -171,7 +167,7 @@ final class Dispatcher implements DispatcherInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function dispatchClosure(\Closure $controller, array $data = null)
|
private function dispatchClosure(\Closure $controller, array $data = null) : mixed
|
||||||
{
|
{
|
||||||
return $data === null ? $controller($this->app) : $controller($this->app, ...$data);
|
return $data === null ? $controller($this->app) : $controller($this->app, ...$data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,5 +36,5 @@ interface DispatcherInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function dispatch($controller, ...$data) : array;
|
public function dispatch(array|string|\Closure $controller, ...$data) : array;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ final class EventManager implements \Countable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function dispatch($func, ...$data) : array
|
public function dispatch(array|string|\Closure $func, ...$data) : array
|
||||||
{
|
{
|
||||||
if (!($func instanceof \Closure)) {
|
if (!($func instanceof \Closure)) {
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -123,16 +123,16 @@ final class EventManager implements \Countable
|
||||||
/**
|
/**
|
||||||
* Attach new event
|
* Attach new event
|
||||||
*
|
*
|
||||||
* @param string $group Name of the event (unique)
|
* @param string $group Name of the event (unique)
|
||||||
* @param mixed $callback Callback or route for the event
|
* @param string|\Closure $callback Callback or route for the event
|
||||||
* @param bool $remove Remove event after triggering it?
|
* @param bool $remove Remove event after triggering it?
|
||||||
* @param bool $reset Reset event after triggering it? Remove must be false!
|
* @param bool $reset Reset event after triggering it? Remove must be false!
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function attach(string $group, $callback, bool $remove = false, bool $reset = false) : bool
|
public function attach(string $group, string|\Closure $callback, bool $remove = false, bool $reset = false) : bool
|
||||||
{
|
{
|
||||||
if (!isset($this->callbacks[$group])) {
|
if (!isset($this->callbacks[$group])) {
|
||||||
$this->callbacks[$group] = ['remove' => $remove, 'reset' => $reset, 'callbacks' => []];
|
$this->callbacks[$group] = ['remove' => $remove, 'reset' => $reset, 'callbacks' => []];
|
||||||
|
|
@ -155,7 +155,7 @@ final class EventManager implements \Countable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function triggerSimilar(string $group, string $id = '', $data = null) : bool
|
public function triggerSimilar(string $group, string $id = '', mixed $data = null) : bool
|
||||||
{
|
{
|
||||||
$groupIsRegex = \stripos($group, '/') === 0;
|
$groupIsRegex = \stripos($group, '/') === 0;
|
||||||
$idIsRegex = \stripos($id, '/') === 0;
|
$idIsRegex = \stripos($id, '/') === 0;
|
||||||
|
|
@ -216,7 +216,7 @@ final class EventManager implements \Countable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function trigger(string $group, string $id = '', $data = null) : bool
|
public function trigger(string $group, string $id = '', mixed $data = null) : bool
|
||||||
{
|
{
|
||||||
if (!isset($this->callbacks[$group])) {
|
if (!isset($this->callbacks[$group])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -147,14 +147,14 @@ final class L11nManager
|
||||||
* @param string $code Language code
|
* @param string $code Language code
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
* @param string $theme Theme
|
* @param string $theme Theme
|
||||||
* @param mixed $translation Text
|
* @param string $translation Text
|
||||||
* @param null|string $app App name
|
* @param null|string $app App name
|
||||||
*
|
*
|
||||||
* @return string In case the language element couldn't be found 'ERROR' will be returned
|
* @return string In case the language element couldn't be found 'ERROR' will be returned
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getText(string $code, string $module, string $theme, $translation, string $app = null) : string
|
public function getText(string $code, string $module, string $theme, string $translation, string $app = null) : string
|
||||||
{
|
{
|
||||||
if (isset($this->language[$code][$module][$translation])) {
|
if (isset($this->language[$code][$module][$translation])) {
|
||||||
return $this->language[$code][$module][$translation];
|
return $this->language[$code][$module][$translation];
|
||||||
|
|
@ -189,13 +189,13 @@ final class L11nManager
|
||||||
* @param string $code Language code
|
* @param string $code Language code
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
* @param string $theme Theme
|
* @param string $theme Theme
|
||||||
* @param mixed $translation Text
|
* @param string $translation Text
|
||||||
*
|
*
|
||||||
* @return string In case the language element couldn't be found 'ERROR' will be returned
|
* @return string In case the language element couldn't be found 'ERROR' will be returned
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getHtml(string $code, string $module, string $theme, $translation) : string
|
public function getHtml(string $code, string $module, string $theme, string $translation) : string
|
||||||
{
|
{
|
||||||
return \htmlspecialchars($this->getText($code, $module, $theme, $translation));
|
return \htmlspecialchars($this->getText($code, $module, $theme, $translation));
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ final class L11nManager
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getNumeric(Localization $l11n, $numeric, string $format = null) : string
|
public function getNumeric(Localization $l11n, int|float $numeric, string $format = null) : string
|
||||||
{
|
{
|
||||||
return \number_format(
|
return \number_format(
|
||||||
$numeric,
|
$numeric,
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ final class Money implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function mult($value) : self
|
public function mult(int|float $value) : self
|
||||||
{
|
{
|
||||||
$this->value = (int) ($this->value * $value);
|
$this->value = (int) ($this->value * $value);
|
||||||
|
|
||||||
|
|
@ -294,7 +294,7 @@ final class Money implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function div($value) : self
|
public function div(int|float $value) : self
|
||||||
{
|
{
|
||||||
$this->value = (int) ($this->value / $value);
|
$this->value = (int) ($this->value / $value);
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ final class Money implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function pow($value) : self
|
public function pow(int|float $value) : self
|
||||||
{
|
{
|
||||||
$this->value = (int) ($this->value ** $value);
|
$this->value = (int) ($this->value ** $value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ final class FileLogger implements LoggerInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function countLogs()
|
public function countLogs() : array
|
||||||
{
|
{
|
||||||
$levels = [];
|
$levels = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -376,45 +376,37 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
/**
|
/**
|
||||||
* Subtract right.
|
* Subtract right.
|
||||||
*
|
*
|
||||||
* @param mixed $value Value
|
* @param int|float|self $value Value
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function sub($value) : self
|
public function sub(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if (\is_numeric($value)) {
|
||||||
return $this->add($value->mult(-1));
|
return $this->addScalar(-$value);
|
||||||
} elseif (!\is_string($value) && \is_numeric($value)) {
|
|
||||||
return $this->add(-$value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Type');
|
return $this->add($value->mult(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add right.
|
* Add right.
|
||||||
*
|
*
|
||||||
* @param mixed $value Value
|
* @param int|float|self $value Value
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function add($value) : self
|
public function add(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if (\is_numeric($value)) {
|
||||||
return $this->addMatrix($value);
|
|
||||||
} elseif (!\is_string($value) && \is_numeric($value)) {
|
|
||||||
return $this->addScalar($value);
|
return $this->addScalar($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException();
|
return $this->addMatrix($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -424,8 +416,6 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function addMatrix(self $matrix) : self
|
private function addMatrix(self $matrix) : self
|
||||||
|
|
@ -476,15 +466,13 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
/**
|
/**
|
||||||
* Add scalar.
|
* Add scalar.
|
||||||
*
|
*
|
||||||
* @param mixed $scalar Scalar
|
* @param int|float $scalar Scalar
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function addScalar($scalar) : self
|
private function addScalar(int|float $scalar) : self
|
||||||
{
|
{
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
|
|
@ -503,23 +491,19 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
/**
|
/**
|
||||||
* Multiply right.
|
* Multiply right.
|
||||||
*
|
*
|
||||||
* @param mixed $value Factor
|
* @param int|float|self $value Factor
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function mult($value) : self
|
public function mult(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if ($value instanceof self) {
|
if (\is_numeric($value)) {
|
||||||
return $this->multMatrix($value);
|
|
||||||
} elseif (!\is_string($value) && \is_numeric($value)) {
|
|
||||||
return $this->multScalar($value);
|
return $this->multScalar($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException('Type');
|
return $this->multMatrix($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -529,8 +513,6 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function multMatrix(self $matrix) : self
|
private function multMatrix(self $matrix) : self
|
||||||
|
|
@ -566,15 +548,13 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
/**
|
/**
|
||||||
* Multiply matrix.
|
* Multiply matrix.
|
||||||
*
|
*
|
||||||
* @param mixed $scalar Scalar value
|
* @param int|float $scalar Scalar value
|
||||||
*
|
*
|
||||||
* @return Matrix
|
* @return Matrix
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function multScalar($scalar) : self
|
private function multScalar(int|float $scalar) : self
|
||||||
{
|
{
|
||||||
$newMatrixArr = $this->matrix;
|
$newMatrixArr = $this->matrix;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,14 @@ final class Vector extends Matrix
|
||||||
/**
|
/**
|
||||||
* Set vector value
|
* Set vector value
|
||||||
*
|
*
|
||||||
* @param int $m Position to set
|
* @param int $m Position to set
|
||||||
* @param mixed $value Value to set
|
* @param int|float $value Value to set
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setV(int $m, $value) : void
|
public function setV(int $m, int|float $value) : void
|
||||||
{
|
{
|
||||||
parent::set($m , 0, $value);
|
parent::set($m , 0, $value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,23 +217,19 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Add opperator
|
* Add opperator
|
||||||
*
|
*
|
||||||
* @param mixed $value Value to add
|
* @param int|float|self $value Value to add
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException This exception is thrown if the argument has an invalid type
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function add($value) : self
|
public function add(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if (\is_numeric($value)) {
|
if (\is_numeric($value)) {
|
||||||
return $this->addScalar($value);
|
return $this->addScalar($value);
|
||||||
} elseif ($value instanceof self) {
|
|
||||||
return $this->addComplex($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException();
|
return $this->addComplex($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -253,13 +249,13 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Add opperator
|
* Add opperator
|
||||||
*
|
*
|
||||||
* @param mixed $val Value to add
|
* @param int|float $val Value to add
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function addScalar($val) : self
|
private function addScalar(int|float $val) : self
|
||||||
{
|
{
|
||||||
return new self($this->re + $val, $this->im);
|
return new self($this->re + $val, $this->im);
|
||||||
}
|
}
|
||||||
|
|
@ -267,23 +263,19 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Sub opperator
|
* Sub opperator
|
||||||
*
|
*
|
||||||
* @param mixed $value Value to sub
|
* @param int|float|self $value Value to sub
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException This exception is thrown if the argument has an invalid type
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function sub($value) : self
|
public function sub(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if (\is_numeric($value)) {
|
if (\is_numeric($value)) {
|
||||||
return $this->subScalar($value);
|
return $this->subScalar($value);
|
||||||
} elseif ($value instanceof self) {
|
|
||||||
return $this->subComplex($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException();
|
return $this->subComplex($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -303,13 +295,13 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Sub opperator
|
* Sub opperator
|
||||||
*
|
*
|
||||||
* @param mixed $val Value to sub
|
* @param int|float $val Value to sub
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function subScalar($val) : self
|
private function subScalar(int|float $val) : self
|
||||||
{
|
{
|
||||||
return new self($this->re - $val, $this->im);
|
return new self($this->re - $val, $this->im);
|
||||||
}
|
}
|
||||||
|
|
@ -317,23 +309,19 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Mult opperator
|
* Mult opperator
|
||||||
*
|
*
|
||||||
* @param mixed $value Value to mult
|
* @param int|float|self $value Value to mult
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException This exception is thrown if the argument has an invalid type
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function mult($value) : self
|
public function mult(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if (\is_numeric($value)) {
|
if (\is_numeric($value)) {
|
||||||
return $this->multScalar($value);
|
return $this->multScalar($value);
|
||||||
} elseif ($value instanceof self) {
|
|
||||||
return $this->multComplex($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException();
|
return $this->multComplex($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -356,13 +344,13 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Mult opperator
|
* Mult opperator
|
||||||
*
|
*
|
||||||
* @param mixed $val Value to mult
|
* @param int|float $val Value to mult
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function multScalar($val) : self
|
private function multScalar(int|float $val) : self
|
||||||
{
|
{
|
||||||
return new self($this->re * $val, $this->im * $val);
|
return new self($this->re * $val, $this->im * $val);
|
||||||
}
|
}
|
||||||
|
|
@ -370,7 +358,7 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Div opperator
|
* Div opperator
|
||||||
*
|
*
|
||||||
* @param mixed $value Value to div
|
* @param int|float|self $value Value to div
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
|
|
@ -378,15 +366,13 @@ final class Complex
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function div($value) : self
|
public function div(int|float|self $value) : self
|
||||||
{
|
{
|
||||||
if (\is_numeric($value)) {
|
if (\is_numeric($value)) {
|
||||||
return $this->divScalar($value);
|
return $this->divScalar($value);
|
||||||
} elseif ($value instanceof self) {
|
|
||||||
return $this->divComplex($value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException();
|
return $this->divComplex($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -409,13 +395,13 @@ final class Complex
|
||||||
/**
|
/**
|
||||||
* Div opperator
|
* Div opperator
|
||||||
*
|
*
|
||||||
* @param mixed $val Value to div
|
* @param int|float $val Value to div
|
||||||
*
|
*
|
||||||
* @return Complex
|
* @return Complex
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function divScalar($val) : self
|
private function divScalar(int|float $val) : self
|
||||||
{
|
{
|
||||||
return new self($this->re / $val, $this->im / $val);
|
return new self($this->re / $val, $this->im / $val);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ final class Integer
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isInteger($value) : bool
|
public static function isInteger(mixed $value) : bool
|
||||||
{
|
{
|
||||||
return \is_int($value);
|
return \is_int($value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ final class Natural
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isNatural($value) : bool
|
public static function isNatural(mixed $value) : bool
|
||||||
{
|
{
|
||||||
return \is_int($value) && $value >= 0;
|
return \is_int($value) && $value >= 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function add($x);
|
public function add(mixed $x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subtract value.
|
* Subtract value.
|
||||||
|
|
@ -44,7 +44,7 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function sub($x);
|
public function sub(mixed $x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right multiplicate value.
|
* Right multiplicate value.
|
||||||
|
|
@ -55,7 +55,7 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function mult($x);
|
public function mult(mixed $x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right devision value.
|
* Right devision value.
|
||||||
|
|
@ -66,7 +66,7 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function div($x);
|
public function div(mixed $x);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Power of value.
|
* Power of value.
|
||||||
|
|
@ -77,7 +77,7 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function pow($p);
|
public function pow(mixed $p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abs of value.
|
* Abs of value.
|
||||||
|
|
@ -86,5 +86,5 @@ interface OperationInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function abs();
|
public function abs() : mixed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,15 +73,17 @@ final class Evaluator
|
||||||
/**
|
/**
|
||||||
* Parse value.
|
* Parse value.
|
||||||
*
|
*
|
||||||
* @param mixed $value Value to parse
|
* @param int|float|string $value Value to parse
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return int|float
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function parseValue($value)
|
private static function parseValue(int|float|string $value) : int|float
|
||||||
{
|
{
|
||||||
return !\is_string($value) ? $value : (\stripos($value, '.') === false ? (int) $value : (float) $value);
|
return !\is_string($value)
|
||||||
|
? $value
|
||||||
|
: (\stripos($value, '.') === false ? (int) $value : (float) $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ final class MeasureOfDispersion
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function meanDeviation(array $x, float $mean = null, $offset = 0) : float
|
public static function meanDeviation(array $x, float $mean = null, int $offset = 0) : float
|
||||||
{
|
{
|
||||||
$mean = $mean !== null ? $mean : Average::arithmeticMean($x);
|
$mean = $mean !== null ? $mean : Average::arithmeticMean($x);
|
||||||
$sum = 0.0;
|
$sum = 0.0;
|
||||||
|
|
@ -362,7 +362,7 @@ final class MeasureOfDispersion
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function meanAbsoluteDeviation(array $x, float $mean = null, $offset = 0) : float
|
public static function meanAbsoluteDeviation(array $x, float $mean = null, int $offset = 0) : float
|
||||||
{
|
{
|
||||||
$mean = $mean !== null ? $mean : Average::arithmeticMean($x);
|
$mean = $mean !== null ? $mean : Average::arithmeticMean($x);
|
||||||
$sum = 0.0;
|
$sum = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ final class CauchyDistribution
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getMode($x0) : float
|
public static function getMode(float $x0) : float
|
||||||
{
|
{
|
||||||
return $x0;
|
return $x0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ final class ParetoDistribution
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getMode($xm) : float
|
public static function getMode(float $xm) : float
|
||||||
{
|
{
|
||||||
return $xm;
|
return $xm;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,13 +100,13 @@ final class ConsoleHeader extends HeaderAbstract
|
||||||
/**
|
/**
|
||||||
* Remove header by ID.
|
* Remove header by ID.
|
||||||
*
|
*
|
||||||
* @param mixed $key Header key
|
* @param string $key Header key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remove($key) : bool
|
public function remove(string $key) : bool
|
||||||
{
|
{
|
||||||
if ($this->isLocked) {
|
if ($this->isLocked) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,13 @@ final class ConsoleResponse extends ResponseAbstract implements RenderableInterf
|
||||||
/**
|
/**
|
||||||
* Remove response by ID.
|
* Remove response by ID.
|
||||||
*
|
*
|
||||||
* @param mixed $id Response ID
|
* @param string $id Response ID
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remove($id) : bool
|
public function remove(string $id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->response[$id])) {
|
if (isset($this->response[$id])) {
|
||||||
unset($this->response[$id]);
|
unset($this->response[$id]);
|
||||||
|
|
|
||||||
|
|
@ -171,13 +171,13 @@ final class HttpHeader extends HeaderAbstract
|
||||||
/**
|
/**
|
||||||
* Remove header by ID.
|
* Remove header by ID.
|
||||||
*
|
*
|
||||||
* @param mixed $key Header key
|
* @param string $key Header key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remove($key) : bool
|
public function remove(string $key) : bool
|
||||||
{
|
{
|
||||||
if ($this->isLocked) {
|
if ($this->isLocked) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -64,13 +64,13 @@ final class HttpResponse extends ResponseAbstract implements RenderableInterface
|
||||||
/**
|
/**
|
||||||
* Remove response by ID.
|
* Remove response by ID.
|
||||||
*
|
*
|
||||||
* @param mixed $id Response ID
|
* @param string $id Response ID
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remove($id) : bool
|
public function remove(string $id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->response[$id])) {
|
if (isset($this->response[$id])) {
|
||||||
unset($this->response[$id]);
|
unset($this->response[$id]);
|
||||||
|
|
|
||||||
|
|
@ -77,13 +77,13 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Data key
|
* @param string $key Data key
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getData($key = null)
|
public function getData(string $key = null) : mixed
|
||||||
{
|
{
|
||||||
if ($key === null) {
|
if ($key === null) {
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
|
@ -97,13 +97,13 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Data key
|
* @param string $key Data key
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getDataJson($key) : array
|
public function getDataJson(string $key) : array
|
||||||
{
|
{
|
||||||
$key = \mb_strtolower($key);
|
$key = \mb_strtolower($key);
|
||||||
|
|
||||||
|
|
@ -119,14 +119,14 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Data key
|
* @param string $key Data key
|
||||||
* @param string $delim Data delimiter
|
* @param string $delim Data delimiter
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getDataList($key, string $delim = ',') : array
|
public function getDataList(string $key, string $delim = ',') : array
|
||||||
{
|
{
|
||||||
$key = \mb_strtolower($key);
|
$key = \mb_strtolower($key);
|
||||||
|
|
||||||
|
|
@ -171,13 +171,13 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Check if has data.
|
* Check if has data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Data key
|
* @param string $key Data key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function hasData($key) : bool
|
public function hasData(string $key) : bool
|
||||||
{
|
{
|
||||||
return isset($this->data[$key]);
|
return isset($this->data[$key]);
|
||||||
}
|
}
|
||||||
|
|
@ -185,15 +185,15 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
/**
|
/**
|
||||||
* Set request data.
|
* Set request data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Data key
|
* @param string $key Data key
|
||||||
* @param mixed $value Value
|
* @param mixed $value Value
|
||||||
* @param bool $overwrite Overwrite data
|
* @param bool $overwrite Overwrite data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setData($key, $value, bool $overwrite = false) : bool
|
public function setData(string $key, mixed $value, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
if (!$this->lock) {
|
if (!$this->lock) {
|
||||||
$key = \mb_strtolower($key);
|
$key = \mb_strtolower($key);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function get($id)
|
public function get(mixed $id) : mixed
|
||||||
{
|
{
|
||||||
return $this->response[$id] ?? null;
|
return $this->response[$id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +65,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set($key, $response, bool $overwrite = false) : void
|
public function set(mixed $key, mixed $response, bool $overwrite = false) : void
|
||||||
{
|
{
|
||||||
// This is not working since the key contains :: from http://
|
// This is not working since the key contains :: from http://
|
||||||
//$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite);
|
//$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ final class FormElementGenerator
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function generate(array $json, $value = null, array $lang = []) : string
|
public static function generate(array $json, mixed $value = null, array $lang = []) : string
|
||||||
{
|
{
|
||||||
if (!isset($json['type'])) {
|
if (!isset($json['type'])) {
|
||||||
return 'INVALID';
|
return 'INVALID';
|
||||||
|
|
@ -67,7 +67,7 @@ final class FormElementGenerator
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function generateInput(array $json, $value = null, array $lang = []) : string
|
private static function generateInput(array $json, mixed $value = null, array $lang = []) : string
|
||||||
{
|
{
|
||||||
$element = '<input';
|
$element = '<input';
|
||||||
foreach ($json['attributes'] as $attribute => $val) {
|
foreach ($json['attributes'] as $attribute => $val) {
|
||||||
|
|
@ -96,7 +96,7 @@ final class FormElementGenerator
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function generateSelect(array $json, $value = null, array $lang = []) : string
|
private static function generateSelect(array $json, mixed $value = null, array $lang = []) : string
|
||||||
{
|
{
|
||||||
$element = '<select';
|
$element = '<select';
|
||||||
foreach ($json['attributes'] as $attribute => $val) {
|
foreach ($json['attributes'] as $attribute => $val) {
|
||||||
|
|
@ -126,7 +126,7 @@ final class FormElementGenerator
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function generateTextarea(array $json, $value = null) : string
|
private static function generateTextarea(array $json, mixed $value = null) : string
|
||||||
{
|
{
|
||||||
$element = '<textarea';
|
$element = '<textarea';
|
||||||
foreach ($json['attributes'] as $attribute => $val) {
|
foreach ($json['attributes'] as $attribute => $val) {
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ abstract class ModuleAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, $obj) : void
|
protected function fillJsonRawResponse(RequestAbstract $request, ResponseAbstract $response, mixed $obj) : void
|
||||||
{
|
{
|
||||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||||
$response->set($request->uri->__toString(), $obj);
|
$response->set($request->uri->__toString(), $obj);
|
||||||
|
|
@ -257,7 +257,7 @@ abstract class ModuleAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function createModel(int $account, $obj, string $mapper, string $trigger, string $ip) : void
|
protected function createModel(int $account, mixed $obj, string $mapper, string $trigger, string $ip) : void
|
||||||
{
|
{
|
||||||
$this->app->eventManager->triggerSimilar('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', $obj);
|
$this->app->eventManager->triggerSimilar('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', $obj);
|
||||||
$id = $mapper::create($obj);
|
$id = $mapper::create($obj);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ abstract class Enum
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValidValue($value) : bool
|
public static function isValidValue(mixed $value) : bool
|
||||||
{
|
{
|
||||||
$constants = self::getConstants();
|
$constants = self::getConstants();
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ abstract class Enum
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getRandom()
|
public static function getRandom() : mixed
|
||||||
{
|
{
|
||||||
$constants = self::getConstants();
|
$constants = self::getConstants();
|
||||||
$keys = \array_keys($constants);
|
$keys = \array_keys($constants);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ abstract class EnumArray
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValidValue($value) : bool
|
public static function isValidValue(mixed $value) : bool
|
||||||
{
|
{
|
||||||
return \in_array($value, static::$constants, true);
|
return \in_array($value, static::$constants, true);
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ abstract class EnumArray
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function get($key)
|
public static function get(mixed $key) : mixed
|
||||||
{
|
{
|
||||||
if (!isset(static::$constants[$key])) {
|
if (!isset(static::$constants[$key])) {
|
||||||
throw new \OutOfBoundsException('Key "' . $key . '" is not valid.');
|
throw new \OutOfBoundsException('Key "' . $key . '" is not valid.');
|
||||||
|
|
@ -117,7 +117,7 @@ abstract class EnumArray
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getRandom()
|
public static function getRandom() : mixed
|
||||||
{
|
{
|
||||||
$keys = \array_keys(static::$constants);
|
$keys = \array_keys(static::$constants);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function insort($x, int $lo = 0) : void
|
public function insort(mixed $x, int $lo = 0) : void
|
||||||
{
|
{
|
||||||
$hi = \count($this->nodes);
|
$hi = \count($this->nodes);
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function push($item) : void
|
public function push(mixed $item) : void
|
||||||
{
|
{
|
||||||
$this->nodes[] = $item;
|
$this->nodes[] = $item;
|
||||||
$this->siftDown(0, \count($this->nodes) - 1);
|
$this->siftDown(0, \count($this->nodes) - 1);
|
||||||
|
|
@ -102,7 +102,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function pop()
|
public function pop() : mixed
|
||||||
{
|
{
|
||||||
$last = \array_pop($this->nodes);
|
$last = \array_pop($this->nodes);
|
||||||
if (empty($this->nodes)) {
|
if (empty($this->nodes)) {
|
||||||
|
|
@ -123,7 +123,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function peek()
|
public function peek() : mixed
|
||||||
{
|
{
|
||||||
return $this->nodes[0];
|
return $this->nodes[0];
|
||||||
}
|
}
|
||||||
|
|
@ -137,7 +137,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function contains($item) : bool
|
public function contains(mixed $item) : bool
|
||||||
{
|
{
|
||||||
foreach ($this->nodes as $key => $node) {
|
foreach ($this->nodes as $key => $node) {
|
||||||
if (\is_scalar($item)) {
|
if (\is_scalar($item)) {
|
||||||
|
|
@ -161,7 +161,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function replace($new)
|
public function replace(mixed $new) : mixed
|
||||||
{
|
{
|
||||||
$old = $this->nodes[0];
|
$old = $this->nodes[0];
|
||||||
$this->nodes[0] = $new;
|
$this->nodes[0] = $new;
|
||||||
|
|
@ -179,7 +179,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function pushpop($item)
|
public function pushpop(mixed $item) : mixed
|
||||||
{
|
{
|
||||||
if (!empty($this->nodes) && ($this->compare)($this->nodes[0], $item) < 0) {
|
if (!empty($this->nodes) && ($this->compare)($this->nodes[0], $item) < 0) {
|
||||||
$temp = $item;
|
$temp = $item;
|
||||||
|
|
@ -220,7 +220,7 @@ class Heap
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function update($item) : bool
|
public function update(mixed $item) : bool
|
||||||
{
|
{
|
||||||
$pos = null;
|
$pos = null;
|
||||||
foreach ($this->nodes as $key => $node) {
|
foreach ($this->nodes as $key => $node) {
|
||||||
|
|
|
||||||
|
|
@ -82,13 +82,13 @@ class Graph
|
||||||
/**
|
/**
|
||||||
* Get graph node
|
* Get graph node
|
||||||
*
|
*
|
||||||
* @param mixed $key Node key
|
* @param int|string $key Node key
|
||||||
*
|
*
|
||||||
* @return null|Node
|
* @return null|Node
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getNode(mixed $key) : ?Node
|
public function getNode(int|string $key) : ?Node
|
||||||
{
|
{
|
||||||
return $this->nodes[$key] ?? null;
|
return $this->nodes[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
@ -111,13 +111,13 @@ class Graph
|
||||||
/**
|
/**
|
||||||
* Graph has node
|
* Graph has node
|
||||||
*
|
*
|
||||||
* @param mixed $key Node key
|
* @param int|string $key Node key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function hasNode($key) : bool
|
public function hasNode(int|string $key) : bool
|
||||||
{
|
{
|
||||||
return isset($this->nodes[$key]);
|
return isset($this->nodes[$key]);
|
||||||
}
|
}
|
||||||
|
|
@ -543,14 +543,14 @@ class Graph
|
||||||
/**
|
/**
|
||||||
* Get longest path between two nodes.
|
* Get longest path between two nodes.
|
||||||
*
|
*
|
||||||
* @param mixed $node1 Graph node
|
* @param int|string $node1 Graph node
|
||||||
* @param mixed $node2 Graph node
|
* @param int|string $node2 Graph node
|
||||||
*
|
*
|
||||||
* @return Node[]
|
* @return Node[]
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function longestPathBetweenNodes($node1, $node2) : array
|
public function longestPathBetweenNodes(int|string $node1, int|string $node2) : array
|
||||||
{
|
{
|
||||||
if (!($node1 instanceof Node)) {
|
if (!($node1 instanceof Node)) {
|
||||||
$node1 = $this->getNode($node1);
|
$node1 = $this->getNode($node1);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class Node
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct(string $id, $data = null)
|
public function __construct(string $id, mixed $data = null)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
|
@ -81,7 +81,7 @@ class Node
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getData()
|
public function getData() : mixed
|
||||||
{
|
{
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ class Node
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setData($data) : void
|
public function setData(mixed $data) : void
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ final class MultiMap implements \Countable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function add(array $keys, $value, bool $overwrite = false) : bool
|
public function add(array $keys, mixed $value, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$id = \count($this->values);
|
$id = \count($this->values);
|
||||||
$inserted = false;
|
$inserted = false;
|
||||||
|
|
@ -176,13 +176,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function get($key)
|
public function get(int|string|array $key) : mixed
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::SINGLE) {
|
if ($this->keyType === KeyType::SINGLE) {
|
||||||
return $this->getSingle($key);
|
return $this->getSingle($key);
|
||||||
|
|
@ -194,13 +194,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function getSingle($key)
|
private function getSingle(int|string $key) : mixed
|
||||||
{
|
{
|
||||||
return isset($this->keys[$key]) ? $this->values[$this->keys[$key]] ?? null : null;
|
return isset($this->keys[$key]) ? $this->values[$this->keys[$key]] ?? null : null;
|
||||||
}
|
}
|
||||||
|
|
@ -208,13 +208,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get data.
|
* Get data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function getMultiple($key)
|
private function getMultiple(int|string|array $key) : mixed
|
||||||
{
|
{
|
||||||
if (\is_array($key)) {
|
if (\is_array($key)) {
|
||||||
if ($this->orderType === OrderType::LOOSE) {
|
if ($this->orderType === OrderType::LOOSE) {
|
||||||
|
|
@ -239,14 +239,14 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Set existing key with data.
|
* Set existing key with data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
* @param mixed $value Value to store
|
* @param mixed $value Value to store
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function set($key, $value) : bool
|
public function set(int|string|array $key, mixed $value) : bool
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::MULTIPLE && \is_array($key)) {
|
if ($this->keyType === KeyType::MULTIPLE && \is_array($key)) {
|
||||||
return $this->setMultiple($key, $value);
|
return $this->setMultiple($key, $value);
|
||||||
|
|
@ -258,14 +258,14 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Set existing key with data.
|
* Set existing key with data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
* @param mixed $value Value to store
|
* @param mixed $value Value to store
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function setMultiple($key, $value) : bool
|
private function setMultiple(int|string|array $key, mixed $value) : bool
|
||||||
{
|
{
|
||||||
if ($this->orderType !== OrderType::STRICT) {
|
if ($this->orderType !== OrderType::STRICT) {
|
||||||
/** @var array<string[]> $permutation */
|
/** @var array<string[]> $permutation */
|
||||||
|
|
@ -286,14 +286,14 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Set existing key with data.
|
* Set existing key with data.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string $key Key used to identify value
|
||||||
* @param mixed $value Value to store
|
* @param mixed $value Value to store
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function setSingle($key, $value) : bool
|
private function setSingle(int|string $key, mixed $value) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->keys[$key])) {
|
if (isset($this->keys[$key])) {
|
||||||
$this->values[$this->keys[$key]] = $value;
|
$this->values[$this->keys[$key]] = $value;
|
||||||
|
|
@ -307,13 +307,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Remove value and all sibling keys based on key.
|
* Remove value and all sibling keys based on key.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remove($key) : bool
|
public function remove(int|string|array $key) : bool
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::MULTIPLE && \is_array($key)) {
|
if ($this->keyType === KeyType::MULTIPLE && \is_array($key)) {
|
||||||
return $this->removeMultiple($key);
|
return $this->removeMultiple($key);
|
||||||
|
|
@ -325,13 +325,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Remove value and all sibling keys based on key.
|
* Remove value and all sibling keys based on key.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function removeMultiple($key) : bool
|
private function removeMultiple(int|string|array $key) : bool
|
||||||
{
|
{
|
||||||
if ($this->orderType !== OrderType::LOOSE) {
|
if ($this->orderType !== OrderType::LOOSE) {
|
||||||
return $this->remove(\implode(':', $key));
|
return $this->remove(\implode(':', $key));
|
||||||
|
|
@ -355,13 +355,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Remove value and all sibling keys based on key.
|
* Remove value and all sibling keys based on key.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function removeSingle($key) : bool
|
private function removeSingle(int|string $key) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->keys[$key])) {
|
if (isset($this->keys[$key])) {
|
||||||
$id = $this->keys[$key];
|
$id = $this->keys[$key];
|
||||||
|
|
@ -381,14 +381,14 @@ final class MultiMap implements \Countable
|
||||||
*
|
*
|
||||||
* Both keys need to exist in the multimap.
|
* Both keys need to exist in the multimap.
|
||||||
*
|
*
|
||||||
* @param mixed $old Old key
|
* @param int|string|array $old Old key
|
||||||
* @param mixed $new New key
|
* @param int|string|array $new New key
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function remap($old, $new) : bool
|
public function remap(int|string|array $old, int|string|array $new) : bool
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::MULTIPLE) {
|
if ($this->keyType === KeyType::MULTIPLE) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -410,13 +410,13 @@ final class MultiMap implements \Countable
|
||||||
*
|
*
|
||||||
* This only removes the value if no other key exists for this value.
|
* This only removes the value if no other key exists for this value.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string|array $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function removeKey($key) : bool
|
public function removeKey(int|string|array $key) : bool
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::MULTIPLE) {
|
if ($this->keyType === KeyType::MULTIPLE) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -430,13 +430,13 @@ final class MultiMap implements \Countable
|
||||||
*
|
*
|
||||||
* This only removes the value if no other key exists for this value.
|
* This only removes the value if no other key exists for this value.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key used to identify value
|
* @param int|string $key Key used to identify value
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function removeKeySingle($key) : bool
|
private function removeKeySingle(int|string $key) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->keys[$key])) {
|
if (isset($this->keys[$key])) {
|
||||||
unset($this->keys[$key]);
|
unset($this->keys[$key]);
|
||||||
|
|
@ -452,13 +452,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get all sibling keys.
|
* Get all sibling keys.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key to find siblings for
|
* @param int|string|array $key Key to find siblings for
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getSiblings($key) : array
|
public function getSiblings(int|string|array $key) : array
|
||||||
{
|
{
|
||||||
if ($this->keyType === KeyType::MULTIPLE) {
|
if ($this->keyType === KeyType::MULTIPLE) {
|
||||||
return $this->getSiblingsMultiple($key);
|
return $this->getSiblingsMultiple($key);
|
||||||
|
|
@ -470,13 +470,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get all sibling keys.
|
* Get all sibling keys.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key to find siblings for
|
* @param int|string|array $key Key to find siblings for
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getSiblingsMultiple($key) : array
|
public function getSiblingsMultiple(int|string|array $key) : array
|
||||||
{
|
{
|
||||||
if ($this->orderType === OrderType::LOOSE) {
|
if ($this->orderType === OrderType::LOOSE) {
|
||||||
$key = \is_array($key) ? $key : [$key];
|
$key = \is_array($key) ? $key : [$key];
|
||||||
|
|
@ -490,13 +490,13 @@ final class MultiMap implements \Countable
|
||||||
/**
|
/**
|
||||||
* Get all sibling keys.
|
* Get all sibling keys.
|
||||||
*
|
*
|
||||||
* @param mixed $key Key to find siblings for
|
* @param int|string $key Key to find siblings for
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private function getSiblingsSingle($key) : array
|
private function getSiblingsSingle(int|string $key) : array
|
||||||
{
|
{
|
||||||
$siblings = [];
|
$siblings = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function insert($data, float $priority = 1.0) : int
|
public function insert(mixed $data, float $priority = 1.0) : int
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
$key = \mt_rand();
|
$key = \mt_rand();
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function ftpConnect(HttpUri $http)
|
public static function ftpConnect(HttpUri $http) : mixed
|
||||||
{
|
{
|
||||||
$con = \ftp_connect($http->host, $http->port, 10);
|
$con = \ftp_connect($http->host, $http->port, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class File extends FileAbstract implements FileInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function ftpConnect(HttpUri $http)
|
public static function ftpConnect(HttpUri $http) : mixed
|
||||||
{
|
{
|
||||||
$con = \ftp_connect($http->host, $http->port, 10);
|
$con = \ftp_connect($http->host, $http->port, 10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ final class ArrayUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function setArray(string $path, array $data, $value, string $delim = '/', bool $overwrite = false) : array
|
public static function setArray(string $path, array $data, mixed $value, string $delim = '/', bool $overwrite = false) : array
|
||||||
{
|
{
|
||||||
$pathParts = \explode($delim, \trim($path, $delim));
|
$pathParts = \explode($delim, \trim($path, $delim));
|
||||||
$current = &$data;
|
$current = &$data;
|
||||||
|
|
@ -129,7 +129,7 @@ final class ArrayUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getArray(string $path, array $data, string $delim = '/')
|
public static function getArray(string $path, array $data, string $delim = '/') : mixed
|
||||||
{
|
{
|
||||||
$pathParts = \explode($delim, \trim($path, $delim));
|
$pathParts = \explode($delim, \trim($path, $delim));
|
||||||
$current = $data;
|
$current = $data;
|
||||||
|
|
@ -160,7 +160,7 @@ final class ArrayUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function inArrayRecursive($needle, array $haystack, $key = null) : bool
|
public static function inArrayRecursive(mixed $needle, array $haystack, $key = null) : bool
|
||||||
{
|
{
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
|
|
@ -356,7 +356,7 @@ final class ArrayUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function arraySumRecursive(array $array)
|
public static function arraySumRecursive(array $array) : mixed
|
||||||
{
|
{
|
||||||
return \array_sum(self::arrayFlatten($array));
|
return \array_sum(self::arrayFlatten($array));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ abstract class C128Abstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function get()
|
public function get() : mixed
|
||||||
{
|
{
|
||||||
$codeString = static::$CODE_START . $this->generateCodeString() . static::$CODE_END;
|
$codeString = static::$CODE_START . $this->generateCodeString() . static::$CODE_END;
|
||||||
|
|
||||||
|
|
@ -321,7 +321,7 @@ abstract class C128Abstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected function createImage(string $codeString)
|
protected function createImage(string $codeString) : mixed
|
||||||
{
|
{
|
||||||
$dimensions = $this->calculateDimensions($codeString);
|
$dimensions = $this->calculateDimensions($codeString);
|
||||||
$image = \imagecreate($dimensions['width'], $dimensions['height']);
|
$image = \imagecreate($dimensions['width'], $dimensions['height']);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface EncodingInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function encode($source);
|
public static function encode(mixed $source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dedecodes text
|
* Dedecodes text
|
||||||
|
|
@ -44,5 +44,5 @@ interface EncodingInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function decode($decoded);
|
public static function decode(mixed $decoded);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ class Repository
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function commit(Commit $commit, $all = true) : string
|
public function commit(Commit $commit, bool $all = true) : string
|
||||||
{
|
{
|
||||||
return \implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . \escapeshellarg($commit->getMessage())));
|
return \implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . \escapeshellarg($commit->getMessage())));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface CsvInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function exportCsv($path) : void;
|
public function exportCsv(string $path) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import Csv.
|
* Import Csv.
|
||||||
|
|
@ -44,5 +44,5 @@ interface CsvInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function importCsv($path) : void;
|
public function importCsv(string $path) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface JsonInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function exportJson($path) : void;
|
public function exportJson(string $path) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import Json.
|
* Import Json.
|
||||||
|
|
@ -44,5 +44,5 @@ interface JsonInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function importJson($path) : void;
|
public function importJson(string $path) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,5 @@ interface PdfInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function exportPdf($path) : void;
|
public function exportPdf(string $path) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ interface SpreadsheetInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function exportSpreadsheet($path) : void;
|
public function exportSpreadsheet(string $path) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import Spreadsheet.
|
* Import Spreadsheet.
|
||||||
|
|
@ -44,5 +44,5 @@ interface SpreadsheetInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function importSpreadsheet($path) : void;
|
public function importSpreadsheet(string $path) : void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,15 @@ interface ArchiveInterface
|
||||||
/**
|
/**
|
||||||
* Create archive.
|
* Create archive.
|
||||||
*
|
*
|
||||||
* @param mixed $sources Files and directories to compress
|
* @param string|array $sources Files and directories to compress
|
||||||
* @param string $destination Output destination
|
* @param string $destination Output destination
|
||||||
* @param bool $overwrite Overwrite if destination is existing
|
* @param bool $overwrite Overwrite if destination is existing
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function pack($sources, string $destination, bool $overwrite = false) : bool;
|
public static function pack(string|array $sources, string $destination, bool $overwrite = false) : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpack archive.
|
* Unpack archive.
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class Gz implements ArchiveInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function pack($source, string $destination, bool $overwrite = false) : bool
|
public static function pack(string|array $source, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = \str_replace('\\', '/', $destination);
|
$destination = \str_replace('\\', '/', $destination);
|
||||||
if (!$overwrite && \is_file($destination) || !\is_file($source)) {
|
if (!$overwrite && \is_file($destination) || !\is_file($source)) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Tar implements ArchiveInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function pack($sources, string $destination, bool $overwrite = false) : bool
|
public static function pack(string|array $sources, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class TarGz implements ArchiveInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function pack($source, string $destination, bool $overwrite = false) : bool
|
public static function pack(string|array $source, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = \str_replace('\\', '/', $destination);
|
$destination = \str_replace('\\', '/', $destination);
|
||||||
if (!$overwrite && \is_file($destination)) {
|
if (!$overwrite && \is_file($destination)) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Zip implements ArchiveInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function pack($sources, string $destination, bool $overwrite = false) : bool
|
public static function pack(string|array $sources, string $destination, bool $overwrite = false) : bool
|
||||||
{
|
{
|
||||||
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
$destination = FileUtils::absolute(\str_replace('\\', '/', $destination));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ final class MbStringUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function mb_startsWith(string $haystack, $needles) : bool
|
public static function mb_startsWith(string $haystack, string|array $needles) : bool
|
||||||
{
|
{
|
||||||
if (\is_string($needles)) {
|
if (\is_string($needles)) {
|
||||||
$needles = [$needles];
|
$needles = [$needles];
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class ArrayParser
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function parseVariable($value, int $depth = 1) : string
|
public static function parseVariable(mixed $value, int $depth = 1) : string
|
||||||
{
|
{
|
||||||
if (\is_array($value)) {
|
if (\is_array($value)) {
|
||||||
return self::serializeArray($value, $depth);
|
return self::serializeArray($value, $depth);
|
||||||
|
|
|
||||||
|
|
@ -103,13 +103,13 @@ final class Permutation
|
||||||
* @param array|string $toPermute To permutate
|
* @param array|string $toPermute To permutate
|
||||||
* @param array $key Permutation keys
|
* @param array $key Permutation keys
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return string|array
|
||||||
*
|
*
|
||||||
* @throws \OutOfBoundsException This exception is thrown if the permutation key is larger than the data to permute
|
* @throws \OutOfBoundsException This exception is thrown if the permutation key is larger than the data to permute
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function permutate($toPermute, array $key)
|
public static function permutate(string|array $toPermute, array $key) : string|array
|
||||||
{
|
{
|
||||||
$length = \is_array($toPermute) ? \count($toPermute) : \strlen($toPermute);
|
$length = \is_array($toPermute) ? \count($toPermute) : \strlen($toPermute);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ final class StringUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function stringify($element, $option = null) : ?string
|
public static function stringify(mixed $element, mixed $option = null) : ?string
|
||||||
{
|
{
|
||||||
if ($element instanceof \JsonSerializable || \is_array($element)) {
|
if ($element instanceof \JsonSerializable || \is_array($element)) {
|
||||||
$encoded = \json_encode($element, $option !== null ? $option : 0);
|
$encoded = \json_encode($element, $option !== null ? $option : 0);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ final class TestUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function setMember(object $obj, string $name, $value) : bool
|
public static function setMember(object $obj, string $name, mixed $value) : bool
|
||||||
{
|
{
|
||||||
$reflectionClass = new \ReflectionClass(\get_class($obj));
|
$reflectionClass = new \ReflectionClass(\get_class($obj));
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ final class TestUtils
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function getMember(object $obj, string $name)
|
public static function getMember(object $obj, string $name) : mixed
|
||||||
{
|
{
|
||||||
$reflectionClass = new \ReflectionClass($obj);
|
$reflectionClass = new \ReflectionClass($obj);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ abstract class DateTime extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
return (bool) \strtotime($value);
|
return (bool) \strtotime($value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ abstract class Json extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
\json_decode($value);
|
\json_decode($value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ final class BIC extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
return (bool) \preg_match('/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i', $value);
|
return (bool) \preg_match('/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i', $value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ final class Iban extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
$value = \str_replace(' ', '', \strtolower($value));
|
$value = \str_replace(' ', '', \strtolower($value));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ abstract class Email extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
if (\filter_var($value, \FILTER_VALIDATE_EMAIL) === false) {
|
if (\filter_var($value, \FILTER_VALIDATE_EMAIL) === false) {
|
||||||
self::$msg = 'Invalid Email by filter_var standards';
|
self::$msg = 'Invalid Email by filter_var standards';
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ abstract class Hostname extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
return \filter_var(\gethostbyname($value), \FILTER_VALIDATE_IP) !== false;
|
return \filter_var(\gethostbyname($value), \FILTER_VALIDATE_IP) !== false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ abstract class Ip extends ValidatorAbstract
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null) : bool
|
public static function isValid(mixed $value, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
return \filter_var($value, \FILTER_VALIDATE_IP) !== false;
|
return \filter_var($value, \FILTER_VALIDATE_IP) !== false;
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ abstract class Ip extends ValidatorAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValidIpv6($value) : bool
|
public static function isValidIpv6(mixed $value) : bool
|
||||||
{
|
{
|
||||||
return \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6) !== false;
|
return \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6) !== false;
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ abstract class Ip extends ValidatorAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValidIpv4($value) : bool
|
public static function isValidIpv4(mixed $value) : bool
|
||||||
{
|
{
|
||||||
return \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4) !== false;
|
return \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4) !== false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ final class Validator extends ValidatorAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValid($var, array $constraints = null) : bool
|
public static function isValid(mixed $var, array $constraints = null) : bool
|
||||||
{
|
{
|
||||||
if ($constraints === null) {
|
if ($constraints === null) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ interface ValidatorInterface
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function isValid($value, array $constraints = null);
|
public static function isValid(mixed $value, array $constraints = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get most recent error string.
|
* Get most recent error string.
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ class View extends ViewAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getData(string $id)
|
public function getData(string $id) : mixed
|
||||||
{
|
{
|
||||||
return $this->data[$id] ?? null;
|
return $this->data[$id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,7 @@ class View extends ViewAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setData(string $id, $data) : void
|
public function setData(string $id, mixed $data) : void
|
||||||
{
|
{
|
||||||
$this->data[$id] = $data;
|
$this->data[$id] = $data;
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ class View extends ViewAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function addData(string $id, $data) : bool
|
public function addData(string $id, mixed $data) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->data[$id])) {
|
if (isset($this->data[$id])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -191,7 +191,7 @@ class View extends ViewAbstract
|
||||||
/**
|
/**
|
||||||
* Get translation.
|
* Get translation.
|
||||||
*
|
*
|
||||||
* @param mixed $translation Text
|
* @param string $translation Text
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
* @param string $theme Theme name
|
* @param string $theme Theme name
|
||||||
*
|
*
|
||||||
|
|
@ -199,7 +199,7 @@ class View extends ViewAbstract
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getText($translation, string $module = null, string $theme = null) : string
|
public function getText(string $translation, string $module = null, string $theme = null) : string
|
||||||
{
|
{
|
||||||
if ($module === null && $this->module === null) {
|
if ($module === null && $this->module === null) {
|
||||||
$this->setModuleDynamically();
|
$this->setModuleDynamically();
|
||||||
|
|
|
||||||
|
|
@ -81,29 +81,29 @@ abstract class ViewAbstract implements RenderableInterface
|
||||||
/**
|
/**
|
||||||
* Print html output.
|
* Print html output.
|
||||||
*
|
*
|
||||||
* @param mixed $text Text
|
* @param string $text Text
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function printHtml($text) : string
|
public function printHtml(string $text) : string
|
||||||
{
|
{
|
||||||
return \htmlspecialchars((string) $text);
|
return \htmlspecialchars($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print html output.
|
* Print html output.
|
||||||
*
|
*
|
||||||
* @param mixed $text Text
|
* @param string $text Text
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function html($text) : string
|
public static function html(string $text) : string
|
||||||
{
|
{
|
||||||
return \htmlspecialchars((string) $text);
|
return \htmlspecialchars($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,11 +123,11 @@ abstract class ViewAbstract implements RenderableInterface
|
||||||
*
|
*
|
||||||
* @param string $id View ID
|
* @param string $id View ID
|
||||||
*
|
*
|
||||||
* @return false|View
|
* @return false|self
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getView(string $id)
|
public function getView(string $id) : bool|self
|
||||||
{
|
{
|
||||||
if (!isset($this->views[$id])) {
|
if (!isset($this->views[$id])) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ require_once __DIR__ . '/../../Autoloader.php';
|
||||||
|
|
||||||
class NumericElement implements SortableInterface
|
class NumericElement implements SortableInterface
|
||||||
{
|
{
|
||||||
public $value = 0;
|
public int|float $value = 0;
|
||||||
|
|
||||||
public function __construct($value)
|
public function __construct(int|float $value)
|
||||||
{
|
{
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
@ -38,12 +38,12 @@ class NumericElement implements SortableInterface
|
||||||
return $this->value === $obj->getValue();
|
return $this->value === $obj->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValue()
|
public function getValue() : int|float
|
||||||
{
|
{
|
||||||
return $this->value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function max(array $list)
|
public static function max(array $list) : int|float
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($list as $element) {
|
foreach ($list as $element) {
|
||||||
|
|
@ -53,7 +53,7 @@ class NumericElement implements SortableInterface
|
||||||
return \max($values);
|
return \max($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function min(array $list)
|
public static function min(array $list) : int|float
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($list as $element) {
|
foreach ($list as $element) {
|
||||||
|
|
|
||||||
|
|
@ -192,18 +192,6 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox A invalid destination type throws UnexpectedValueException
|
|
||||||
* @covers phpOMS\Dispatcher\Dispatcher
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidDestination() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\UnexpectedValueException::class);
|
|
||||||
|
|
||||||
$this->app->dispatcher->dispatch(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox A invalid controller path throws a PathException
|
* @testdox A invalid controller path throws a PathException
|
||||||
* @covers phpOMS\Dispatcher\Dispatcher
|
* @covers phpOMS\Dispatcher\Dispatcher
|
||||||
|
|
|
||||||
|
|
@ -438,60 +438,6 @@ class MatrixTest extends \PHPUnit\Framework\TestCase
|
||||||
$id->get(99, 99);
|
$id->get(99, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox Subtracting a invalid data type from a matrix throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Matrix\Matrix
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidSub() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$id = new Matrix();
|
|
||||||
$id->setMatrix([
|
|
||||||
[1, 0],
|
|
||||||
[0, 1],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$id->sub(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox Adding a invalid data type from a matrix throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Matrix\Matrix
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidAdd() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$id = new Matrix();
|
|
||||||
$id->setMatrix([
|
|
||||||
[1, 0],
|
|
||||||
[0, 1],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$id->add(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox Multiplying a invalid data type from a matrix throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Matrix\Matrix
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidMult() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$id = new Matrix();
|
|
||||||
$id->setMatrix([
|
|
||||||
[1, 0],
|
|
||||||
[0, 1],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$id->mult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox Adding a matrix with a different dimension to a matrix throws a InvalidDimensionException
|
* @testdox Adding a matrix with a different dimension to a matrix throws a InvalidDimensionException
|
||||||
* @covers phpOMS\Math\Matrix\Matrix
|
* @covers phpOMS\Math\Matrix\Matrix
|
||||||
|
|
|
||||||
|
|
@ -219,56 +219,4 @@ class ComplexTest extends \PHPUnit\Framework\TestCase
|
||||||
$cpl2 = new Complex(-1, 3);
|
$cpl2 = new Complex(-1, 3);
|
||||||
self::assertEquals('1.04 + 1.44i', $cpl2->sqrt()->render());
|
self::assertEquals('1.04 + 1.44i', $cpl2->sqrt()->render());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox A invalid type addition throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Number\Complex
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidAdd() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$cpl = new Complex(4, 3);
|
|
||||||
$cpl->add(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox A invalid type subtraction throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Number\Complex
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidSub() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$cpl = new Complex(4, 3);
|
|
||||||
$cpl->sub(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox A invalid type cannot multiplication throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Number\Complex
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidMult() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$cpl = new Complex(4, 3);
|
|
||||||
$cpl->mult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox A invalid type division throws a InvalidArgumentException
|
|
||||||
* @covers phpOMS\Math\Number\Complex
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidDiv() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
|
|
||||||
$cpl = new Complex(4, 3);
|
|
||||||
$cpl->div(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class ErrorTest extends \PHPUnit\Framework\TestCase
|
||||||
$scaledErrors = Error::getScaledErrorArray($errors, $observed);
|
$scaledErrors = Error::getScaledErrorArray($errors, $observed);
|
||||||
|
|
||||||
self::assertEqualsWithDelta(
|
self::assertEqualsWithDelta(
|
||||||
Error::getMeanAbsoluteScaledError(ArrayUtils::powerInt($scaledErrors, 2)),
|
Error::getMeanAbsoluteScaledError(ArrayUtils::power($scaledErrors, 2)),
|
||||||
Error::getMeanSquaredScaledError($scaledErrors), 0.01
|
Error::getMeanSquaredScaledError($scaledErrors), 0.01
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user