auto fixes

This commit is contained in:
Dennis Eichhorn 2023-08-30 11:53:16 +00:00
parent 447efca623
commit 4469789af4
34 changed files with 290 additions and 318 deletions

View File

@ -141,7 +141,7 @@ final class DBSCAN
{ {
$this->clusters[$c][] = $point; $this->clusters[$c][] = $point;
$this->clusteredPoints[] = $point; $this->clusteredPoints[] = $point;
$nPoint = reset($neighbors); $nPoint = \reset($neighbors);
while ($nPoint) { while ($nPoint) {
$neighbors2 = $this->findNeighbors($nPoint, $epsilon); $neighbors2 = $this->findNeighbors($nPoint, $epsilon);
@ -159,7 +159,7 @@ final class DBSCAN
$this->clusteredPoints[] = $nPoint; $this->clusteredPoints[] = $nPoint;
} }
$nPoint = next($neighbors); $nPoint = \next($neighbors);
} }
} }
@ -242,7 +242,7 @@ final class DBSCAN
if (Polygon::isPointInPolygon( if (Polygon::isPointInPolygon(
[ [
'x' => \reset($point->coordinates), 'x' => \reset($point->coordinates),
'y' => \end($point->coordinates) 'y' => \end($point->coordinates),
], ],
$hull $hull
) <= 0 ) <= 0

View File

@ -160,7 +160,7 @@ final class MeanShift
// @todo create an array of noisePoints like in the DBSCAN. That array can be empty or not depending on the bandwidth defined // @todo create an array of noisePoints like in the DBSCAN. That array can be empty or not depending on the bandwidth defined
$this->clusters = $this->groupPoints($shiftPoints); $this->clusters = $this->groupPoints($shiftPoints);
$this->clusterCenters = $shiftPoints; $this->clusterCenters = $shiftPoints;
} }
@ -215,8 +215,8 @@ final class MeanShift
private function groupPoints(array $points) : array private function groupPoints(array $points) : array
{ {
$groupAssignment = []; $groupAssignment = [];
$groups = []; $groups = [];
$groupIndex = 0; $groupIndex = 0;
foreach ($points as $point) { foreach ($points as $point) {
$nearestGroupIndex = $this->findNearestGroup($point, $groups); $nearestGroupIndex = $this->findNearestGroup($point, $groups);

View File

@ -33,6 +33,4 @@ class IdleTime
public int $interval = 0; public int $interval = 0;
public int $duration = 0; // in seconds public int $duration = 0; // in seconds
} }

View File

@ -29,6 +29,4 @@ class Machine
public MachineType $type; public MachineType $type;
public array $idle = []; public array $idle = [];
} }

View File

@ -144,6 +144,4 @@ final class ScheduleQueue
{ {
unset($this->queue[$id]); unset($this->queue[$id]);
} }
} }

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);
@ -108,7 +107,7 @@ class GeneticOptimization
$parameterCount = \count(\reset($population)); $parameterCount = \count(\reset($population));
// Genetic Algorithm Loop // Genetic Algorithm Loop
for ($generation = 0; $generation < $generations; $generation++) { for ($generation = 0; $generation < $generations; ++$generation) {
$fitnessScores = []; $fitnessScores = [];
foreach ($population as $parameters) { foreach ($population as $parameters) {
$fitnessScores[] = ($fitness)($parameters); $fitnessScores[] = ($fitness)($parameters);
@ -116,7 +115,7 @@ class GeneticOptimization
// Select parents for crossover based on fitness scores // Select parents for crossover based on fitness scores
$parents = []; $parents = [];
for ($i = 0; $i < $populationSize; $i++) { for ($i = 0; $i < $populationSize; ++$i) {
do { do {
$parentIndex1 = \array_rand($population); $parentIndex1 = \array_rand($population);
$parentIndex2 = \array_rand($population); $parentIndex2 = \array_rand($population);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);
@ -77,7 +76,7 @@ class SimulatedAnnealing
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function optimize( public function optimize(
array $space, array $space,
int $initialTemperature, int $initialTemperature,
\Closure $costFunction, \Closure $costFunction,
@ -96,19 +95,19 @@ class SimulatedAnnealing
$newCost = ($costFunction)($newGeneration); $newCost = ($costFunction)($newGeneration);
$temperature = $initialTemperature * pow($coolingRate, $i); $temperature = $initialTemperature * \pow($coolingRate, $i);
if ($newCost < $currentCost if ($newCost < $currentCost
|| \mt_rand() / \mt_getrandmax() < \exp(($currentCost - $newCost) / $temperature) || \mt_rand() / \mt_getrandmax() < \exp(($currentCost - $newCost) / $temperature)
) { ) {
$currentGeneration = $newGeneration; $currentGeneration = $newGeneration;
$currentCost = $newCost; $currentCost = $newCost;
} }
} }
return [ return [
'solutions' => $currentGeneration, 'solutions' => $currentGeneration,
'costs' => $currentCost 'costs' => $currentCost,
]; ];
} }
} }

View File

@ -9,7 +9,6 @@
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
* @link https://jingga.app * @link https://jingga.app
*
*/ */
declare(strict_types=1); declare(strict_types=1);
@ -97,7 +96,7 @@ class TabuSearch
} }
} }
if (\is_null($bestNeighbor)) { if ($bestNeighbor === null) {
break; break;
} }
@ -108,7 +107,6 @@ class TabuSearch
$currentSolution = $bestNeighbor; $currentSolution = $bestNeighbor;
if (($score = ($fitness)($bestNeighbor)) > $bestFitness) { if (($score = ($fitness)($bestNeighbor)) > $bestFitness) {
$bestSolution = $bestNeighbor; $bestSolution = $bestNeighbor;
$bestFitness = $score; $bestFitness = $score;

View File

@ -166,7 +166,7 @@ final class Glicko1
return [ return [
'elo' => (int) \max((int) $r, $this->MIN_ELO), 'elo' => (int) \max((int) $r, $this->MIN_ELO),
'rd' => (int) \max($RD_, $this->MIN_RD) 'rd' => (int) \max($RD_, $this->MIN_RD),
]; ];
} }
} }

