test fixes

This commit is contained in:
Dennis Eichhorn 2024-04-24 20:02:48 +00:00
parent 370e4fa420
commit ca57051cd7
11 changed files with 33 additions and 25 deletions

View File

@ -25,6 +25,10 @@ namespace phpOMS\Algorithm\Clustering;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @property array<int, int|float> $coordinates
* @property string $name
* @property int $group
*/ */
interface PointInterface interface PointInterface
{ {

View File

@ -211,20 +211,22 @@ final class EUVATVies implements EUVATInterface
$result['vat'] = $json['isValid'] ? 'A' : 'B'; $result['vat'] = $json['isValid'] ? 'A' : 'B';
$result['name'] = $json['isValid']; $result['name'] = $json['isValid'];
$result['city'] = \stripos($json['address'] ?? '', "\n") !== false $newLinePos = \stripos($json['address'] ?? '', "\n");
? \substr($json['address'], \stripos($json['address'], "\n") + 1)
$result['city'] = $newLinePos !== false
? \substr($json['address'], $newLinePos + 1)
: ''; : '';
$result['postal'] = \stripos($json['address'] ?? '', "\n") !== false $result['postal'] = $newLinePos !== false
? \substr( ? \substr(
$json['address'], $json['address'],
\stripos($json['address'], "\n") + 1, $newLinePos + 1,
\stripos($json['address'], ' ', \stripos($json['address'], "\n")) - \stripos($json['address'], "\n") - 1 \stripos($json['address'], ' ', $newLinePos) - $newLinePos - 1
) )
: ''; : '';
$result['address'] = \stripos($json['address'] ?? '', "\n") !== false $result['address'] = $newLinePos !== false
? \substr($json['address'], 0, \stripos($json['address'], "\n") - 1) ? \substr($json['address'], 0, $newLinePos - 1)
: ($json['address'] ?? ''); : ($json['address'] ?? '');
$result['name'] = $result['name'] === '---' ? '' : $result['name']; $result['name'] = $result['name'] === '---' ? '' : $result['name'];

View File

@ -134,7 +134,7 @@ final class Loan
return $loan / $collateral; 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); 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; return $loan * $r / $interval;
} }
public static function getAmortizationPrincipalPayment(float $payment, float $interest) public static function getAmortizationPrincipalPayment(float $payment, float $interest) : float
{ {
return $payment - $interest; return $payment - $interest;
} }

View File

