Fix para types

This commit is contained in:
Dennis Eichhorn 2018-09-11 21:19:55 +02:00
parent 4b791bf12d
commit 1bf1e6da3b
38 changed files with 319 additions and 161 deletions

View File

@ -928,7 +928,7 @@ final class FinanceFormulas
/** /**
* Future Value Factor * Future Value Factor
* *
* @param array $r Rate of return * @param array<int|float> $r Rate of return
* *
* @return float * @return float
* *
@ -1056,8 +1056,8 @@ final class FinanceFormulas
/** /**
* Net Present Value * Net Present Value
* *
* @param array $C Cash flow ($C[0] = initial investment) * @param array<int|float> $C Cash flow ($C[0] = initial investment)
* @param float $r Discount rate * @param float $r Discount rate
* *
* @return float * @return float
* *

View File

@ -27,7 +27,7 @@ final class Lorenzkurve
/** /**
* Calculate Gini coefficient * Calculate Gini coefficient
* *
* @param array $data Datapoints (can be unsorted) * @param array<int|float> $data Datapoints (can be unsorted)
* *
* @return float * @return float
* *

View File

@ -198,7 +198,7 @@ final class StockBonds
/** /**
* Holding Period Return * Holding Period Return
* *
* @param array $r Rate of return * @param array<int|float> $r Rate of return
* *
* @return float * @return float
* *

View File

@ -179,7 +179,7 @@ final class Localization
/** /**
* Load localization from locale * Load localization from locale
* *
* @param array $locale Locale data * @param array<string, mixed> $locale Locale data
* *
* @return void * @return void
* *
@ -193,7 +193,7 @@ final class Localization
$this->setThousands($locale['thousand'] ?? ','); $this->setThousands($locale['thousand'] ?? ',');
$this->setDecimal($locale['decimal'] ?? '.'); $this->setDecimal($locale['decimal'] ?? '.');
$this->setAngle($locale['angle'] ?? AngleType::DEGREE); $this->setAngle($locale['angle'] ?? AngleType::DEGREE);
$this->setTemperature($locale['temperature'] ?? emperatureType::CELSIUS); $this->setTemperature($locale['temperature'] ?? TemperatureType::CELSIUS);
$this->setWeight($locale['weight'] ?? []); $this->setWeight($locale['weight'] ?? []);
$this->setSpeed($locale['speed'] ?? []); $this->setSpeed($locale['speed'] ?? []);
$this->setLength($locale['length'] ?? []); $this->setLength($locale['length'] ?? []);
@ -459,7 +459,7 @@ final class Localization
/** /**
* Get speed type * Get speed type
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -471,7 +471,7 @@ final class Localization
/** /**
* Set speed type * Set speed type
* *
* @param array $speed Speed * @param array<string, string> $speed Speed
* *
* @return void * @return void
* *
@ -485,7 +485,7 @@ final class Localization
/** /**
* Get weight type * Get weight type
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -497,7 +497,7 @@ final class Localization
/** /**
* Set weight type * Set weight type
* *
* @param array $weight Weight type * @param array<string, string> $weight Weight type
* *
* @return void * @return void
* *
@ -511,7 +511,7 @@ final class Localization
/** /**
* Get length type * Get length type
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -523,7 +523,7 @@ final class Localization
/** /**
* Set length type * Set length type
* *
* @param array $length Length type * @param array<string, string> $length Length type
* *
* @return void * @return void
* *
@ -537,7 +537,7 @@ final class Localization
/** /**
* Get area type * Get area type
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -549,7 +549,7 @@ final class Localization
/** /**
* Set area type * Set area type
* *
* @param array $area Area type * @param array<string, string> $area Area type
* *
* @return void * @return void
* *
@ -563,7 +563,7 @@ final class Localization
/** /**
* Get volume type * Get volume type
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -575,7 +575,7 @@ final class Localization
/** /**
* Set volume type * Set volume type
* *
* @param array $volume Volume type * @param array<string, string> $volume Volume type
* *
* @return void * @return void
* *

View File

@ -127,9 +127,9 @@ final class Functions
/** /**
* Applying abs to every array value * Applying abs to every array value
* *
* @param array $values Numeric values * @param array<int|float> $values Numeric values
* *
* @return array * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -240,10 +240,10 @@ final class Functions
/** /**
* Power all values in array. * Power all values in array.
* *
* @param array $values Values to square * @param array<int|float> $values Values to square
* @param float $exp Exponent * @param float $exp Exponent
* *
* @return array * @return array<float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -261,10 +261,10 @@ final class Functions
/** /**
* Power all values in array. * Power all values in array.
* *
* @param array $values Values to square * @param array<int|float> $values Values to square
* @param int $exp Exponent * @param int $exp Exponent
* *
* @return array * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -282,9 +282,9 @@ final class Functions
/** /**
* Sqrt all values in array. * Sqrt all values in array.
* *
* @param array $values Values to sqrt * @param array<int|float> $values Values to sqrt
* *
* @return array * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -40,7 +40,7 @@ final class MonotoneChain
* *
* @param array<int, array<string, int|float>> $points Points (Point Cloud) * @param array<int, array<string, int|float>> $points Points (Point Cloud)
* *
* @return array * @return array<int, array<string, int|float>>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -59,7 +59,7 @@ final class Polygon implements D2ShapeInterface
/** /**
* Point polygon relative position * Point polygon relative position
* *
* @param array $point Point location * @param array<string, int|float> $point Point location
* *
* @return int * @return int
* *
@ -76,8 +76,8 @@ final class Polygon implements D2ShapeInterface
/** /**
* Point polygon relative position * Point polygon relative position
* *
* @param array $point Point location * @param array<string, int|float> $point Point location
* @param array $polygon Polygon definition * @param array<int, array<string, int|float> $polygon Polygon definition
* *
* @return int -1 inside polygon 0 on vertice 1 outside * @return int -1 inside polygon 0 on vertice 1 outside
* *
@ -141,8 +141,8 @@ final class Polygon implements D2ShapeInterface
/** /**
* Is point on vertex? * Is point on vertex?
* *
* @param array $point Point location * @param array<string, int|float> $point Point location
* @param array $polygon Polygon definition * @param array<int, array<string, int|float> $polygon Polygon definition
* *
* @return bool * @return bool
* *
@ -239,7 +239,7 @@ final class Polygon implements D2ShapeInterface
/** /**
* Get barycenter * Get barycenter
* *
* @return array * @return array<string, int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -176,8 +176,8 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Get sub matrix array. * Get sub matrix array.
* *
* @param array $rows Row indices * @param array<int> $rows Row indices
* @param array $cols Row indices * @param array<int> $cols Row indices
* *
* @return Matrix * @return Matrix
* *
@ -204,9 +204,9 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Get sub matrix array. * Get sub matrix array.
* *
* @param int $iRow Start row * @param int $iRow Start row
* @param int $lRow End row * @param int $lRow End row
* @param array $cols Row indices * @param array<int> $cols Row indices
* *
* @return Matrix * @return Matrix
* *
@ -232,9 +232,9 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Get sub matrix array. * Get sub matrix array.
* *
* @param array $rows Row indices * @param array<int> $rows Row indices
* @param int $iCol Start col * @param int $iCol Start col
* @param int $lCol End col * @param int $lCol End col
* *
* @return Matrix * @return Matrix
* *
@ -304,7 +304,7 @@ class Matrix implements \ArrayAccess, \Iterator
if ($this->m > $this->n) { if ($this->m > $this->n) {
$mDim = $this->n; $mDim = $this->n;
$nDim = $this->m; $nDim = $this->m;
$matrix = array_map(null, ...$matrix); $matrix = \array_map(null, ...$matrix);
} }
$rank = $mDim; $rank = $mDim;
@ -349,10 +349,10 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Swap values in rows * Swap values in rows
* *
* @param array $matrix Matrix reference to modify * @param array<array> $matrix Matrix reference to modify
* @param int $row1 Row to swap * @param int $row1 Row to swap
* @param int $row2 Row to swap * @param int $row2 Row to swap
* @param int $col Max col to swap to * @param int $col Max col to swap to
* *
* @return void * @return void
* *
@ -370,7 +370,7 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Set matrix array. * Set matrix array.
* *
* @param array $matrix Matrix * @param array<int, array<int|float>> $matrix Matrix
* *
* @return Matrix * @return Matrix
* *
@ -625,7 +625,7 @@ class Matrix implements \ArrayAccess, \Iterator
/** /**
* Trianglize matrix. * Trianglize matrix.
* *
* @param array $arr Matrix to trianglize * @param array<int, array<int|float>> $arr Matrix to trianglize
* *
* @return int Det sign * @return int Det sign
* *

View File

@ -54,7 +54,7 @@ final class Integer
* *
* @param int $value Integer to factorize * @param int $value Integer to factorize
* *
* @return array * @return array<int>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -147,7 +147,7 @@ final class Integer
* @param int $value Integer to factorize * @param int $value Integer to factorize
* @param int $limit Max amount of iterations * @param int $limit Max amount of iterations
* *
* @return array * @return array<int>
* *
* @throws \Exception * @throws \Exception
* *

View File

@ -89,7 +89,7 @@ class Evaluator
* *
* @param string $equation Equation to convert * @param string $equation Equation to convert
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -40,9 +40,9 @@ final class Basic
* *
* Example: ([4, 5, 9, 1, 3]) * Example: ([4, 5, 9, 1, 3])
* *
* @param array $values Values * @param array<int|float|array> $values Values
* *
* @return array * @return array<int|float|array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -51,8 +51,8 @@ final class Basic
$freaquency = []; $freaquency = [];
$sum = 1; $sum = 1;
if (!($isArray = is_array(\reset($values)))) { if (!($isArray = \is_array(\reset($values)))) {
$sum = array_sum($values); $sum = \array_sum($values);
} }
foreach ($values as $value) { foreach ($values as $value) {

View File

@ -40,8 +40,8 @@ final class Correlation
* *
* Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3])
* *
* @param array $x Values * @param array<int|float> $x Values
* @param array $y Values * @param array<int|float> $y Values
* *
* @return float * @return float
* *
@ -55,8 +55,8 @@ final class Correlation
/** /**
* Get the autocorrelation coefficient (ACF). * Get the autocorrelation coefficient (ACF).
* *
* @param array $x Dataset * @param array<int|float> $x Dataset
* @param int $k k-th coefficient * @param int $k k-th coefficient
* *
* @return float * @return float
* *
@ -79,9 +79,9 @@ final class Correlation
/** /**
* Box Pierce test (portmanteau test). * Box Pierce test (portmanteau test).
* *
* @param array $autocorrelations Autocorrelations * @param array<float> $autocorrelations Autocorrelations
* @param int $h Maximum leg considered * @param int $h Maximum leg considered
* @param int $n Amount of observations * @param int $n Amount of observations
* *
* @return float * @return float
* *
@ -100,9 +100,9 @@ final class Correlation
/** /**
* Ljung Box test (portmanteau test). * Ljung Box test (portmanteau test).
* *
* @param array $autocorrelations Autocorrelations * @param array<float> $autocorrelations Autocorrelations
* @param int $h Maximum leg considered * @param int $h Maximum leg considered
* @param int $n Amount of observations * @param int $n Amount of observations
* *
* @return float * @return float
* *

View File

@ -31,7 +31,7 @@ class Forecasts
* @param float $standardDeviation Standard Deviation of forecast * @param float $standardDeviation Standard Deviation of forecast
* @param float $interval Forecast multiplier for prediction intervals * @param float $interval Forecast multiplier for prediction intervals
* *
* @return array * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -33,8 +33,8 @@ abstract class RegressionAbstract
* *
* @latex y = b_{0} + b_{1} \cdot x * @latex y = b_{0} + b_{1} \cdot x
* *
* @param array $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array $y Observed y values * @param array<int|float> $y Observed y values
* *
* @return array [b0 => ?, b1 => ?] * @return array [b0 => ?, b1 => ?]
* *
@ -60,7 +60,7 @@ abstract class RegressionAbstract
* *
* @latex s_{e} = \sqrt{\frac{1}{N - 2}\sum_{i = 1}^{N} e_{i}^{2}} * @latex s_{e} = \sqrt{\frac{1}{N - 2}\sum_{i = 1}^{N} e_{i}^{2}}
* *
* @param array $errors Errors (e = y - y_forecasted) * @param array<int|float> $errors Errors (e = y - y_forecasted)
* *
* @return float * @return float
* *
@ -82,12 +82,12 @@ abstract class RegressionAbstract
/** /**
* Get predictional interval for linear regression. * Get predictional interval for linear regression.
* *
* @param float $forecasted Forecasted y value * @param float $forecasted Forecasted y value
* @param array $x observex x values * @param array<int|float> $x observex x values
* @param array $errors Errors for y values (y - y_forecasted) * @param array<int|float> $errors Errors for y values (y - y_forecasted)
* @param float $multiplier Multiplier for interval * @param float $multiplier Multiplier for interval
* *
* @return array * @return array<int|float>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -111,8 +111,8 @@ abstract class RegressionAbstract
* *
* @latex \beta_{1} = \frac{\sum_{i=1}^{N} \left(y_{i} - \bar{y}\right)\left(x_{i} - \bar{x}\right)}{\sum_{i=1}^{N} \left(x_{i} - \bar{x}\right)^{2}} * @latex \beta_{1} = \frac{\sum_{i=1}^{N} \left(y_{i} - \bar{y}\right)\left(x_{i} - \bar{x}\right)}{\sum_{i=1}^{N} \left(x_{i} - \bar{x}\right)^{2}}
* *
* @param array $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array $y Observed y values * @param array<int|float> $y Observed y values
* *
* @return float * @return float
* *
@ -140,9 +140,9 @@ abstract class RegressionAbstract
* *
* @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x} * @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x}
* *
* @param array $x Obersved x values * @param array<int|float> $x Obersved x values
* @param array $y Observed y values * @param array<int|float> $y Observed y values
* @param float $b1 Beta 1 * @param float $b1 Beta 1
* *
* @return float * @return float
* *

View File

@ -119,8 +119,8 @@ final class InfoManager
*/ */
public function set(string $path, $data, string $delim = '/') : void public function set(string $path, $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.');
} }
ArrayUtils::setArray($path, $this->info, $data, $delim, true); ArrayUtils::setArray($path, $this->info, $data, $delim, true);
@ -129,7 +129,7 @@ final class InfoManager
/** /**
* Get info data. * Get info data.
* *
* @return array * @return array<string, array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -165,7 +165,7 @@ final class InfoManager
/** /**
* Get info data. * Get info data.
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -177,7 +177,7 @@ final class InfoManager
/** /**
* Get info data. * Get info data.
* *
* @return array * @return array<string, string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -225,7 +225,7 @@ final class InfoManager
/** /**
* Get info data. * Get info data.
* *
* @return array * @return array<array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -111,7 +111,7 @@ abstract class ModuleAbstract
* @param string $language Language key * @param string $language Language key
* @param string $destination Application destination (e.g. Backend) * @param string $destination Application destination (e.g. Backend)
* *
* @return array * @return array<string, array<string, string>>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -112,7 +112,7 @@ final class ModuleManager
* *
* @param RequestAbstract $request Request * @param RequestAbstract $request Request
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -135,7 +135,7 @@ final class ModuleManager
* *
* @param RequestAbstract $request Request * @param RequestAbstract $request Request
* *
* @return array * @return array<string, array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -164,7 +164,7 @@ final class ModuleManager
* *
* @param bool $useCache Use Cache or load new * @param bool $useCache Use Cache or load new
* *
* @return array * @return array<string, array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -215,7 +215,7 @@ final class ModuleManager
/** /**
* Get all modules in the module directory. * Get all modules in the module directory.
* *
* @return array * @return array<string, array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -260,7 +260,7 @@ final class ModuleManager
* *
* @param bool $useCache Use Cache * @param bool $useCache Use Cache
* *
* @return array * @return array<string, array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -530,7 +530,7 @@ final class ModuleManager
/** /**
* Install module dependencies. * Install module dependencies.
* *
* @param array $dependencies Module dependencies * @param array<string, string> $dependencies Module dependencies
* *
* @return void * @return void
* *
@ -680,7 +680,7 @@ final class ModuleManager
* *
* @param Request $request Request * @param Request $request Request
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -96,7 +96,7 @@ final class PhpCode
/** /**
* Check if function is disabled * Check if function is disabled
* *
* @param array $functions Functions to check * @param array<string> $functions Functions to check
* *
* @return bool * @return bool
* *

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace phpOMS\Stdlib\Graph; namespace phpOMS\Stdlib\Graph;
/** /**
* Tree class. * Edge class.
* *
* @package phpOMS\Stdlib\Graph * @package phpOMS\Stdlib\Graph
* @license OMS License 1.0 * @license OMS License 1.0
@ -24,26 +24,119 @@ namespace phpOMS\Stdlib\Graph;
*/ */
class Edge class Edge
{ {
/**
* Node1.
*
* In case of directed edges this is the from node/starting node.
*
* @var Node
* @since 1.0.0
*/
private $node1 = null; private $node1 = null;
/**
* Node2.
*
* In case of directed edges this is the to node/end node.
*
* @var Node
* @since 1.0.0
*/
private $node2 = null; private $node2 = null;
private $directed = false; /**
* Is graph/edge directed
*
* @var Node
* @since 1.0.0
*/
private $isDirected = false;
public function __construct(Node $node1, Node $node2, bool $directed = false) /**
* Edge weight
*
* @var float
* @since 1.0.0
*/
private $weight = 0.0;
/**
* Constructor.
*
* @param Node $node1 Graph node (start node in case of directed edge)
* @param Node $node2 Graph node (end node in case of directed edge)
* @param bool $isDirected Is directed edge
*
* @return Graph
*
* @since 1.0.0
*/
public function __construct(Node $node1, Node $node2, float $weight = 0.0, bool $isDirected = false)
{ {
$this->node1 = $node1; $this->node1 = $node1;
$this->node2 = $node2; $this->node2 = $node2;
$this->directed = $directed; $this->weight = $weight;
$this->isDirected = $isDirected;
} }
/**
* Get nodes of the edge.
*
* @return Node[]
*
* @since 1.0.0
*/
public function getNodes() : array public function getNodes() : array
{ {
return [$this->node1, $this->node2]; return [$this->node1, $this->node2];
} }
/**
* Get node of the edge.
*
* @return Node
*
* @since 1.0.0
*/
public function getNode1() : Node
{
return $this->node1;
}
/**
* Get node of the edge.
*
* @return Node
*
* @since 1.0.0
*/
public function getNode2() : Node
{
return $this->node2;
}
/**
* Get weight
*
* @return float
*
* @since 1.0.0
*/
public function getWeight() : float
{
return $this->weight;
}
/**
* Is directed edge
*
* @return bool
*
* @since 1.0.0
*/
public function isDirected() : bool public function isDirected() : bool
{ {
return $this->directed; return $this->isDirected;
} }
} }

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace phpOMS\Stdlib\Graph; namespace phpOMS\Stdlib\Graph;
/** /**
* Tree class. * Node class.
* *
* @package phpOMS\Stdlib\Graph * @package phpOMS\Stdlib\Graph
* @license OMS License 1.0 * @license OMS License 1.0
@ -26,4 +26,47 @@ namespace phpOMS\Stdlib\Graph;
*/ */
class Node class Node
{ {
/**
* Node data.
*
* @var mixed
* @since 1.0.0
*/
private $data = null;
/**
* Constructor.
*
* @param mixed $data Node data
*
* @since 1.0.0
*/
public function __construct($data = null)
{
$this->data = $data;
}
/**
* Get data.
*
* @return mixed
*
* @since 1.0.0
*/
public function getData()
{
return $this->data;
}
/**
* Set data.
*
* @param mixed $data Node data
*
* @since 1.0.0
*/
public function setData($data) : void
{
$this->data = $data;
}
} }

