code fixes

This commit is contained in:
Dennis Eichhorn 2023-09-21 12:06:14 +00:00
parent 0d200da299
commit 6b74b8d968
7 changed files with 14 additions and 11 deletions

View File

@ -152,13 +152,15 @@ final class JWT
} }
try { try {
$header = \json_decode(Base64Url::decode($explode[0]), true); $header = \json_decode(Base64Url::decode($explode[0]), true);
$payload = \json_decode(Base64Url::decode($explode[1]), true); $payload = \json_decode(Base64Url::decode($explode[1]), true);
if (!\is_array($header) || !\is_array($payload)) { if (!\is_array($header) || !\is_array($payload)) {
return false; return false;
} }
/** @var array{alg:string, typ:string} $header */
/** @var array{sub:string, uid?:string, name?:string, iat:string} $payload */
$signature = self::createSignature($secret, $header, $payload); $signature = self::createSignature($secret, $header, $payload);
return \hash_equals($signature, $explode[2]); return \hash_equals($signature, $explode[2]);

View File

@ -77,6 +77,7 @@ class LanguageResult implements \ArrayAccess, \IteratorAggregate, \JsonSerializa
if ($offset === null) { if ($offset === null) {
$this->result[] = $value; $this->result[] = $value;
} else { } else {
/** @var int $offset */
$this->result[$offset] = $value; $this->result[$offset] = $value;
} }
} }

View File

@ -101,7 +101,7 @@ abstract class NgramParser
} }
} }
/** @var array $tokens */ /** @var array|non-empty-array $tokens */
foreach ($tokens as $i => $token) { foreach ($tokens as $i => $token) {
$sum = \array_sum($token); $sum = \array_sum($token);

View File

@ -697,11 +697,11 @@ class Matrix implements \ArrayAccess, \Iterator
* *
* @param self $B Matrix * @param self $B Matrix
* *
* @return int|float|self * @return self
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function dot(self $B) : int|float|self public function dot(self $B) : self
{ {
$value1 = $this->matrix; $value1 = $this->matrix;
$value2 = $B->getMatrix(); $value2 = $B->getMatrix();
@ -745,7 +745,7 @@ class Matrix implements \ArrayAccess, \Iterator
$result += $value1[$i] * $value2[$i]; $result += $value1[$i] * $value2[$i];
} }
return $result; return self::fromArray([[$result]]);
} elseif ($isMatrix1 && !$isMatrix2) { } elseif ($isMatrix1 && !$isMatrix2) {
$result = []; $result = [];
for ($i = 0; $i < $m1; ++$i) { // Row of 1 for ($i = 0; $i < $m1; ++$i) { // Row of 1

View File

@ -101,7 +101,7 @@ final class Vector extends Matrix
{ {
$dotProduct = 0.0; $dotProduct = 0.0;
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$dotProduct += $this->matrix[$i][0] * $v[$i][0]; $dotProduct += $this->matrix[$i][0] * $v->matrix[$i][0];
} }
$sumOfSquares = 0; $sumOfSquares = 0;

View File

@ -305,7 +305,7 @@ final class ArrayUtils
* @param string $id Id to find * @param string $id Id to find
* @param array<string|int, T> $args CLI command list * @param array<string|int, T> $args CLI command list
* *
* @return null|T * @return mixed
* *
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@ -12,12 +12,12 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace phpOMS\tests\Business\Marketing; namespace phpOMS\tests\Business\Recommendation;
use phpOMS\Business\Marketing\ArticleCorrelationAffinity; use phpOMS\Business\Recommendation\ArticleCorrelationAffinity;
/** /**
* @testdox phpOMS\tests\Business\Marketing\ArticleCorrelationAffinityTest: Article affinity/correlation * @testdox phpOMS\tests\Business\Recommendation\ArticleCorrelationAffinityTest: Article affinity/correlation
* *
* @internal * @internal
*/ */