@ -84,6 +84,7 @@ final class Dispatcher implements DispatcherInterface
if (($c = \count($dispatch)) === 3) { if (($c = \count($dispatch)) === 3) {
/* Handling static functions */ /* Handling static functions */
/** @var \Closure $function */
$function = $dispatch[0] . '::' . $dispatch[2]; $function = $dispatch[0] . '::' . $dispatch[2];
$views[$controller] = $data === null ? $function() : $function(...$data); $views[$controller] = $data === null ? $function() : $function(...$data);

View File

@ -34,6 +34,7 @@ use phpOMS\Uri\UriInterface;
* @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.Superglobals)
* *
* @property HttpHeader $header * @property HttpHeader $header
* @property HttpUri $uri
*/ */
final class HttpRequest extends RequestAbstract final class HttpRequest extends RequestAbstract
{ {

View File

@ -74,7 +74,7 @@ final class FormElementGenerator
$element .= ' ' . $attribute . '="' . $val . '"'; $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) . '"' : ''); $element .= (isset($json['default']) || $value !== null ? ' value="' . ($json['subtype'] === 'datetime' ? (new SmartDateTime($value))->format($json['default']['format']) : $value) . '"' : '');

View File

@ -29,7 +29,7 @@ final class SocketRouter implements RouterInterface
/** /**
* Routes. * Routes.
* *
* @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array{}, pattern?:string}>> * @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array, pattern?:string}>>
* @since 1.0.0 * @since 1.0.0
*/ */
private array $routes = []; private array $routes = [];

View File

@ -40,7 +40,7 @@ final class WebRouter implements RouterInterface
/** /**
* Routes. * Routes.
* *
* @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array{}, pattern?:string}>> * @var array<string, array<int, array{dest:string, verb:int, csrf?:bool, active?:bool, permission:array{module:string, type:int, category:int}, validation?:array, pattern?:string}>>
* @since 1.0.0 * @since 1.0.0
*/ */
private array $routes = []; private array $routes = [];

View File

@ -127,13 +127,13 @@ final class UriFactory
/** /**
* Setup uri builder based on current request * Setup uri builder based on current request
* *
* @param UriInterface $uri Uri * @param HttpUri $uri Uri
* *
* @return void * @return void
* *
* @since 1.0.0 * @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('/scheme', $uri->scheme);
self::setQuery('/host', $uri->host); self::setQuery('/host', $uri->host);

View File

@ -49,13 +49,13 @@ abstract class TwoDAbstract extends CodeAbstract
* *
* @param array $codeArray Code array to render * @param array $codeArray Code array to render
* *
* @return \GdImage * @return null|\GdImage
* *
* @throws \Exception * @throws \Exception
* *
* @since 1.0.0 * @since 1.0.0
*/ */
protected function createImage(array $codeArray) : mixed protected function createImage(array $codeArray) : ?\GdImage
{ {
if (empty($codeArray)) { if (empty($codeArray)) {
return null; return null;

View File

@ -338,7 +338,7 @@ class Markdown
* @var array{}|array{text:string, id:string, level:string} * @var array{}|array{text:string, id:string, level:string}
* @since 1.0.0 * @since 1.0.0
*/ */
protected $contentsListArray = []; protected array $contentsListArray = [];
/** /**
* TOC string after parsing headers * TOC string after parsing headers
@ -346,7 +346,7 @@ class Markdown
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected $contentsListString = ''; protected string $contentsListString = '';
/** /**
* First head level * First head level
@ -362,7 +362,7 @@ class Markdown
* @var bool * @var bool
* @since 1.0.0 * @since 1.0.0
*/ */
protected $isBlacklistInitialized = false; protected bool $isBlacklistInitialized = false;
/** /**
* Header duplicates (same header text) * Header duplicates (same header text)
@ -370,7 +370,7 @@ class Markdown
* @var array<string, int> * @var array<string, int>
* @since 1.0.0 * @since 1.0.0
*/ */
protected $anchorDuplicates = []; protected array $anchorDuplicates = [];
// TOC: end // TOC: end
/** /**
@ -387,7 +387,7 @@ class Markdown
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $currentAbreviation; private string $currentAbbreviation;
/** /**
* Current abbreviation meaning * Current abbreviation meaning
@ -420,7 +420,7 @@ class Markdown
$this->firstHeadLevel = 0; $this->firstHeadLevel = 0;
$this->anchorDuplicates = []; $this->anchorDuplicates = [];
$this->footnoteCount = 0; $this->footnoteCount = 0;
$this->currentAbreviation = ''; $this->currentAbbreviation = '';
$this->currentMeaning = ''; $this->currentMeaning = '';
} }
@ -3514,14 +3514,14 @@ class Markdown
} }
$element['elements'] = self::pregReplaceElements( $element['elements'] = self::pregReplaceElements(
'/\b' . \preg_quote($this->currentAbreviation, '/') . '\b/', '/\b' . \preg_quote($this->currentAbbreviation, '/') . '\b/',
[ [
[ [
'name' => 'abbr', 'name' => 'abbr',
'attributes' => [ 'attributes' => [
'title' => $this->currentMeaning, 'title' => $this->currentMeaning,
], ],
'text' => $this->currentAbreviation, 'text' => $this->currentAbbreviation,
], ],
], ],
$element['text'] $element['text']
@ -3563,7 +3563,7 @@ class Markdown
} }
foreach ($this->definitionData['Abbreviation'] as $abbreviation => $meaning) { foreach ($this->definitionData['Abbreviation'] as $abbreviation => $meaning) {
$this->currentAbreviation = $abbreviation; $this->currentAbbreviation = $abbreviation;
$this->currentMeaning = $meaning; $this->currentMeaning = $meaning;
$inline['element'] = $this->elementApplyRecursiveDepthFirst( $inline['element'] = $this->elementApplyRecursiveDepthFirst(