View File

@ -76,9 +76,9 @@ class MultiMap implements \Countable
/** /**
* Add data. * Add data.
* *
* @param array $keys Keys for value * @param array<string|int|float> $keys Keys for value
* @param mixed $value Value to store * @param mixed $value Value to store
* @param bool $overwrite Add value if key exists * @param bool $overwrite Add value if key exists
* *
* @return bool * @return bool
* *

View File

@ -215,7 +215,7 @@ class PriorityQueue implements \Countable, \Serializable
*/ */
public function pop() : array public function pop() : array
{ {
return \array_pop($this->queue); return \array_pop($this->queue) ?? [];
} }
/** /**
@ -283,7 +283,7 @@ class PriorityQueue implements \Countable, \Serializable
/** /**
* Get element * Get element
* *
* @return array * @return array<array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -201,9 +201,9 @@ interface ContainerInterface
/** /**
* Count subresources. * Count subresources.
* *
* @param string $path Path of the resource * @param string $path Path of the resource
* @param bool $recursive Consider subdirectories * @param bool $recursive Consider subdirectories
* @param array $ignore Files/paths to ignore (no regex) * @param array<string> $ignore Files/paths to ignore (no regex)
* *
* @return int * @return int
* *

View File

@ -31,9 +31,9 @@ interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess
* *
* A file will always return 1 as it doesn't have any sub-resources. * A file will always return 1 as it doesn't have any sub-resources.
* *
* @param string $path Path of the resource * @param string $path Path of the resource
* @param bool $recursive Should count also sub-sub-resources * @param bool $recursive Should count also sub-sub-resources
* @param array $ignore Ignore files * @param array<string> $ignore Ignore files
* *
* @return int * @return int
* *

View File

@ -71,7 +71,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
* @param string $path Path * @param string $path Path
* @param string $filter Filter * @param string $filter Filter
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -105,7 +105,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
* @param string $extension Extension * @param string $extension Extension
* @param string $exclude Pattern to exclude * @param string $exclude Pattern to exclude
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -272,9 +272,9 @@ abstract class StorageAbstract
/** /**
* Count subresources. * Count subresources.
* *
* @param string $path Path of the resource * @param string $path Path of the resource
* @param bool $recursive Consider subdirectories * @param bool $recursive Consider subdirectories
* @param array $ignore Files/paths to ignore (no regex) * @param array<string> $ignore Files/paths to ignore (no regex)
* *
* @return int * @return int
* *

View File

@ -223,8 +223,8 @@ final class UriFactory
* @ = * @ =
* $ = Other data * $ = Other data
* *
* @param string $uri Path data * @param string $uri Path data
* @param array $toMatch Optional special replacements * @param array<string, string|float|int|bool> $toMatch Optional special replacements
* *
* @return string * @return string
* *

View File

@ -297,8 +297,8 @@ final class ArrayUtils
* *
* Useful for parsing command line parsing * Useful for parsing command line parsing
* *
* @param string $id Id to find * @param string $id Id to find
* @param array $args CLI command list * @param array<string> $args CLI command list
* *
* @return string * @return string
* *
@ -316,8 +316,8 @@ final class ArrayUtils
/** /**
* Check if flag is set * Check if flag is set
* *
* @param string $id Id to find * @param string $id Id to find
* @param array $args CLI command list * @param array<string> $args CLI command list
* *
* @return int * @return int
* *
@ -347,13 +347,13 @@ final class ArrayUtils
{ {
// see collection collapse as alternative?! // see collection collapse as alternative?!
$flat = []; $flat = [];
$stack = array_values($array); $stack = \array_values($array);
while (!empty($stack)) { while (!empty($stack)) {
$value = array_shift($stack); $value = \array_shift($stack);
if (\is_array($value)) { if (\is_array($value)) {
$stack = array_merge(array_values($value), $stack); $stack = \array_merge(\array_values($value), $stack);
} else { } else {
$flat[] = $value; $flat[] = $value;
} }
@ -377,7 +377,7 @@ final class ArrayUtils
{ {
$count = $count === 0 ? \count($array) : $start + $count; $count = $count === 0 ? \count($array) : $start + $count;
$sum = 0; $sum = 0;
$array = array_values($array); $array = \array_values($array);
for ($i = $start; $i <= $count - 1; ++$i) { for ($i = $start; $i <= $count - 1; ++$i) {
$sum += $array[$i]; $sum += $array[$i];
@ -397,6 +397,6 @@ final class ArrayUtils
*/ */
public static function arraySumRecursive(array $array) public static function arraySumRecursive(array $array)
{ {
return array_sum(self::arrayFlatten($array)); return \array_sum(self::arrayFlatten($array));
} }
} }

