Skip to content

Commit

Permalink
code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Sep 21, 2023
1 parent 0d200da commit 6b74b8d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions DataStorage/Session/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ public static function validateJWT(string $secret, string $jwt) : bool
}

try {
$header = \json_decode(Base64Url::decode($explode[0]), true);
$payload = \json_decode(Base64Url::decode($explode[1]), true);
$header = \json_decode(Base64Url::decode($explode[0]), true);
$payload = \json_decode(Base64Url::decode($explode[1]), true);

if (!\is_array($header) || !\is_array($payload)) {
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);

return \hash_equals($signature, $explode[2]);
Expand Down
1 change: 1 addition & 0 deletions Localization/LanguageDetection/LanguageResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function offsetSet($offset, $value) : void
if ($offset === null) {
$this->result[] = $value;
} else {
/** @var int $offset */
$this->result[$offset] = $value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Localization/LanguageDetection/NgramParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function getNgrams(string $str) : array
}
}

/** @var array $tokens */
/** @var array|non-empty-array $tokens */
foreach ($tokens as $i => $token) {

Check failure on line 105 in Localization/LanguageDetection/NgramParser.php

View workflow job for this annotation

GitHub Actions / static-tests (8.1)

Empty array passed to foreach.
$sum = \array_sum($token);

Expand Down
6 changes: 3 additions & 3 deletions Math/Matrix/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,11 @@ public function det() : float
*
* @param self $B Matrix
*
* @return int|float|self
* @return self
*
* @since 1.0.0
*/
public function dot(self $B) : int|float|self
public function dot(self $B) : self
{
$value1 = $this->matrix;
$value2 = $B->getMatrix();
Expand Down Expand Up @@ -745,7 +745,7 @@ public function dot(self $B) : int|float|self
$result += $value1[$i] * $value2[$i];
}

return $result;
return self::fromArray([[$result]]);
} elseif ($isMatrix1 && !$isMatrix2) {
$result = [];
for ($i = 0; $i < $m1; ++$i) { // Row of 1
Expand Down
2 changes: 1 addition & 1 deletion Math/Matrix/Vector.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function cosine(self $v) : float
{
$dotProduct = 0.0;
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;
Expand Down
2 changes: 1 addition & 1 deletion Utils/ArrayUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public static function arrayToXml(array $data, \SimpleXMLElement $xml = null) :
* @param string $id Id to find
* @param array<string|int, T> $args CLI command list
*
* @return null|T
* @return mixed
*
* @since 1.0.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*/
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
*/
Expand Down

0 comments on commit 6b74b8d

Please sign in to comment.