View File

@ -124,7 +124,7 @@ final class Glicko2
// Step 1: // Step 1:
$g = []; $g = [];
foreach ($oRd as $rd) { foreach ($oRd as $rd) {
$g[] = 1 / \sqrt(1 + 3 * $rd * $rd / (\M_PI * \M_PI)); $g[] = 1 / \sqrt(1 + 3 * $rd * $rd / (\M_PI * \M_PI));
} }
$E = []; $E = [];

View File

@ -41,7 +41,6 @@ class TrueSkill
public function __construct() public function __construct()
{ {
} }
// Draw margin = epsilon // Draw margin = epsilon
@ -104,15 +103,15 @@ class TrueSkill
private function vDraw(float $t, float $epsilon) : float private function vDraw(float $t, float $epsilon) : float
{ {
$tAbs = \abs($t); $tAbs = \abs($t);
$a = $epsilon - $tAbs; $a = $epsilon - $tAbs;
$b = -$epsilon - $tAbs; $b = -$epsilon - $tAbs;
$aPdf = NormalDistribution::getPdf($a, 0.0, 1.0); $aPdf = NormalDistribution::getPdf($a, 0.0, 1.0);
$bPdf = NormalDistribution::getPdf($b, 0.0, 1.0); $bPdf = NormalDistribution::getPdf($b, 0.0, 1.0);
$numer = $bPdf - $aPdf; $numer = $bPdf - $aPdf;
$aCdf = NormalDistribution::getCdf($a, 0.0, 1.0); $aCdf = NormalDistribution::getCdf($a, 0.0, 1.0);
$bCdf = NormalDistribution::getCdf($b, 0.0, 1.0); $bCdf = NormalDistribution::getCdf($b, 0.0, 1.0);
$denom = $aCdf - $bCdf; $denom = $aCdf - $bCdf;
return $numer / $denom; return $numer / $denom;
@ -156,28 +155,24 @@ class TrueSkill
$v = $this->vDraw($t, $epsilon); $v = $this->vDraw($t, $epsilon);
return $v * $v return $v * $v
+ (($epsilon - $t) * NormalDistribution::getPdf($epsilon - $tAbs, 0.0, 1.0) + ($epsilon + $tAbs) * NormalDistribution::getPdf($epsilon + $tAbs, 0.0, 1.0)) + (($epsilon - $t) * NormalDistribution::getPdf($epsilon - $tAbs, 0.0, 1.0) + ($epsilon + $tAbs) * NormalDistribution::getPdf($epsilon + $tAbs, 0.0, 1.0))
/ (NormalDistribution::getCdf($epsilon - $tAbs, 0.0, 1.0) - NormalDistribution::getCdf(-$epsilon - $tAbs, 0.0, 1.0)); / (NormalDistribution::getCdf($epsilon - $tAbs, 0.0, 1.0) - NormalDistribution::getCdf(-$epsilon - $tAbs, 0.0, 1.0));
} }
private function buildRatingLayer() private function buildRatingLayer() : void
{ {
} }
private function buildPerformanceLayer() private function buildPerformanceLayer() : void
{ {
} }
private function buildTeamPerformanceLayer() private function buildTeamPerformanceLayer() : void
{ {
} }
private function buildTruncLayer() private function buildTruncLayer() : void
{ {
} }
private function factorGraphBuilders() private function factorGraphBuilders()
@ -191,44 +186,37 @@ class TrueSkill
// Trunc layer // Trunc layer
return [ return [
'rating_layer' => $ratingLayer, 'rating_layer' => $ratingLayer,
'performance_layer' => $ratingLayer, 'performance_layer' => $ratingLayer,
'team_performance_layer' => $ratingLayer, 'team_performance_layer' => $ratingLayer,
'trunc_layer' => $ratingLayer, 'trunc_layer' => $ratingLayer,
]; ];
} }
public function rating() public function rating() : void
{ {
// Start values // Start values
$mu = 25; $mu = 25;
$sigma = $mu / 3; $sigma = $mu / 3;
$beta = $sigma / 2; $beta = $sigma / 2;
$tau = $sigma / 100; $tau = $sigma / 100;
$Pdraw = 0.1; $Pdraw = 0.1;
$alpha = 0.25; $alpha = 0.25;
// Partial update // Partial update
$sigmaPartial = $sigmaOld * $sigmaNew / \sqrt($alpha * $sigmaOld * $sigmaOld - ($alpha - 1) * $sigmaNew * $sigmaNew); $sigmaPartial = $sigmaOld * $sigmaNew / \sqrt($alpha * $sigmaOld * $sigmaOld - ($alpha - 1) * $sigmaNew * $sigmaNew);
$muPartial = $muOld * ($alpha - 1) * $sigmaNew * $sigmaNew - $muNew * $alpha * $sigmaOld * $sigmaOld $muPartial = $muOld * ($alpha - 1) * $sigmaNew * $sigmaNew - $muNew * $alpha * $sigmaOld * $sigmaOld
/ (($alpha - 1) * $sigmaNew * $sigmaNew - $alpha * $sigmaOld * $sigmaOld); / (($alpha - 1) * $sigmaNew * $sigmaNew - $alpha * $sigmaOld * $sigmaOld);
// New // New
$tau = $pi * $mu; $tau = $pi * $mu;
$P = NormalDistribution::getCdf(($s1 - $s2) / (\sqrt(2) * $beta)); $P = NormalDistribution::getCdf(($s1 - $s2) / (\sqrt(2) * $beta));
$Delta = $alpha * $beta * \sqrt($pi) * (($y + 1) / 2 - $P); $Delta = $alpha * $beta * \sqrt($pi) * (($y + 1) / 2 - $P);
$K = NormalDistribution::getCdf(); $K = NormalDistribution::getCdf();
$pi = 1 / ($sigma * $sigma); $pi = 1 / ($sigma * $sigma);
} }
} }

