From ca57051cd7bef41d499ed2ede470cde074c9af45 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 24 Apr 2024 20:02:48 +0000 Subject: [PATCH] test fixes --- Algorithm/Clustering/PointInterface.php | 4 ++++ Api/EUVAT/EUVATVies.php | 16 +++++++++------- Business/Finance/Loan.php | 4 ++-- Dispatcher/Dispatcher.php | 1 + Message/Http/HttpRequest.php | 1 + Model/Html/FormElementGenerator.php | 2 +- Router/SocketRouter.php | 2 +- Router/WebRouter.php | 2 +- Uri/UriFactory.php | 4 ++-- Utils/Barcode/TwoDAbstract.php | 4 ++-- Utils/Parser/Markdown/Markdown.php | 18 +++++++++--------- 11 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Algorithm/Clustering/PointInterface.php b/Algorithm/Clustering/PointInterface.php index bac83bf60..3d89389be 100755 --- a/Algorithm/Clustering/PointInterface.php +++ b/Algorithm/Clustering/PointInterface.php @@ -25,6 +25,10 @@ namespace phpOMS\Algorithm\Clustering; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @property array $coordinates + * @property string $name + * @property int $group */ interface PointInterface { diff --git a/Api/EUVAT/EUVATVies.php b/Api/EUVAT/EUVATVies.php index 4fcda0f99..c27dad3ed 100755 --- a/Api/EUVAT/EUVATVies.php +++ b/Api/EUVAT/EUVATVies.php @@ -211,20 +211,22 @@ final class EUVATVies implements EUVATInterface $result['vat'] = $json['isValid'] ? 'A' : 'B'; $result['name'] = $json['isValid']; - $result['city'] = \stripos($json['address'] ?? '', "\n") !== false - ? \substr($json['address'], \stripos($json['address'], "\n") + 1) + $newLinePos = \stripos($json['address'] ?? '', "\n"); + + $result['city'] = $newLinePos !== false + ? \substr($json['address'], $newLinePos + 1) : ''; - $result['postal'] = \stripos($json['address'] ?? '', "\n") !== false + $result['postal'] = $newLinePos !== false ? \substr( $json['address'], - \stripos($json['address'], "\n") + 1, - \stripos($json['address'], ' ', \stripos($json['address'], "\n")) - \stripos($json['address'], "\n") - 1 + $newLinePos + 1, + \stripos($json['address'], ' ', $newLinePos) - $newLinePos - 1 ) : ''; - $result['address'] = \stripos($json['address'] ?? '', "\n") !== false - ? \substr($json['address'], 0, \stripos($json['address'], "\n") - 1) + $result['address'] = $newLinePos !== false + ? \substr($json['address'], 0, $newLinePos - 1) : ($json['address'] ?? ''); $result['name'] = $result['name'] === '---' ? '' : $result['name']; diff --git a/Business/Finance/Loan.php b/Business/Finance/Loan.php index 0e3f7fc6e..79421b9a0 100755 --- a/Business/Finance/Loan.php +++ b/Business/Finance/Loan.php @@ -134,7 +134,7 @@ final class Loan return $loan / $collateral; } - public static function getAmortizationLoanPayment(float $loan, float $r, int $duration, int $interval) + public static function getAmortizationLoanPayment(float $loan, float $r, int $duration, int $interval) : float { return $loan * (($r / $interval * (1.0 + $r / $interval) / $duration) / ((1.0 + $r / $interval) / $duration) - 1); } @@ -144,7 +144,7 @@ final class Loan return $loan * $r / $interval; } - public static function getAmortizationPrincipalPayment(float $payment, float $interest) + public static function getAmortizationPrincipalPayment(float $payment, float $interest) : float { return $payment - $interest; } diff --git a/Dispatcher/Dispatcher.php b/Dispatcher/Dispatcher.php index 4d6a66c74..a3254f1af 100755 --- a/Dispatcher/Dispatcher.php +++ b/Dispatcher/Dispatcher.php @@ -84,6 +84,7 @@ final class Dispatcher implements DispatcherInterface if (($c = \count($dispatch)) === 3) { /* Handling static functions */ + /** @var \Closure $function */ $function = $dispatch[0] . '::' . $dispatch[2]; $views[$controller] = $data === null ? $function() : $function(...$data); diff --git a/Message/Http/HttpRequest.php b/Message/Http/HttpRequest.php index 6ef20f278..593db590f 100755 --- a/Message/Http/HttpRequest.php +++ b/Message/Http/HttpRequest.php @@ -34,6 +34,7 @@ use phpOMS\Uri\UriInterface; * @SuppressWarnings(PHPMD.Superglobals) * * @property HttpHeader $header + * @property HttpUri $uri */ final class HttpRequest extends RequestAbstract { diff --git a/Model/Html/FormElementGenerator.php b/Model/Html/FormElementGenerator.php index 1ae27a2cf..32320df5b 100755 --- a/Model/Html/FormElementGenerator.php +++ b/Model/Html/FormElementGenerator.php @@ -74,7 +74,7 @@ final class FormElementGenerator $element .= ' ' . $attribute . '="' . $val . '"'; } - $value ??= $json['default']['value'] ?? ''; + $value ??= $json['default']['value'] ?? null; $element .= (isset($json['default']) || $value !== null ? ' value="' . ($json['subtype'] === 'datetime' ? (new SmartDateTime($value))->format($json['default']['format']) : $value) . '"' : ''); diff --git a/Router/SocketRouter.php b/Router/SocketRouter.php index a5fae2caf..a150343a5 100755 --- a/Router/SocketRouter.php +++ b/Router/SocketRouter.php @@ -29,7 +29,7 @@ final class SocketRouter implements RouterInterface /** * Routes. * - * @var array> + * @var array> * @since 1.0.0 */ private array $routes = []; diff --git a/Router/WebRouter.php b/Router/WebRouter.php index 109d70970..e39256a97 100755 --- a/Router/WebRouter.php +++ b/Router/WebRouter.php @@ -40,7 +40,7 @@ final class WebRouter implements RouterInterface /** * Routes. * - * @var array> + * @var array> * @since 1.0.0 */ private array $routes = []; diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index dbeeeb232..fe9facc4b 100755 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -127,13 +127,13 @@ final class UriFactory /** * Setup uri builder based on current request * - * @param UriInterface $uri Uri + * @param HttpUri $uri Uri * * @return void * * @since 1.0.0 */ - public static function setupUriBuilder(UriInterface $uri) : void + public static function setupUriBuilder(HttpUri $uri) : void { self::setQuery('/scheme', $uri->scheme); self::setQuery('/host', $uri->host); diff --git a/Utils/Barcode/TwoDAbstract.php b/Utils/Barcode/TwoDAbstract.php index d80e5ab24..130844189 100755 --- a/Utils/Barcode/TwoDAbstract.php +++ b/Utils/Barcode/TwoDAbstract.php @@ -49,13 +49,13 @@ abstract class TwoDAbstract extends CodeAbstract * * @param array $codeArray Code array to render * - * @return \GdImage + * @return null|\GdImage * * @throws \Exception * * @since 1.0.0 */ - protected function createImage(array $codeArray) : mixed + protected function createImage(array $codeArray) : ?\GdImage { if (empty($codeArray)) { return null; diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 442803ebf..738401d11 100755 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -338,7 +338,7 @@ class Markdown * @var array{}|array{text:string, id:string, level:string} * @since 1.0.0 */ - protected $contentsListArray = []; + protected array $contentsListArray = []; /** * TOC string after parsing headers @@ -346,7 +346,7 @@ class Markdown * @var string * @since 1.0.0 */ - protected $contentsListString = ''; + protected string $contentsListString = ''; /** * First head level @@ -362,7 +362,7 @@ class Markdown * @var bool * @since 1.0.0 */ - protected $isBlacklistInitialized = false; + protected bool $isBlacklistInitialized = false; /** * Header duplicates (same header text) @@ -370,7 +370,7 @@ class Markdown * @var array * @since 1.0.0 */ - protected $anchorDuplicates = []; + protected array $anchorDuplicates = []; // TOC: end /** @@ -387,7 +387,7 @@ class Markdown * @var string * @since 1.0.0 */ - private string $currentAbreviation; + private string $currentAbbreviation; /** * Current abbreviation meaning @@ -420,7 +420,7 @@ class Markdown $this->firstHeadLevel = 0; $this->anchorDuplicates = []; $this->footnoteCount = 0; - $this->currentAbreviation = ''; + $this->currentAbbreviation = ''; $this->currentMeaning = ''; } @@ -3514,14 +3514,14 @@ class Markdown } $element['elements'] = self::pregReplaceElements( - '/\b' . \preg_quote($this->currentAbreviation, '/') . '\b/', + '/\b' . \preg_quote($this->currentAbbreviation, '/') . '\b/', [ [ 'name' => 'abbr', 'attributes' => [ 'title' => $this->currentMeaning, ], - 'text' => $this->currentAbreviation, + 'text' => $this->currentAbbreviation, ], ], $element['text'] @@ -3563,7 +3563,7 @@ class Markdown } foreach ($this->definitionData['Abbreviation'] as $abbreviation => $meaning) { - $this->currentAbreviation = $abbreviation; + $this->currentAbbreviation = $abbreviation; $this->currentMeaning = $meaning; $inline['element'] = $this->elementApplyRecursiveDepthFirst(