View File

@ -58,7 +58,7 @@ final class ColorUtils
/** /**
* Convert rgb to int * Convert rgb to int
* *
* @param array $rgb Int rgb array * @param array<string, int> $rgb Int rgb array
* *
* @return int * @return int
* *

View File

@ -88,7 +88,7 @@ class Currency
/** /**
* Get ECB currency rates. * Get ECB currency rates.
* *
* @return array * @return array<string, float>
* *
* @throws \Exception * @throws \Exception
* *
@ -111,7 +111,7 @@ class Currency
self::$ecbCurrencies = []; self::$ecbCurrencies = [];
foreach ($node as $key => $value) { foreach ($node as $key => $value) {
self::$ecbCurrencies[strtoupper((string) $value->attributes()['currency'])] = (float) $value->attributes()['rate']; self::$ecbCurrencies[\strtoupper((string) $value->attributes()['currency'])] = (float) $value->attributes()['rate'];
} }
} }

View File

@ -79,14 +79,14 @@ final class Dictionary
$count = []; $count = [];
while (isset($source[0])) { while (isset($source[0])) {
$count[] = [substr_count($source, $source[0]), $source[0]]; $count[] = [\substr_count($source, $source[0]), $source[0]];
$source = \str_replace($source[0], '', $source); $source = \str_replace($source[0], '', $source);
} }
\sort($count); \sort($count);
while (\count($count) > 1) { while (\count($count) > 1) {
$row1 = array_shift($count); $row1 = \array_shift($count);
$row2 = array_shift($count); $row2 = \array_shift($count);
$count[] = [$row1[0] + $row2[0], [$row1, $row2]]; $count[] = [$row1[0] + $row2[0], [$row1, $row2]];
\sort($count); \sort($count);
@ -107,14 +107,14 @@ final class Dictionary
*/ */
private function fill(array $entry, string $value = '') : void private function fill(array $entry, string $value = '') : void
{ {
if (!is_array($entry[0][1])) { if (!\is_array($entry[0][1])) {
$this->set($entry[0][1], $value . '0'); $this->set($entry[0][1], $value . '0');
} else { } else {
$this->fill($entry[0][1], $value . '0'); $this->fill($entry[0][1], $value . '0');
} }
if (isset($entry[1])) { if (isset($entry[1])) {
if (!is_array($entry[1][1])) { if (!\is_array($entry[1][1])) {
$this->set($entry[1][1], $value . '1'); $this->set($entry[1][1], $value . '1');
} else { } else {
$this->fill($entry[1][1], $value . '1'); $this->fill($entry[1][1], $value . '1');

View File

@ -135,7 +135,7 @@ class Repository
/** /**
* Get all branches. * Get all branches.
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -160,7 +160,7 @@ class Repository
* *
* @param string $cmd Command to run * @param string $cmd Command to run
* *
* @return array * @return array<string>
* *
* @throws \Exception * @throws \Exception
* *
@ -212,7 +212,7 @@ class Repository
* *
* @param string $lines Result of git command * @param string $lines Result of git command
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -464,7 +464,7 @@ class Repository
/** /**
* Get all remote branches. * Get all remote branches.
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -642,7 +642,7 @@ class Repository
/** /**
* Get LOC. * Get LOC.
* *
* @param array $extensions Extensions whitelist * @param array<string> $extensions Extensions whitelist
* *
* @return int * @return int
* *
@ -687,7 +687,7 @@ class Repository
* @param \DateTime $start Start date * @param \DateTime $start Start date
* @param \DateTime $end End date * @param \DateTime $end End date
* *
* @return array * @return array<string>
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -727,7 +727,7 @@ class Repository
* @param \DateTime $start Start date * @param \DateTime $start Start date
* @param \DateTime $end End date * @param \DateTime $end End date
* *
* @return array * @return array<string, int>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -41,7 +41,7 @@ final class Permutation
* @param array $toPermute data to permutate * @param array $toPermute data to permutate
* @param array $result existing permutations * @param array $result existing permutations
* *
* @return array * @return array<string|array>
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -48,7 +48,7 @@ class File
/** /**
* Get a random file extension. * Get a random file extension.
* *
* @param array $source Source array for possible extensions * @param array<array<string>> $source Source array for possible extensions
* @param DistributionType|int $distribution Distribution type for the extensions * @param DistributionType|int $distribution Distribution type for the extensions
* *
* @return false|array * @return false|array

View File

@ -42,12 +42,12 @@ final class StringUtils
} }
/** /**
* Check if a string contains any of the provided needles. * Check if a string contains any of the provided needles (case sensitive).
* *
* The validation is done case sensitive. * The validation is done case sensitive.
* *
* @param string $haystack Haystack * @param string $haystack Haystack
* @param array $needles Needles to check if any of them are part of the haystack * @param array<string, float, int> $needles Needles to check if any of them are part of the haystack
* *
* @example StringUtils::contains('This string', ['This', 'test']); // true * @example StringUtils::contains('This string', ['This', 'test']); // true
* *
@ -67,12 +67,12 @@ final class StringUtils
} }
/** /**
* Check if a string contains any of the provided needles. * Check if a string contains any of the provided needles (case sensitive).
* *
* The validation is done case sensitive. * The validation is done case sensitive.
* *
* @param string $haystack Haystack * @param string $haystack Haystack
* @param array $needles Needles to check if any of them are part of the haystack * @param array<string, float, int> $needles Needles to check if any of them are part of the haystack
* *
* @example StringUtils::mb_contains('This string', ['This', 'test']); // true * @example StringUtils::mb_contains('This string', ['This', 'test']); // true
* *
@ -92,7 +92,7 @@ final class StringUtils
} }
/** /**
* Tests if a string ends with a certain string. * Tests if a string ends with a certain string (case sensitive).
* *
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the end of the haystack string. * In case of an array the function will test if any of the needles is at the end of the haystack string.
@ -122,7 +122,7 @@ final class StringUtils
} }
/** /**
* Tests if a string starts with a certain string. * Tests if a string starts with a certain string (case sensitive).
* *
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the beginning of the haystack string. * In case of an array the function will test if any of the needles is at the beginning of the haystack string.
@ -154,7 +154,7 @@ final class StringUtils
} }
/** /**
* Tests if a multi byte string starts with a certain string. * Tests if a multi byte string starts with a certain string (case sensitive).
* *
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the beginning of the haystack string. * In case of an array the function will test if any of the needles is at the beginning of the haystack string.
@ -182,7 +182,7 @@ final class StringUtils
} }
/** /**
* Tests if a multi byte string ends with a certain string. * Tests if a multi byte string ends with a certain string (case sensitive).
* *
* The validation is done case sensitive. The function takes strings or an array of strings for the validation. * The validation is done case sensitive. The function takes strings or an array of strings for the validation.
* In case of an array the function will test if any of the needles is at the end of the haystack string. * In case of an array the function will test if any of the needles is at the end of the haystack string.

View File

@ -14,11 +14,20 @@
namespace phpOMS\tests\Stdlib\Graph; namespace phpOMS\tests\Stdlib\Graph;
use phpOMS\Stdlib\Graph\Edge; use phpOMS\Stdlib\Graph\Edge;
use phpOMS\Stdlib\Graph\Node;
class EdgeTest extends \PHPUnit\Framework\TestCase class EdgeTest extends \PHPUnit\Framework\TestCase
{ {
public function testPlaceholder() public function testDefault()
{ {
self::markTestIncomplete(); $edge = new Edge(new Node(), new Node());
self::assertEquals([new Node(), new Node()], $edge->getNodes());
self::assertEquals(new Node(), $edge->getNode1());
self::assertEquals(new Node(), $edge->getNode2());
self::assertEquals(0.0, $edge->getWeight());
self::assertFalse($edge->isDirected());
$edge = new Edge(new Node(), new Node(), 0.0, true);
self::assertTrue($edge->isDirected());
} }
} }

View File

@ -17,8 +17,18 @@ use phpOMS\Stdlib\Graph\Node;
class NodeTest extends \PHPUnit\Framework\TestCase class NodeTest extends \PHPUnit\Framework\TestCase
{ {
public function testPlaceholder() public function testDefault()
{ {
self::markTestIncomplete(); $node = new Node();
self::assertEquals(null, $node->getData());
}
public function testGetSet()
{
$node = new Node(1);
self::assertEquals(1, $node->getData());
$node->setData(false);
self::assertEquals(false, $node->getData());
} }
} }

View File

@ -22,6 +22,9 @@ class PriorityQueueTest extends \PHPUnit\Framework\TestCase
{ {
$queue = new PriorityQueue(); $queue = new PriorityQueue();
self::assertEquals(0, $queue->count()); self::assertEquals(0, $queue->count());
self::assertEquals([], $queue->get(1));
self::assertEquals([], $queue->pop());
self::assertEquals([], $queue->getAll());
self::assertEquals(PriorityMode::FIFO, $queue->getType()); self::assertEquals(PriorityMode::FIFO, $queue->getType());
} }