View File

@ -28,18 +28,21 @@ namespace phpOMS\Business\Recommendation;
final class BayesianPersonalizedRanking final class BayesianPersonalizedRanking
{ {
private int $numFactors; private int $numFactors;
private float $learningRate; private float $learningRate;
private float $regularization; private float $regularization;
private array $userFactors = []; private array $userFactors = [];
private array $itemFactors = []; private array $itemFactors = [];
// num_factors determines the dimensionality of the latent factor space. // num_factors determines the dimensionality of the latent factor space.
// learning_rate controls the step size for updating the latent factors during optimization. // learning_rate controls the step size for updating the latent factors during optimization.
// regularization prevents overfitting by adding a penalty for large parameter values. // regularization prevents overfitting by adding a penalty for large parameter values.
public function __construct(int $numFactors, float $learningRate, float $regularization) { public function __construct(int $numFactors, float $learningRate, float $regularization) {
$this->numFactors = $numFactors; $this->numFactors = $numFactors;
$this->learningRate = $learningRate; $this->learningRate = $learningRate;
$this->regularization = $regularization; $this->regularization = $regularization;
} }
@ -55,7 +58,7 @@ final class BayesianPersonalizedRanking
public function predict($userId, $itemId) { public function predict($userId, $itemId) {
$userFactor = $this->userFactors[$userId]; $userFactor = $this->userFactors[$userId];
$itemFactor = $this->itemFactors[$itemId]; $itemFactor = $this->itemFactors[$itemId];
$score = 0; $score = 0;
for ($i = 0; $i < $this->numFactors; ++$i) { for ($i = 0; $i < $this->numFactors; ++$i) {
$score += $userFactor[$i] * $itemFactor[$i]; $score += $userFactor[$i] * $itemFactor[$i];
@ -64,7 +67,7 @@ final class BayesianPersonalizedRanking
return $score; return $score;
} }
public function updateFactors($userId, $posItemId, $negItemId) { public function updateFactors($userId, $posItemId, $negItemId) : void {
if (!isset($this->userFactors[$userId])) { if (!isset($this->userFactors[$userId])) {
$this->userFactors[$userId] = $this->generateRandomFactors(); $this->userFactors[$userId] = $this->generateRandomFactors();
} }
@ -77,17 +80,17 @@ final class BayesianPersonalizedRanking
$this->itemFactors[$negItemId] = $this->generateRandomFactors(); $this->itemFactors[$negItemId] = $this->generateRandomFactors();
} }
$userFactor = $this->userFactors[$userId]; $userFactor = $this->userFactors[$userId];
$posItemFactor = $this->itemFactors[$posItemId]; $posItemFactor = $this->itemFactors[$posItemId];
$negItemFactor = $this->itemFactors[$negItemId]; $negItemFactor = $this->itemFactors[$negItemId];
for ($i = 0; $i < $this->numFactors; ++$i) { for ($i = 0; $i < $this->numFactors; ++$i) {
$userFactor[$i] += $this->learningRate * ($posItemFactor[$i] - $negItemFactor[$i]) - $this->regularization * $userFactor[$i]; $userFactor[$i] += $this->learningRate * ($posItemFactor[$i] - $negItemFactor[$i]) - $this->regularization * $userFactor[$i];
$posItemFactor[$i] += $this->learningRate * $userFactor[$i] - $this->regularization * $posItemFactor[$i]; $posItemFactor[$i] += $this->learningRate * $userFactor[$i] - $this->regularization * $posItemFactor[$i];
$negItemFactor[$i] += $this->learningRate * (-$userFactor[$i]) - $this->regularization * $negItemFactor[$i]; $negItemFactor[$i] += $this->learningRate * (-$userFactor[$i]) - $this->regularization * $negItemFactor[$i];
} }
$this->userFactors[$userId] = $userFactor; $this->userFactors[$userId] = $userFactor;
$this->itemFactors[$posItemId] = $posItemFactor; $this->itemFactors[$posItemId] = $posItemFactor;
$this->itemFactors[$negItemId] = $negItemFactor; $this->itemFactors[$negItemId] = $negItemFactor;
} }

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Session; namespace phpOMS\DataStorage\Session;
use phpOMS\DataStorage\LockException;
use phpOMS\Log\FileLogger; use phpOMS\Log\FileLogger;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Session\JWT; use phpOMS\Session\JWT;

View File

@ -35,8 +35,8 @@ final class JWT
/** /**
* Create JWT signature part * Create JWT signature part
* *
* @param string $secret Secret (at least 256 bit) * @param string $secret Secret (at least 256 bit)
* @param array{alg:string, typ:string} $header Header * @param array{alg:string, typ:string} $header Header
* @param array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload * @param array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload
* *
* @return string hmac(Header64 . Payload64, secret) * @return string hmac(Header64 . Payload64, secret)
@ -60,8 +60,8 @@ final class JWT
/** /**
* Create JWT token * Create JWT token
* *
* @param string $secret Secret (at least 256 bit) * @param string $secret Secret (at least 256 bit)
* @param array{alg:string, typ:string} $header Header * @param array{alg:string, typ:string} $header Header
* @param array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload * @param array{sub:string, ?uid:string, ?name:string, iat:string} $payload Payload
* *
* @return string Header64 . Payload64 . hmac(Header64 . Payload64, secret) * @return string Header64 . Payload64 . hmac(Header64 . Payload64, secret)
@ -128,8 +128,8 @@ final class JWT
/** /**
* Validate JWT token integrity * Validate JWT token integrity
* *
* @param string $secret Secret (at least 256 bit) * @param string $secret Secret (at least 256 bit)
* @param string $jwt JWT token [Header64 . Payload64 . hmac(Header64 . Payload64, secret)] * @param string $jwt JWT token [Header64 . Payload64 . hmac(Header64 . Payload64, secret)]
* *
* @return bool * @return bool
* *

View File

@ -61,7 +61,7 @@ final class Dispatcher implements DispatcherInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dispatch(array | string | Callable $controller, mixed ...$data) : array public function dispatch(array | string | callable $controller, mixed ...$data) : array
{ {
$views = []; $views = [];
$data = \array_values($data); $data = \array_values($data);
@ -172,7 +172,7 @@ final class Dispatcher implements DispatcherInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
private function dispatchClosure(Callable $controller, array $data = null) : mixed private function dispatchClosure(callable $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);
} }

View File

@ -36,5 +36,5 @@ interface DispatcherInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function dispatch(array | string | Callable $controller, mixed ...$data) : array; public function dispatch(array | string | callable $controller, mixed ...$data) : array;
} }

View File

@ -70,7 +70,7 @@ final class EventManager implements \Countable
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dispatch(array | string | Callable $func, mixed ...$data) : array public function dispatch(array | string | callable $func, mixed ...$data) : array
{ {
if (!\is_callable($func)) { if (!\is_callable($func)) {
return []; return [];
@ -144,7 +144,7 @@ final class EventManager implements \Countable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function attach(string $group, string | Callable $callback, bool $remove = false, bool $reset = false) : bool public function attach(string $group, string | callable $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' => []];

View File

@ -256,7 +256,7 @@ final class Functions
-1.624290004647e-6,1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8, -1.624290004647e-6,1.303655835580e-6,1.5626441722e-8,-8.5238095915e-8,
6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10, 6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,
9.6467911e-11, 2.394038e-12,-6.886027e-12,8.94487e-13, 3.13092e-13, 9.6467911e-11, 2.394038e-12,-6.886027e-12,8.94487e-13, 3.13092e-13,
-1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17 -1.12708e-13,3.81e-16,7.106e-15,-1.523e-15,-9.4e-17,1.21e-16,-2.8e-17,
]; ];
/** /**
@ -322,7 +322,7 @@ final class Functions
$dd = $tmp; $dd = $tmp;
} }
return $t * \exp(-$z * $z + 0.5*(self::ERF_COF[0] + $ty * $d) - $dd); return $t * \exp(-$z * $z + 0.5 * (self::ERF_COF[0] + $ty * $d) - $dd);
} }
/** /**
@ -343,8 +343,8 @@ final class Functions
} }
$pp = ($p < 1.0) ? $p : 2. - $p; $pp = ($p < 1.0) ? $p : 2. - $p;
$t = sqrt(-2. * \log($pp / 2.)); $t = \sqrt(-2. * \log($pp / 2.));
$x = -0.70711 * ((2.30753 + $t * 0.27061)/(1. + $t * (0.99229 + $t * 0.04481)) - $t); $x = -0.70711 * ((2.30753 + $t * 0.27061) / (1. + $t * (0.99229 + $t * 0.04481)) - $t);
for ($j = 0; $j < 2; ++$j) { for ($j = 0; $j < 2; ++$j) {
$err = self::getErfc($x) - $pp; $err = self::getErfc($x) - $pp;

View File

@ -845,9 +845,9 @@ class Matrix implements \ArrayAccess, \Iterator
if ($this->isDiagonal()) { if ($this->isDiagonal()) {
$matrix = []; $matrix = [];
for ($i = 0; $i < $this->m; $i++) { for ($i = 0; $i < $this->m; ++$i) {
$row = []; $row = [];
for ($j = 0; $j < $this->m; $j++) { for ($j = 0; $j < $this->m; ++$j) {
if ($i === $j) { if ($i === $j) {
$row[] = \pow($this->matrix[$i][$j], $exponent); $row[] = \pow($this->matrix[$i][$j], $exponent);
} else { } else {

View File

@ -37,7 +37,7 @@ final class Integration
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function intLeftRect(float $from, float $to, float $n, Callable $func) : float public static function intLeftRect(float $from, float $to, float $n, callable $func) : float
{ {
$h = ($to - $from) / $n; $h = ($to - $from) / $n;
$sum = 0.0; $sum = 0.0;
@ -61,7 +61,7 @@ final class Integration
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function intRightRect(float $from, float $to, float $n, Callable $func) : float public static function intRightRect(float $from, float $to, float $n, callable $func) : float
{ {
$h = ($to - $from) / $n; $h = ($to - $from) / $n;
$sum = 0.0; $sum = 0.0;
@ -85,7 +85,7 @@ final class Integration
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function intMiddleRect(float $from, float $to, float $n, Callable $func) : float public static function intMiddleRect(float $from, float $to, float $n, callable $func) : float
{ {
$h = ($to - $from) / $n; $h = ($to - $from) / $n;
$sum = 0.0; $sum = 0.0;
@ -109,7 +109,7 @@ final class Integration
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function intTrapezium(float $from, float $to, float $n, Callable $func) : float public static function intTrapezium(float $from, float $to, float $n, callable $func) : float
{ {
$h = ($to - $from) / $n; $h = ($to - $from) / $n;
$sum = $func($from) + $func($to); $sum = $func($from) + $func($to);
@ -133,7 +133,7 @@ final class Integration
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function intSimpson(float $from, float $to, float $n, Callable $func) : float public static function intSimpson(float $from, float $to, float $n, callable $func) : float
{ {
$h = ($to - $from) / $n; $h = ($to - $from) / $n;
$sum1 = 0.0; $sum1 = 0.0;

View File

@ -48,7 +48,7 @@ final class Bisection
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
{ {
if ($func($a) * $func($b) >= 0) { if ($func($a) * $func($b) >= 0) {
throw new \Exception("Function values at endpoints must have opposite signs."); throw new \Exception("Function values at endpoints must have opposite signs.");

View File

@ -48,7 +48,7 @@ final class Illinois
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
{ {
if ($func($a) * $func($b) >= 0) { if ($func($a) * $func($b) >= 0) {
throw new \Exception("Function values at endpoints must have opposite signs."); throw new \Exception("Function values at endpoints must have opposite signs.");

View File

@ -48,7 +48,7 @@ final class RegulaFalsi
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function root(Callable $func, float $a, float $b, int $maxIterations = 100) : float public static function root(callable $func, float $a, float $b, int $maxIterations = 100) : float
{ {
if ($func($a) * $func($b) >= 0) { if ($func($a) * $func($b) >= 0) {
throw new \Exception("Function values at endpoints must have opposite signs."); throw new \Exception("Function values at endpoints must have opposite signs.");

View File

@ -264,7 +264,7 @@ final class MeasureOfDispersion
* *
* @return float * @return float
* *
* @throws ZeroDivisionException This exception is thrown if the size of the x array is less than 2 * @throws ZeroDivisionException This exception is thrown if the size of the x array is less than 2
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -65,7 +65,7 @@ final class Kernels2D
public static function triangularKernel(float $distance, float $bandwidth) : float public static function triangularKernel(float $distance, float $bandwidth) : float
{ {
return \abs($distance) <= $bandwidth / 2 return \abs($distance) <= $bandwidth / 2
? 1 - abs($distance) / ($bandwidth / 2) ? 1 - \abs($distance) / ($bandwidth / 2)
: 0.0; : 0.0;
} }

View File

@ -112,7 +112,7 @@ final class MetricsND
} }
$dotProduct = 0; $dotProduct = 0;
for ($i = 0; $i < \count($a); $i++) { for ($i = 0; $i < \count($a); ++$i) {
$dotProduct += $a[$i] * $b[$i]; $dotProduct += $a[$i] * $b[$i];
} }

View File

@ -40,7 +40,7 @@ class HtmlFormatter
$dom->loadHTML($text); $dom->loadHTML($text);
$dom->preserveWhiteSpace = false; $dom->preserveWhiteSpace = false;
$dom->formatOutput = true; $dom->formatOutput = true;
return $dom->saveXML($dom->documentElement); return $dom->saveXML($dom->documentElement);
} }

File diff suppressed because it is too large Load Diff

View File

@ -84,13 +84,13 @@ final class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
*/ */
public function testEqualPermissions() : void public function testEqualPermissions() : void
{ {
$perm1 = new class() extends PermissionAbstract {}; $perm1 = new class() extends PermissionAbstract {};
$perm1->unit = 1; $perm1->unit = 1;
$perm1->setPermission(PermissionType::READ); $perm1->setPermission(PermissionType::READ);
self::assertTrue($perm1->isEqual($perm1)); self::assertTrue($perm1->isEqual($perm1));
$perm2 = new class() extends PermissionAbstract {}; $perm2 = new class() extends PermissionAbstract {};
$perm2->unit = 1; $perm2->unit = 1;
$perm2->setPermission(PermissionType::CREATE); $perm2->setPermission(PermissionType::CREATE);