diff --git a/Business/Finance/FinanceFormulas.php b/Business/Finance/FinanceFormulas.php index a09480a18..ee59a366c 100644 --- a/Business/Finance/FinanceFormulas.php +++ b/Business/Finance/FinanceFormulas.php @@ -928,7 +928,7 @@ final class FinanceFormulas /** * Future Value Factor * - * @param array $r Rate of return + * @param array $r Rate of return * * @return float * @@ -1056,8 +1056,8 @@ final class FinanceFormulas /** * Net Present Value * - * @param array $C Cash flow ($C[0] = initial investment) - * @param float $r Discount rate + * @param array $C Cash flow ($C[0] = initial investment) + * @param float $r Discount rate * * @return float * diff --git a/Business/Finance/Lorenzkurve.php b/Business/Finance/Lorenzkurve.php index 9e09e52db..bd478634f 100644 --- a/Business/Finance/Lorenzkurve.php +++ b/Business/Finance/Lorenzkurve.php @@ -27,7 +27,7 @@ final class Lorenzkurve /** * Calculate Gini coefficient * - * @param array $data Datapoints (can be unsorted) + * @param array $data Datapoints (can be unsorted) * * @return float * diff --git a/Business/Finance/StockBonds.php b/Business/Finance/StockBonds.php index fad0a5b1c..b5f90bb59 100644 --- a/Business/Finance/StockBonds.php +++ b/Business/Finance/StockBonds.php @@ -198,7 +198,7 @@ final class StockBonds /** * Holding Period Return * - * @param array $r Rate of return + * @param array $r Rate of return * * @return float * diff --git a/Localization/Localization.php b/Localization/Localization.php index ca8224341..c89b7a4e8 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -179,7 +179,7 @@ final class Localization /** * Load localization from locale * - * @param array $locale Locale data + * @param array $locale Locale data * * @return void * @@ -193,7 +193,7 @@ final class Localization $this->setThousands($locale['thousand'] ?? ','); $this->setDecimal($locale['decimal'] ?? '.'); $this->setAngle($locale['angle'] ?? AngleType::DEGREE); - $this->setTemperature($locale['temperature'] ?? emperatureType::CELSIUS); + $this->setTemperature($locale['temperature'] ?? TemperatureType::CELSIUS); $this->setWeight($locale['weight'] ?? []); $this->setSpeed($locale['speed'] ?? []); $this->setLength($locale['length'] ?? []); @@ -459,7 +459,7 @@ final class Localization /** * Get speed type * - * @return array + * @return array * * @since 1.0.0 */ @@ -471,7 +471,7 @@ final class Localization /** * Set speed type * - * @param array $speed Speed + * @param array $speed Speed * * @return void * @@ -485,7 +485,7 @@ final class Localization /** * Get weight type * - * @return array + * @return array * * @since 1.0.0 */ @@ -497,7 +497,7 @@ final class Localization /** * Set weight type * - * @param array $weight Weight type + * @param array $weight Weight type * * @return void * @@ -511,7 +511,7 @@ final class Localization /** * Get length type * - * @return array + * @return array * * @since 1.0.0 */ @@ -523,7 +523,7 @@ final class Localization /** * Set length type * - * @param array $length Length type + * @param array $length Length type * * @return void * @@ -537,7 +537,7 @@ final class Localization /** * Get area type * - * @return array + * @return array * * @since 1.0.0 */ @@ -549,7 +549,7 @@ final class Localization /** * Set area type * - * @param array $area Area type + * @param array $area Area type * * @return void * @@ -563,7 +563,7 @@ final class Localization /** * Get volume type * - * @return array + * @return array * * @since 1.0.0 */ @@ -575,7 +575,7 @@ final class Localization /** * Set volume type * - * @param array $volume Volume type + * @param array $volume Volume type * * @return void * diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index b8564895b..a00f0e6d4 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -127,9 +127,9 @@ final class Functions /** * Applying abs to every array value * - * @param array $values Numeric values + * @param array $values Numeric values * - * @return array + * @return array * * @since 1.0.0 */ @@ -240,10 +240,10 @@ final class Functions /** * Power all values in array. * - * @param array $values Values to square - * @param float $exp Exponent + * @param array $values Values to square + * @param float $exp Exponent * - * @return array + * @return array * * @since 1.0.0 */ @@ -261,10 +261,10 @@ final class Functions /** * Power all values in array. * - * @param array $values Values to square - * @param int $exp Exponent + * @param array $values Values to square + * @param int $exp Exponent * - * @return array + * @return array * * @since 1.0.0 */ @@ -282,9 +282,9 @@ final class Functions /** * Sqrt all values in array. * - * @param array $values Values to sqrt + * @param array $values Values to sqrt * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Math/Geometry/ConvexHull/MonotoneChain.php b/Math/Geometry/ConvexHull/MonotoneChain.php index 5afa8fcf3..e61c57f3d 100644 --- a/Math/Geometry/ConvexHull/MonotoneChain.php +++ b/Math/Geometry/ConvexHull/MonotoneChain.php @@ -40,7 +40,7 @@ final class MonotoneChain * * @param array> $points Points (Point Cloud) * - * @return array + * @return array> * * @since 1.0.0 */ diff --git a/Math/Geometry/Shape/D2/Polygon.php b/Math/Geometry/Shape/D2/Polygon.php index 20a0505f1..a97dfd66d 100644 --- a/Math/Geometry/Shape/D2/Polygon.php +++ b/Math/Geometry/Shape/D2/Polygon.php @@ -59,7 +59,7 @@ final class Polygon implements D2ShapeInterface /** * Point polygon relative position * - * @param array $point Point location + * @param array $point Point location * * @return int * @@ -76,8 +76,8 @@ final class Polygon implements D2ShapeInterface /** * Point polygon relative position * - * @param array $point Point location - * @param array $polygon Polygon definition + * @param array $point Point location + * @param array $polygon Polygon definition * * @return int -1 inside polygon 0 on vertice 1 outside * @@ -141,8 +141,8 @@ final class Polygon implements D2ShapeInterface /** * Is point on vertex? * - * @param array $point Point location - * @param array $polygon Polygon definition + * @param array $point Point location + * @param array $polygon Polygon definition * * @return bool * @@ -239,7 +239,7 @@ final class Polygon implements D2ShapeInterface /** * Get barycenter * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 47bd64ce4..54d0c8be6 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -176,8 +176,8 @@ class Matrix implements \ArrayAccess, \Iterator /** * Get sub matrix array. * - * @param array $rows Row indices - * @param array $cols Row indices + * @param array $rows Row indices + * @param array $cols Row indices * * @return Matrix * @@ -204,9 +204,9 @@ class Matrix implements \ArrayAccess, \Iterator /** * Get sub matrix array. * - * @param int $iRow Start row - * @param int $lRow End row - * @param array $cols Row indices + * @param int $iRow Start row + * @param int $lRow End row + * @param array $cols Row indices * * @return Matrix * @@ -232,9 +232,9 @@ class Matrix implements \ArrayAccess, \Iterator /** * Get sub matrix array. * - * @param array $rows Row indices - * @param int $iCol Start col - * @param int $lCol End col + * @param array $rows Row indices + * @param int $iCol Start col + * @param int $lCol End col * * @return Matrix * @@ -304,7 +304,7 @@ class Matrix implements \ArrayAccess, \Iterator if ($this->m > $this->n) { $mDim = $this->n; $nDim = $this->m; - $matrix = array_map(null, ...$matrix); + $matrix = \array_map(null, ...$matrix); } $rank = $mDim; @@ -349,10 +349,10 @@ class Matrix implements \ArrayAccess, \Iterator /** * Swap values in rows * - * @param array $matrix Matrix reference to modify - * @param int $row1 Row to swap - * @param int $row2 Row to swap - * @param int $col Max col to swap to + * @param array $matrix Matrix reference to modify + * @param int $row1 Row to swap + * @param int $row2 Row to swap + * @param int $col Max col to swap to * * @return void * @@ -370,7 +370,7 @@ class Matrix implements \ArrayAccess, \Iterator /** * Set matrix array. * - * @param array $matrix Matrix + * @param array> $matrix Matrix * * @return Matrix * @@ -625,7 +625,7 @@ class Matrix implements \ArrayAccess, \Iterator /** * Trianglize matrix. * - * @param array $arr Matrix to trianglize + * @param array> $arr Matrix to trianglize * * @return int Det sign * diff --git a/Math/Number/Integer.php b/Math/Number/Integer.php index 63a16219f..973da99a3 100644 --- a/Math/Number/Integer.php +++ b/Math/Number/Integer.php @@ -54,7 +54,7 @@ final class Integer * * @param int $value Integer to factorize * - * @return array + * @return array * * @since 1.0.0 */ @@ -147,7 +147,7 @@ final class Integer * @param int $value Integer to factorize * @param int $limit Max amount of iterations * - * @return array + * @return array * * @throws \Exception * diff --git a/Math/Parser/Evaluator.php b/Math/Parser/Evaluator.php index 6ad9d0ec9..d9746f834 100644 --- a/Math/Parser/Evaluator.php +++ b/Math/Parser/Evaluator.php @@ -89,7 +89,7 @@ class Evaluator * * @param string $equation Equation to convert * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Math/Statistic/Basic.php b/Math/Statistic/Basic.php index 8bd00139f..bac3ce243 100644 --- a/Math/Statistic/Basic.php +++ b/Math/Statistic/Basic.php @@ -40,9 +40,9 @@ final class Basic * * Example: ([4, 5, 9, 1, 3]) * - * @param array $values Values + * @param array $values Values * - * @return array + * @return array * * @since 1.0.0 */ @@ -51,8 +51,8 @@ final class Basic $freaquency = []; $sum = 1; - if (!($isArray = is_array(\reset($values)))) { - $sum = array_sum($values); + if (!($isArray = \is_array(\reset($values)))) { + $sum = \array_sum($values); } foreach ($values as $value) { diff --git a/Math/Statistic/Correlation.php b/Math/Statistic/Correlation.php index cdab96310..2a68a5cff 100644 --- a/Math/Statistic/Correlation.php +++ b/Math/Statistic/Correlation.php @@ -40,8 +40,8 @@ final class Correlation * * Example: ([4, 5, 9, 1, 3], [4, 5, 9, 1, 3]) * - * @param array $x Values - * @param array $y Values + * @param array $x Values + * @param array $y Values * * @return float * @@ -55,8 +55,8 @@ final class Correlation /** * Get the autocorrelation coefficient (ACF). * - * @param array $x Dataset - * @param int $k k-th coefficient + * @param array $x Dataset + * @param int $k k-th coefficient * * @return float * @@ -79,9 +79,9 @@ final class Correlation /** * Box Pierce test (portmanteau test). * - * @param array $autocorrelations Autocorrelations - * @param int $h Maximum leg considered - * @param int $n Amount of observations + * @param array $autocorrelations Autocorrelations + * @param int $h Maximum leg considered + * @param int $n Amount of observations * * @return float * @@ -100,9 +100,9 @@ final class Correlation /** * Ljung Box test (portmanteau test). * - * @param array $autocorrelations Autocorrelations - * @param int $h Maximum leg considered - * @param int $n Amount of observations + * @param array $autocorrelations Autocorrelations + * @param int $h Maximum leg considered + * @param int $n Amount of observations * * @return float * diff --git a/Math/Statistic/Forecast/Forecasts.php b/Math/Statistic/Forecast/Forecasts.php index 834935ad0..b6da74006 100644 --- a/Math/Statistic/Forecast/Forecasts.php +++ b/Math/Statistic/Forecast/Forecasts.php @@ -31,7 +31,7 @@ class Forecasts * @param float $standardDeviation Standard Deviation of forecast * @param float $interval Forecast multiplier for prediction intervals * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Math/Statistic/Forecast/Regression/RegressionAbstract.php b/Math/Statistic/Forecast/Regression/RegressionAbstract.php index 163a30ad2..533fa2bf3 100644 --- a/Math/Statistic/Forecast/Regression/RegressionAbstract.php +++ b/Math/Statistic/Forecast/Regression/RegressionAbstract.php @@ -33,8 +33,8 @@ abstract class RegressionAbstract * * @latex y = b_{0} + b_{1} \cdot x * - * @param array $x Obersved x values - * @param array $y Observed y values + * @param array $x Obersved x values + * @param array $y Observed y values * * @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}} * - * @param array $errors Errors (e = y - y_forecasted) + * @param array $errors Errors (e = y - y_forecasted) * * @return float * @@ -82,12 +82,12 @@ abstract class RegressionAbstract /** * Get predictional interval for linear regression. * - * @param float $forecasted Forecasted y value - * @param array $x observex x values - * @param array $errors Errors for y values (y - y_forecasted) - * @param float $multiplier Multiplier for interval + * @param float $forecasted Forecasted y value + * @param array $x observex x values + * @param array $errors Errors for y values (y - y_forecasted) + * @param float $multiplier Multiplier for interval * - * @return array + * @return array * * @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}} * - * @param array $x Obersved x values - * @param array $y Observed y values + * @param array $x Obersved x values + * @param array $y Observed y values * * @return float * @@ -140,9 +140,9 @@ abstract class RegressionAbstract * * @latex \beta_{0} = \bar{x} - b_{1} \cdot \bar{x} * - * @param array $x Obersved x values - * @param array $y Observed y values - * @param float $b1 Beta 1 + * @param array $x Obersved x values + * @param array $y Observed y values + * @param float $b1 Beta 1 * * @return float * diff --git a/Module/InfoManager.php b/Module/InfoManager.php index 197f0c479..04a71d5b9 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -119,8 +119,8 @@ final class InfoManager */ public function set(string $path, $data, string $delim = '/') : void { - if (!is_scalar($data) && !is_array($data) && !($data instanceof \JsonSerializable)) { - throw new \InvalidArgumentException('Type of $data "' . gettype($data) . '" is not supported.'); + if (!\is_scalar($data) && !\is_array($data) && !($data instanceof \JsonSerializable)) { + throw new \InvalidArgumentException('Type of $data "' . \gettype($data) . '" is not supported.'); } ArrayUtils::setArray($path, $this->info, $data, $delim, true); @@ -129,7 +129,7 @@ final class InfoManager /** * Get info data. * - * @return array + * @return array * * @since 1.0.0 */ @@ -165,7 +165,7 @@ final class InfoManager /** * Get info data. * - * @return array + * @return array * * @since 1.0.0 */ @@ -177,7 +177,7 @@ final class InfoManager /** * Get info data. * - * @return array + * @return array * * @since 1.0.0 */ @@ -225,7 +225,7 @@ final class InfoManager /** * Get info data. * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 6811c5817..b3741595f 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -111,7 +111,7 @@ abstract class ModuleAbstract * @param string $language Language key * @param string $destination Application destination (e.g. Backend) * - * @return array + * @return array> * * @since 1.0.0 */ diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index a87e0beee..0f6dfb9d0 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -112,7 +112,7 @@ final class ModuleManager * * @param RequestAbstract $request Request * - * @return array + * @return array * * @since 1.0.0 */ @@ -135,7 +135,7 @@ final class ModuleManager * * @param RequestAbstract $request Request * - * @return array + * @return array * * @since 1.0.0 */ @@ -164,7 +164,7 @@ final class ModuleManager * * @param bool $useCache Use Cache or load new * - * @return array + * @return array * * @since 1.0.0 */ @@ -215,7 +215,7 @@ final class ModuleManager /** * Get all modules in the module directory. * - * @return array + * @return array * * @since 1.0.0 */ @@ -260,7 +260,7 @@ final class ModuleManager * * @param bool $useCache Use Cache * - * @return array + * @return array * * @since 1.0.0 */ @@ -530,7 +530,7 @@ final class ModuleManager /** * Install module dependencies. * - * @param array $dependencies Module dependencies + * @param array $dependencies Module dependencies * * @return void * @@ -680,7 +680,7 @@ final class ModuleManager * * @param Request $request Request * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Security/PhpCode.php b/Security/PhpCode.php index a6ca86393..c02007ab4 100644 --- a/Security/PhpCode.php +++ b/Security/PhpCode.php @@ -96,7 +96,7 @@ final class PhpCode /** * Check if function is disabled * - * @param array $functions Functions to check + * @param array $functions Functions to check * * @return bool * diff --git a/Stdlib/Graph/Edge.php b/Stdlib/Graph/Edge.php index 66e2dcb04..a2f3e2bf1 100644 --- a/Stdlib/Graph/Edge.php +++ b/Stdlib/Graph/Edge.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace phpOMS\Stdlib\Graph; /** - * Tree class. + * Edge class. * * @package phpOMS\Stdlib\Graph * @license OMS License 1.0 @@ -24,26 +24,119 @@ namespace phpOMS\Stdlib\Graph; */ class Edge { + /** + * Node1. + * + * In case of directed edges this is the from node/starting node. + * + * @var Node + * @since 1.0.0 + */ 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 $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->node2 = $node2; - $this->directed = $directed; + $this->node1 = $node1; + $this->node2 = $node2; + $this->weight = $weight; + $this->isDirected = $isDirected; } + /** + * Get nodes of the edge. + * + * @return Node[] + * + * @since 1.0.0 + */ public function getNodes() : array { 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 { - return $this->directed; + return $this->isDirected; } } diff --git a/Stdlib/Graph/Node.php b/Stdlib/Graph/Node.php index 81d47e550..695bb13f2 100644 --- a/Stdlib/Graph/Node.php +++ b/Stdlib/Graph/Node.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace phpOMS\Stdlib\Graph; /** - * Tree class. + * Node class. * * @package phpOMS\Stdlib\Graph * @license OMS License 1.0 @@ -26,4 +26,47 @@ namespace phpOMS\Stdlib\Graph; */ 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; + } } diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index 048547e68..52400c573 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -76,9 +76,9 @@ class MultiMap implements \Countable /** * Add data. * - * @param array $keys Keys for value - * @param mixed $value Value to store - * @param bool $overwrite Add value if key exists + * @param array $keys Keys for value + * @param mixed $value Value to store + * @param bool $overwrite Add value if key exists * * @return bool * diff --git a/Stdlib/Queue/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php index 6ce3a0b9e..1e7e4e2dc 100644 --- a/Stdlib/Queue/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -215,7 +215,7 @@ class PriorityQueue implements \Countable, \Serializable */ 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 * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/System/File/ContainerInterface.php b/System/File/ContainerInterface.php index fc999e9b3..e5887072e 100644 --- a/System/File/ContainerInterface.php +++ b/System/File/ContainerInterface.php @@ -201,9 +201,9 @@ interface ContainerInterface /** * Count subresources. * - * @param string $path Path of the resource - * @param bool $recursive Consider subdirectories - * @param array $ignore Files/paths to ignore (no regex) + * @param string $path Path of the resource + * @param bool $recursive Consider subdirectories + * @param array $ignore Files/paths to ignore (no regex) * * @return int * diff --git a/System/File/DirectoryInterface.php b/System/File/DirectoryInterface.php index 27d374985..55d388f81 100644 --- a/System/File/DirectoryInterface.php +++ b/System/File/DirectoryInterface.php @@ -31,9 +31,9 @@ interface DirectoryInterface extends ContainerInterface, \Iterator, \ArrayAccess * * A file will always return 1 as it doesn't have any sub-resources. * - * @param string $path Path of the resource - * @param bool $recursive Should count also sub-sub-resources - * @param array $ignore Ignore files + * @param string $path Path of the resource + * @param bool $recursive Should count also sub-sub-resources + * @param array $ignore Ignore files * * @return int * diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 19ea1ca55..79d7b434b 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -71,7 +71,7 @@ final class Directory extends FileAbstract implements DirectoryInterface * @param string $path Path * @param string $filter Filter * - * @return array + * @return array * * @since 1.0.0 */ @@ -105,7 +105,7 @@ final class Directory extends FileAbstract implements DirectoryInterface * @param string $extension Extension * @param string $exclude Pattern to exclude * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php index 48b1d8d37..3589a07bc 100644 --- a/System/File/StorageAbstract.php +++ b/System/File/StorageAbstract.php @@ -272,9 +272,9 @@ abstract class StorageAbstract /** * Count subresources. * - * @param string $path Path of the resource - * @param bool $recursive Consider subdirectories - * @param array $ignore Files/paths to ignore (no regex) + * @param string $path Path of the resource + * @param bool $recursive Consider subdirectories + * @param array $ignore Files/paths to ignore (no regex) * * @return int * diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 87ddbd8f4..89e5c9331 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -223,8 +223,8 @@ final class UriFactory * @ = * $ = Other data * - * @param string $uri Path data - * @param array $toMatch Optional special replacements + * @param string $uri Path data + * @param array $toMatch Optional special replacements * * @return string * diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index d4487d8fd..b443c66b8 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -297,8 +297,8 @@ final class ArrayUtils * * Useful for parsing command line parsing * - * @param string $id Id to find - * @param array $args CLI command list + * @param string $id Id to find + * @param array $args CLI command list * * @return string * @@ -316,8 +316,8 @@ final class ArrayUtils /** * Check if flag is set * - * @param string $id Id to find - * @param array $args CLI command list + * @param string $id Id to find + * @param array $args CLI command list * * @return int * @@ -347,13 +347,13 @@ final class ArrayUtils { // see collection collapse as alternative?! $flat = []; - $stack = array_values($array); + $stack = \array_values($array); while (!empty($stack)) { - $value = array_shift($stack); + $value = \array_shift($stack); if (\is_array($value)) { - $stack = array_merge(array_values($value), $stack); + $stack = \array_merge(\array_values($value), $stack); } else { $flat[] = $value; } @@ -377,7 +377,7 @@ final class ArrayUtils { $count = $count === 0 ? \count($array) : $start + $count; $sum = 0; - $array = array_values($array); + $array = \array_values($array); for ($i = $start; $i <= $count - 1; ++$i) { $sum += $array[$i]; @@ -397,6 +397,6 @@ final class ArrayUtils */ public static function arraySumRecursive(array $array) { - return array_sum(self::arrayFlatten($array)); + return \array_sum(self::arrayFlatten($array)); } } diff --git a/Utils/ColorUtils.php b/Utils/ColorUtils.php index 6917b1c83..c17da020a 100644 --- a/Utils/ColorUtils.php +++ b/Utils/ColorUtils.php @@ -58,7 +58,7 @@ final class ColorUtils /** * Convert rgb to int * - * @param array $rgb Int rgb array + * @param array $rgb Int rgb array * * @return int * diff --git a/Utils/Converter/Currency.php b/Utils/Converter/Currency.php index 77b270d7b..8dc20e57d 100644 --- a/Utils/Converter/Currency.php +++ b/Utils/Converter/Currency.php @@ -88,7 +88,7 @@ class Currency /** * Get ECB currency rates. * - * @return array + * @return array * * @throws \Exception * @@ -111,7 +111,7 @@ class Currency self::$ecbCurrencies = []; 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']; } } diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index 09aa2ff5e..d35b4704f 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -79,14 +79,14 @@ final class Dictionary $count = []; 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); } \sort($count); while (\count($count) > 1) { - $row1 = array_shift($count); - $row2 = array_shift($count); + $row1 = \array_shift($count); + $row2 = \array_shift($count); $count[] = [$row1[0] + $row2[0], [$row1, $row2]]; \sort($count); @@ -107,14 +107,14 @@ final class Dictionary */ 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'); } else { $this->fill($entry[0][1], $value . '0'); } if (isset($entry[1])) { - if (!is_array($entry[1][1])) { + if (!\is_array($entry[1][1])) { $this->set($entry[1][1], $value . '1'); } else { $this->fill($entry[1][1], $value . '1'); diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 88b28a3cd..b6dad6604 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -135,7 +135,7 @@ class Repository /** * Get all branches. * - * @return array + * @return array * * @since 1.0.0 */ @@ -160,7 +160,7 @@ class Repository * * @param string $cmd Command to run * - * @return array + * @return array * * @throws \Exception * @@ -212,7 +212,7 @@ class Repository * * @param string $lines Result of git command * - * @return array + * @return array * * @since 1.0.0 */ @@ -464,7 +464,7 @@ class Repository /** * Get all remote branches. * - * @return array + * @return array * * @since 1.0.0 */ @@ -642,7 +642,7 @@ class Repository /** * Get LOC. * - * @param array $extensions Extensions whitelist + * @param array $extensions Extensions whitelist * * @return int * @@ -687,7 +687,7 @@ class Repository * @param \DateTime $start Start date * @param \DateTime $end End date * - * @return array + * @return array * * @since 1.0.0 */ @@ -727,7 +727,7 @@ class Repository * @param \DateTime $start Start date * @param \DateTime $end End date * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Utils/Permutation.php b/Utils/Permutation.php index fcfca34b8..151931b62 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -41,7 +41,7 @@ final class Permutation * @param array $toPermute data to permutate * @param array $result existing permutations * - * @return array + * @return array * * @since 1.0.0 */ diff --git a/Utils/RnG/File.php b/Utils/RnG/File.php index f85ce6bb8..24f15d22e 100644 --- a/Utils/RnG/File.php +++ b/Utils/RnG/File.php @@ -48,7 +48,7 @@ class File /** * Get a random file extension. * - * @param array $source Source array for possible extensions + * @param array> $source Source array for possible extensions * @param DistributionType|int $distribution Distribution type for the extensions * * @return false|array diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index 24e0a3d85..da1abc6eb 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -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. * - * @param string $haystack Haystack - * @param array $needles Needles to check if any of them are part of the haystack + * @param string $haystack Haystack + * @param array $needles Needles to check if any of them are part of the haystack * * @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. * - * @param string $haystack Haystack - * @param array $needles Needles to check if any of them are part of the haystack + * @param string $haystack Haystack + * @param array $needles Needles to check if any of them are part of the haystack * * @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. * 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. * 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. * 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. * In case of an array the function will test if any of the needles is at the end of the haystack string. diff --git a/tests/Stdlib/Graph/EdgeTest.php b/tests/Stdlib/Graph/EdgeTest.php index aa8ce525b..b48ed81c4 100644 --- a/tests/Stdlib/Graph/EdgeTest.php +++ b/tests/Stdlib/Graph/EdgeTest.php @@ -14,11 +14,20 @@ namespace phpOMS\tests\Stdlib\Graph; use phpOMS\Stdlib\Graph\Edge; +use phpOMS\Stdlib\Graph\Node; 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()); } } diff --git a/tests/Stdlib/Graph/NodeTest.php b/tests/Stdlib/Graph/NodeTest.php index b5e04d6b1..b6c52101a 100644 --- a/tests/Stdlib/Graph/NodeTest.php +++ b/tests/Stdlib/Graph/NodeTest.php @@ -17,8 +17,18 @@ use phpOMS\Stdlib\Graph\Node; 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()); } } diff --git a/tests/Stdlib/Queue/PriorityQueueTest.php b/tests/Stdlib/Queue/PriorityQueueTest.php index e6bc6a058..a9e0cffc7 100644 --- a/tests/Stdlib/Queue/PriorityQueueTest.php +++ b/tests/Stdlib/Queue/PriorityQueueTest.php @@ -22,6 +22,9 @@ class PriorityQueueTest extends \PHPUnit\Framework\TestCase { $queue = new PriorityQueue(); self::assertEquals(0, $queue->count()); + self::assertEquals([], $queue->get(1)); + self::assertEquals([], $queue->pop()); + self::assertEquals([], $queue->getAll()); self::assertEquals(PriorityMode::FIFO, $queue->getType()); }