bug fixes and subscription improvements

This commit is contained in:
Dennis Eichhorn 2023-04-25 01:51:28 +00:00
parent c47d3bb6c1
commit 7c01ac51e9
37 changed files with 474 additions and 384 deletions

View File

@ -15,10 +15,8 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Database;
use phpOMS\Contract\SerializableInterface;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\Column;
use phpOMS\DataStorage\Database\Query\Parameter;
use phpOMS\DataStorage\Database\Query\QueryType;
/**
* Grammar.
@ -139,6 +137,17 @@ abstract class GrammarAbstract
return \substr($queryString, 0, -1) . ';';
}
/**
* Compile post querys.
*
* These are queries, which should be run after the main query (e.g. table alters, trigger definitions etc.)
*
* @param BuilderAbstract $query Builder
*
* @return string[]
*
* @since 1.0.0
*/
public function compilePostQuerys(BuilderAbstract $query) : array
{
return [];

View File

@ -104,21 +104,60 @@ class Grammar extends GrammarAbstract
return $sql;
}
/**
* Compile the select tables.
*
* @param SchemaBuilder $query Query
* @param array $tables Tables
*
* @return string
*
* @since 1.0.0
*/
protected function compileSelectTables(SchemaBuilder $query, array $tables) : string
{
return '';
}
/**
* Compile the select fields from table.
*
* @param SchemaBuilder $query Query
* @param array $table Table
*
* @return string
*
* @since 1.0.0
*/
protected function compileSelectFields(SchemaBuilder $query, string $table) : string
{
return '';
}
/**
* Compile the create fields.
*
* @param SchemaBuilder $query Query
* @param array $fields Fields
*
* @return string
*
* @since 1.0.0
*/
protected function compileCreateFields(SchemaBuilder $query, array $fields) : string
{
return '';
}
/**
* Compile the select tables.
*
* @param SchemaBuilder $query Query
*
* @return string
*
* @since 1.0.0
*/
public function compilePostQueries(BuilderAbstract $query): array
{
return [];

View File

@ -43,6 +43,12 @@ class BaseStringL11n implements \JsonSerializable
*/
public string $name = '';
// @todo: this feels like $name and $type accomplish the same thing
// maybe we can always use $type and remove $name.
// This would require some smart mapper adjustment where the name is part of the l11n model,
// maybe use the path definition in the mapper which is used by arrays (e.g. type/name)
public ?BaseStringL11nType $type = null;
/**
* Ref.
*

View File

@ -0,0 +1,93 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package phpOMS\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace phpOMS\Localization;
/**
* String l11n class.
*
* @package phpOMS\Localization
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class BaseStringL11nType implements \JsonSerializable
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Identifier for the l11n type.
*
* @var string
* @since 1.0.0
*/
public string $title = '';
/**
* Is the l11n type required for an item?
*
* @var bool
* @since 1.0.0
*/
public bool $isRequired = false;
/**
* Constructor.
*
* @param string $title Title
*
* @since 1.0.0
*/
public function __construct(string $title = '')
{
$this->title = $title;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [
'id' => $this->id,
'title' => $this->title,
];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize() : mixed
{
return $this->toArray();
}
}

View File

@ -35,7 +35,7 @@ class LanguageResult implements \JsonSerializable, \IteratorAggregate, \ArrayAcc
/**
* Match values per language
*
* @var float[]
* @var array<int|float, int|float>
* @sicne 1.0.0
*/
private array $result = [];

View File

@ -355,6 +355,20 @@ final class Complex
return new self($this->re * $val, $this->im * $val);
}
/**
* Calculate the magnitude of the complex number
*
* @param int $power Power
*
* @return int|float
*
* @since 1.0.0
*/
public function magnitued(int $power = 2) : int | float
{
return \pow($this->re, $power) + \pow($this->im, $power);
}
/**
* Div opperator
*

View File

@ -0,0 +1,205 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package phpOMS\Math\Optimization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
// https://github.com/PetarV-/Algorithms/blob/master/Mathematical%20Algorithms/Simplex%20Algorithm.cpp
/**
* Simplex class.
*
* @package phpOMS\Math\Optimization
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class Simplex {
private array $function = [];
private string $functionType = '';
private int|float $functionLimit = 0.0;
private array $constraints = [];
private array $constraintsType = [];
private array $constraintsLimit = [];
private array $slackForm = [];
private array $nonbasicSolution = [];
private array $basicSolution = [];
public function setFunction(array $function)
{
}
public function addConstraint(array $function, string $type, float $limit)
{
}
private function pivot(int $x, int $y)
{
}
private function iterateSimplex()
{
}
private function initialize() : bool
{
$k = -1;
$minLimit = -1;
$m = \count($this->constraints);
$n = \count($this->function);
for ($i = 0; $i < $m; ++$i) {
if ($k === -1 || $this->constraintsLimit[$i] < $minLimit) {
$k = $i;
$minLimit = $this->constraintsLimit[$i];
}
}
if ($this->constraintsLimit[$k] >= 0) {
for ($j = 0; $j < $n; ++$j) {
$this->nonbasicSolution[$j] = $j;
}
for ($i = 0; $i < $m; ++$i) {
$this->basicSolution[$i] = $n + $i;
}
return true;
}
// Auxiliary LP
++$n;
for ($j = 0; $j < $n; ++$j) {
$this->nonbasicSolution[$j] = $j;
}
for ($i = 0; $i < $m; ++$i) {
$this->basicSolution[$i] = $n + $i;
}
$oldFunction = $this->function;
$oldLimit = $this->functionLimit;
// Auxiliary function
$this->function[$n - 1] = -1;
$this->functionLimit = 0;
for ($j = 0; $j < $n - 1; ++$j) {
$this->function[$j] = 0;
}
// Auxiliary constraints
for ($i = 0; $i < $m; ++$i) {
$this->constraints[$i][$n - 1] = 1;
}
$this->pivot($k, $n - 1);
// Solve Auxiliary LP
while ($this->iterateSimplex());
if ($this->functionLimit !== 0) {
return false;
}
$zBasic = -1;
for ($i = 0; $i < $m; ++$i) {
if ($this->basicSolution[$i] === $n - 1) {
$zBasic = $i;
break;
}
}
if ($zBasic === -1) {
$this->pivot($zBasic, $n - 1);
}
$zNonBasic = -1;
for ($j = 0; $j < $n; ++$j) {
if ($this->nonbasicSolution[$j] === $n - 1) {
$zNonBasic = $j;
break;
}
}
for ($i = 0; $i < $m; ++$i) {
$this->constraints[$i][$zNonBasic] = $this->constraints[$i][$n - 1];
}
$tmp = $this->nonbasicSolution[$n - 1];
$this->nonbasicSolution[$n - 1] = $this->nonbasicSolution[$zNonBasic];
$this->nonbasicSolution[$zNonBasic] = $tmp;
--$n;
for ($j = 0; $j < $n; ++$j) {
if ($this->nonbasicSolution[$j] > $n) {
--$this->nonbasicSolution[$j];
}
}
for ($i = 0; $i < $m; ++$i) {
if ($this->basicSolution[$i] > $n) {
--$this->basicSolution[$i];
}
}
$this->functionLimit = $oldLimit;
for ($j = 0; $j < $n; ++$j) {
$this->function[$j] = 0;
}
for ($j = 0; $j < $n; ++$j) {
$ok = false;
for ($jj = 0; $jj < $n; ++$jj) {
if ($j === $this->nonbasicSolution[$jj]) {
$this->function[$jj] += $oldFunction[$j];
$ok = true;
break;
}
}
if ($ok) {
continue;
}
for ($i = 0; $i < $m; ++$i) {
if ($j = $this->basicSolution[$i]) {
for ($jj = 0; $jj < $n; ++$jj) {
$this->function[$jj] += $oldFunction[$j] * $this->constraints[$i][$jj];
}
$this->functionLimit += $oldFunction[$j] * $this->constraintsLimit[$i];
break;
}
}
}
return true;
}
public function solve() : array
{
if (!$this->initialize()) {
return [];
}
}
}

View File

@ -415,8 +415,7 @@ final class HttpHeader extends HeaderAbstract
private function generate100() : void
{
$this->set('', 'HTTP/1.0 100 Continue');
$this->set('Status', 'Status: HTTP/1.0 100 Continue');
\http_response_code(100);
$this->set('Status', '100 Continue');
}
/**
@ -429,8 +428,7 @@ final class HttpHeader extends HeaderAbstract
private function generate102() : void
{
$this->set('', 'HTTP/1.0 102 Processing');
$this->set('Status', 'Status: HTTP/1.0 102 Processing');
\http_response_code(102);
$this->set('Status', '102 Processing');
}
/**
@ -443,8 +441,7 @@ final class HttpHeader extends HeaderAbstract
private function generate200() : void
{
$this->set('', 'HTTP/1.0 200 OK');
$this->set('Status', 'Status: HTTP/1.0 200 OK');
\http_response_code(200);
$this->set('Status', '200 OK');
}
/**
@ -457,8 +454,7 @@ final class HttpHeader extends HeaderAbstract
private function generate201() : void
{
$this->set('', 'HTTP/1.0 201 Created');
$this->set('Status', 'Status: HTTP/1.0 201 Created');
\http_response_code(201);
$this->set('Status', '201 Created');
}
/**
@ -471,8 +467,7 @@ final class HttpHeader extends HeaderAbstract
private function generate202() : void
{
$this->set('', 'HTTP/1.0 202 Accepted');
$this->set('Status', 'Status: HTTP/1.0 202 Accepted');
\http_response_code(202);
$this->set('Status', '202 Accepted');
}
/**
@ -485,8 +480,7 @@ final class HttpHeader extends HeaderAbstract
private function generate204() : void
{
$this->set('', 'HTTP/1.0 204 No Content');
$this->set('Status', 'Status: HTTP/1.0 204 No Content');
\http_response_code(204);
$this->set('Status', '204 No Content');
}
/**
@ -499,8 +493,7 @@ final class HttpHeader extends HeaderAbstract
private function generate205() : void
{
$this->set('', 'HTTP/1.0 205 Reset Content');
$this->set('Status', 'Status: HTTP/1.0 205 Reset Content');
\http_response_code(205);
$this->set('Status', '205 Reset Content');
}
/**
@ -513,8 +506,7 @@ final class HttpHeader extends HeaderAbstract
private function generate206() : void
{
$this->set('', 'HTTP/1.0 206 Partial Content');
$this->set('Status', 'Status: HTTP/1.0 206 Partial Content');
\http_response_code(206);
$this->set('Status', '206 Partial Content');
}
/**
@ -527,8 +519,7 @@ final class HttpHeader extends HeaderAbstract
private function generate301() : void
{
$this->set('', 'HTTP/1.0 301 Moved Permanently');
$this->set('Status', 'Status: HTTP/1.0 301 Moved Permanently');
\http_response_code(301);
$this->set('Status', '301 Moved Permanently');
}
/**
@ -541,8 +532,7 @@ final class HttpHeader extends HeaderAbstract
private function generate302() : void
{
$this->set('', 'HTTP/1.0 302 Found');
$this->set('Status', 'Status: HTTP/1.0 302 Found');
\http_response_code(302);
$this->set('Status', '302 Found');
}
/**
@ -555,8 +545,7 @@ final class HttpHeader extends HeaderAbstract
private function generate303() : void
{
$this->set('', 'HTTP/1.0 303 See Other');
$this->set('Status', 'Status: HTTP/1.0 303 See Other');
\http_response_code(303);
$this->set('Status', '303 See Other');
}
/**
@ -569,8 +558,7 @@ final class HttpHeader extends HeaderAbstract
private function generate304() : void
{
$this->set('', 'HTTP/1.0 304 Not Modified');
$this->set('Status', 'Status: HTTP/1.0 304 Not Modified');
\http_response_code(304);
$this->set('Status', '304 Not Modified');
}
/**
@ -583,8 +571,7 @@ final class HttpHeader extends HeaderAbstract
private function generate307() : void
{
$this->set('', 'HTTP/1.0 307 Temporary Redirect');
$this->set('Status', 'Status: HTTP/1.0 307 Temporary Redirect');
\http_response_code(307);
$this->set('Status', '307 Temporary Redirect');
}
/**
@ -597,8 +584,7 @@ final class HttpHeader extends HeaderAbstract
private function generate308() : void
{
$this->set('', 'HTTP/1.0 308 Permanent Redirect');
$this->set('Status', 'Status: HTTP/1.0 308 Permanent Redirect');
\http_response_code(308);
$this->set('Status', '308 Permanent Redirect');
}
/**
@ -611,8 +597,7 @@ final class HttpHeader extends HeaderAbstract
private function generate400() : void
{
$this->set('', 'HTTP/1.0 400 Bad Request');
$this->set('Status', 'Status: HTTP/1.0 400 Bad Request');
\http_response_code(400);
$this->set('Status', '400 Bad Request');
}
/**
@ -625,8 +610,7 @@ final class HttpHeader extends HeaderAbstract
private function generate401() : void
{
$this->set('', 'HTTP/1.0 401 Unauthorized');
$this->set('Status', 'Status: HTTP/1.0 401 Unauthorized');
\http_response_code(401);
$this->set('Status', '401 Unauthorized');
}
/**
@ -639,8 +623,7 @@ final class HttpHeader extends HeaderAbstract
private function generate402() : void
{
$this->set('', 'HTTP/1.0 402 Payment Required');
$this->set('Status', 'Status: HTTP/1.0 402 Payment Required');
\http_response_code(402);
$this->set('Status', '402 Payment Required');
}
/**
@ -653,8 +636,7 @@ final class HttpHeader extends HeaderAbstract
private function generate403() : void
{
$this->set('', 'HTTP/1.0 403 Forbidden');
$this->set('Status', 'Status: HTTP/1.0 403 Forbidden');
\http_response_code(403);
$this->set('Status', '403 Forbidden');
}
/**
@ -667,8 +649,7 @@ final class HttpHeader extends HeaderAbstract
private function generate404() : void
{
$this->set('', 'HTTP/1.0 404 Not Found');
$this->set('Status', 'Status: HTTP/1.0 404 Not Found');
\http_response_code(404);
$this->set('Status', '404 Not Found');
}
/**
@ -681,8 +662,7 @@ final class HttpHeader extends HeaderAbstract
private function generate405() : void
{
$this->set('', 'HTTP/1.0 405 Method Not Allowed');
$this->set('Status', 'Status: HTTP/1.0 405 Method Not Allowed');
\http_response_code(405);
$this->set('Status', '405 Method Not Allowed');
}
/**
@ -695,8 +675,7 @@ final class HttpHeader extends HeaderAbstract
private function generate406() : void
{
$this->set('', 'HTTP/1.0 406 Not acceptable');
$this->set('Status', 'Status: 406 Not acceptable');
\http_response_code(406);
$this->set('Status', '406 Not acceptable');
}
/**
@ -709,8 +688,7 @@ final class HttpHeader extends HeaderAbstract
private function generate407() : void
{
$this->set('', 'HTTP/1.0 407 Proxy Authentication Required');
$this->set('Status', 'Status: HTTP/1.0 407 Proxy Authentication Required');
\http_response_code(407);
$this->set('Status', '407 Proxy Authentication Required');
}
/**
@ -723,8 +701,7 @@ final class HttpHeader extends HeaderAbstract
private function generate408() : void
{
$this->set('', 'HTTP/1.0 408 Request Timeout');
$this->set('Status', 'Status: HTTP/1.0 408 Request Timeout');
\http_response_code(408);
$this->set('Status', '408 Request Timeout');
}
/**
@ -737,8 +714,7 @@ final class HttpHeader extends HeaderAbstract
private function generate409() : void
{
$this->set('', 'HTTP/1.0 409 Conflict');
$this->set('Status', 'Status: HTTP/1.0 409 Conflict');
\http_response_code(409);
$this->set('Status', '409 Conflict');
}
/**
@ -751,8 +727,7 @@ final class HttpHeader extends HeaderAbstract
private function generate410() : void
{
$this->set('', 'HTTP/1.0 410 Gone');
$this->set('Status', 'Status: HTTP/1.0 410 Gone');
\http_response_code(410);
$this->set('Status', '410 Gone');
}
/**
@ -765,8 +740,7 @@ final class HttpHeader extends HeaderAbstract
private function generate411() : void
{
$this->set('', 'HTTP/1.0 411 Length Required');
$this->set('Status', 'Status: HTTP/1.0 411 Length Required');
\http_response_code(411);
$this->set('Status', '411 Length Required');
}
/**
@ -779,8 +753,7 @@ final class HttpHeader extends HeaderAbstract
private function generate412() : void
{
$this->set('', 'HTTP/1.0 412 Precondition Failed');
$this->set('Status', 'Status: HTTP/1.0 412 Precondition Failed');
\http_response_code(412);
$this->set('Status', '412 Precondition Failed');
}
/**
@ -793,8 +766,7 @@ final class HttpHeader extends HeaderAbstract
private function generate413() : void
{
$this->set('', 'HTTP/1.0 413 Request Entity Too Large');
$this->set('Status', 'Status: HTTP/1.0 413 Request Entity Too Large');
\http_response_code(413);
$this->set('Status', '413 Request Entity Too Large');
}
/**
@ -807,8 +779,7 @@ final class HttpHeader extends HeaderAbstract
private function generate414() : void
{
$this->set('', 'HTTP/1.0 414 Request-URI Too Long');
$this->set('Status', 'Status: HTTP/1.0 414 Request-URI Too Long');
\http_response_code(414);
$this->set('Status', '414 Request-URI Too Long');
}
/**
@ -821,8 +792,7 @@ final class HttpHeader extends HeaderAbstract
private function generate415() : void
{
$this->set('', 'HTTP/1.0 415 Unsupported Media Type');
$this->set('Status', 'Status: HTTP/1.0 415 Unsupported Media Type');
\http_response_code(415);
$this->set('Status', '415 Unsupported Media Type');
}
/**
@ -835,8 +805,7 @@ final class HttpHeader extends HeaderAbstract
private function generate416() : void
{
$this->set('', 'HTTP/1.0 416 Requested Range Not Satisfiable');
$this->set('Status', 'Status: HTTP/1.0 416 Requested Range Not Satisfiable');
\http_response_code(416);
$this->set('Status', '416 Requested Range Not Satisfiable');
}
/**
@ -849,8 +818,7 @@ final class HttpHeader extends HeaderAbstract
private function generate417() : void
{
$this->set('', 'HTTP/1.0 417 Expectation Failed');
$this->set('Status', 'Status: HTTP/1.0 417 Expectation Failed');
\http_response_code(417);
$this->set('Status', '417 Expectation Failed');
}
/**
@ -863,8 +831,7 @@ final class HttpHeader extends HeaderAbstract
private function generate421() : void
{
$this->set('', 'HTTP/1.0 421 Misdirected Request');
$this->set('Status', 'Status: HTTP/1.0 421 Misdirected Request');
\http_response_code(421);
$this->set('Status', '421 Misdirected Request');
}
/**
@ -877,8 +844,7 @@ final class HttpHeader extends HeaderAbstract
private function generate422() : void
{
$this->set('', 'HTTP/1.0 422 Unprocessable Entity');
$this->set('Status', 'Status: HTTP/1.0 422 Unprocessable Entity');
\http_response_code(422);
$this->set('Status', '422 Unprocessable Entity');
}
/**
@ -891,8 +857,7 @@ final class HttpHeader extends HeaderAbstract
private function generate423() : void
{
$this->set('', 'HTTP/1.0 423 Locked');
$this->set('Status', 'Status: HTTP/1.0 423 Locked');
\http_response_code(423);
$this->set('Status', '423 Locked');
}
/**
@ -905,8 +870,7 @@ final class HttpHeader extends HeaderAbstract
private function generate424() : void
{
$this->set('', 'HTTP/1.0 424 Failed Dependency');
$this->set('Status', 'Status: HTTP/1.0 424 Failed Dependency');
\http_response_code(424);
$this->set('Status', '424 Failed Dependency');
}
/**
@ -919,8 +883,7 @@ final class HttpHeader extends HeaderAbstract
private function generate425() : void
{
$this->set('', 'HTTP/1.0 425 Too Early');
$this->set('Status', 'Status: HTTP/1.0 425 Too Early');
\http_response_code(425);
$this->set('Status', '425 Too Early');
}
/**
@ -933,8 +896,7 @@ final class HttpHeader extends HeaderAbstract
private function generate426() : void
{
$this->set('', 'HTTP/1.0 426 Upgrade Required');
$this->set('Status', 'Status: HTTP/1.0 426 Upgrade Required');
\http_response_code(426);
$this->set('Status', '426 Upgrade Required');
}
/**
@ -947,8 +909,7 @@ final class HttpHeader extends HeaderAbstract
private function generate428() : void
{
$this->set('', 'HTTP/1.0 428 Precondition Required');
$this->set('Status', 'Status: HTTP/1.0 428 Precondition Required');
\http_response_code(428);
$this->set('Status', '428 Precondition Required');
}
/**
@ -961,8 +922,7 @@ final class HttpHeader extends HeaderAbstract
private function generate429() : void
{
$this->set('', 'HTTP/1.0 429 Too Many Requests');
$this->set('Status', 'Status: HTTP/1.0 429 Too Many Requests');
\http_response_code(429);
$this->set('Status', '429 Too Many Requests');
}
/**
@ -975,8 +935,7 @@ final class HttpHeader extends HeaderAbstract
private function generate431() : void
{
$this->set('', 'HTTP/1.0 431 Request Header Fields Too Large');
$this->set('Status', 'Status: HTTP/1.0 431 Request Header Fields Too Large');
\http_response_code(431);
$this->set('Status', '431 Request Header Fields Too Large');
}
/**
@ -989,8 +948,7 @@ final class HttpHeader extends HeaderAbstract
private function generate451() : void
{
$this->set('', 'HTTP/1.0 451 Unavailable For Legal Reasons');
$this->set('Status', 'Status: HTTP/1.0 451 Unavailable For Legal Reasons');
\http_response_code(451);
$this->set('Status', '451 Unavailable For Legal Reasons');
}
/**
@ -1003,8 +961,7 @@ final class HttpHeader extends HeaderAbstract
private function generate500() : void
{
$this->set('', 'HTTP/1.0 500 Internal Server Error');
$this->set('Status', 'Status: HTTP/1.0 500 Internal Server Error');
\http_response_code(500);
$this->set('Status', '500 Internal Server Error');
}
/**
@ -1017,8 +974,7 @@ final class HttpHeader extends HeaderAbstract
private function generate501() : void
{
$this->set('', 'HTTP/1.0 501 Not Implemented');
$this->set('Status', 'Status: HTTP/1.0 501 Not Implemented');
\http_response_code(501);
$this->set('Status', '501 Not Implemented');
}
/**
@ -1031,8 +987,7 @@ final class HttpHeader extends HeaderAbstract
private function generate502() : void
{
$this->set('', 'HTTP/1.0 502 Bad Gateway');
$this->set('Status', 'Status: HTTP/1.0 502 Bad Gateway');
\http_response_code(502);
$this->set('Status', '502 Bad Gateway');
}
/**
@ -1045,9 +1000,8 @@ final class HttpHeader extends HeaderAbstract
private function generate503() : void
{
$this->set('', 'HTTP/1.0 503 Service Temporarily Unavailable');
$this->set('Status', 'Status: 503 Service Temporarily Unavailable');
$this->set('Status', '503 Service Temporarily Unavailable');
$this->set('Retry-After', 'Retry-After: 300');
\http_response_code(503);
}
/**
@ -1060,8 +1014,7 @@ final class HttpHeader extends HeaderAbstract
private function generate504() : void
{
$this->set('', 'HTTP/1.0 504 Gateway Timeout');
$this->set('Status', 'Status: HTTP/1.0 504 Gateway Timeout');
\http_response_code(504);
$this->set('Status', '504 Gateway Timeout');
}
/**
@ -1074,8 +1027,7 @@ final class HttpHeader extends HeaderAbstract
private function generate507() : void
{
$this->set('', 'HTTP/1.0 507 Insufficient Storage');
$this->set('Status', 'Status: HTTP/1.0 507 Insufficient Storage');
\http_response_code(507);
$this->set('Status', '507 Insufficient Storage');
}
/**
@ -1088,8 +1040,7 @@ final class HttpHeader extends HeaderAbstract
private function generate508() : void
{
$this->set('', 'HTTP/1.0 508 Loop Detected');
$this->set('Status', 'Status: HTTP/1.0 508 Loop Detected');
\http_response_code(508);
$this->set('Status', '508 Loop Detected');
}
/**
@ -1102,8 +1053,7 @@ final class HttpHeader extends HeaderAbstract
private function generate511() : void
{
$this->set('', 'HTTP/1.0 511 Network Authentication Required');
$this->set('Status', 'Status: HTTP/1.0 511 Network Authentication Required');
\http_response_code(511);
$this->set('Status', '511 Network Authentication Required');
}
/**
@ -1116,8 +1066,7 @@ final class HttpHeader extends HeaderAbstract
private function generate598() : void
{
$this->set('', 'HTTP/1.0 598 Network read timeout error');
$this->set('Status', 'Status: HTTP/1.0 598 Network read timeout error');
\http_response_code(598);
$this->set('Status', '598 Network read timeout error');
}
/**
@ -1130,7 +1079,6 @@ final class HttpHeader extends HeaderAbstract
private function generate599() : void
{
$this->set('', 'HTTP/1.0 599 Network connect timeout error');
$this->set('Status', 'Status: HTTP/1.0 599 Network connect timeout error');
\http_response_code(599);
$this->set('Status', '599 Network connect timeout error');
}
}

View File

@ -339,6 +339,10 @@ final class PackageManager
*/
private function authenticate(string $signedHash, string $rawHash) : bool
{
if ($signedHash === '' || $rawHash === '') {
return false;
}
try {
return \sodium_crypto_sign_verify_detached($signedHash, $rawHash, $this->publicKey);
} catch(\Throwable $t) {

View File

@ -69,7 +69,11 @@ final class Guard
if (\is_array($data)) {
$result = [];
foreach ($data as $key => $value) {
if (\is_string($value) || \is_array($value)) {
$result[$key] = self::unslash($value);
} else {
$result[$key] = $value;
}
}
return $result;

View File

@ -771,10 +771,10 @@ class Datamatrix extends TwoDAbstract
} elseif (isset($chr, self::CHARSET['SH2'][$chr])) {
$temp_cw[] = 1; // shift 2
$shiftset = self::CHARSET['SH2'];
} elseif (($enc === self::ENC_C40) && isset(self::CHARSET['S3C'][$chr])) {
} elseif ($enc === self::ENC_C40 && isset(self::CHARSET['S3C'][$chr])) {
$temp_cw[] = 2; // shift 3
$shiftset = self::CHARSET['S3C'];
} elseif (($enc === self::ENC_TXT) && isset(self::CHARSET['S3T'][$chr])) {
} elseif ($enc === self::ENC_TXT && isset(self::CHARSET['S3T'][$chr])) {
$temp_cw[] = 2; // shift 3
$shiftset = self::CHARSET['S3T'];
} else {

View File

@ -214,6 +214,9 @@ final class ImageUtils
$diff = empty($out) ? -1 : $out;
$dst = false;
$red = 0;
$green = 0;
if ($diff !== -1) {
$dst = $diff === 0
? \imagecreatetruecolor($newDim[0], $newDim[1])
@ -246,12 +249,20 @@ final class ImageUtils
for ($j = 0; $j < $newDim[1]; ++$j) {
if ($i >= $imageDim1[0] || $j >= $imageDim1[1]) {
if ($diff === 0) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $green);
} elseif ($diff === 1) {
if ($i >= $imageDim2[0] || $j >= $imageDim2[1]) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $green);
} else {
$color2 = \imagecolorat($src2, $i, $j);
if ($color2 === false) {
continue;
}
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $color2);
}
}
@ -262,12 +273,20 @@ final class ImageUtils
if ($i >= $imageDim2[0] || $j >= $imageDim2[1]) {
if ($diff === 0) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $red);
} elseif ($diff === 1) {
if ($i >= $imageDim1[0] || $j >= $imageDim1[1]) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $red);
} else {
$color1 = \imagecolorat($src1, $i, $j);
if ($color1 === false) {
continue;
}
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $color1);
}
}
@ -279,12 +298,14 @@ final class ImageUtils
$color1 = \imagecolorat($src1, $i, $j);
$color2 = \imagecolorat($src2, $i, $j);
if ($color1 !== $color2 && $color1 !== false && $color2 !== null) {
if ($color1 !== $color2 && $color1 !== false && $color2 !== false) {
++$difference;
if ($diff === 0) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $color2);
} elseif ($diff === 1) {
/** @var \GdImage $dst */
\imagesetpixel($dst, $i, $j, $green);
}
}

View File

@ -102,4 +102,11 @@ class TaskScheduler extends SchedulerAbstract
return $jobs;
}
/**
* {@inheritdoc}
*/
public function reload() : void
{
}
}

View File

@ -41,19 +41,6 @@ final class AccountManagerTest extends \PHPUnit\Framework\TestCase
$this->account->generatePassword('abcd');
}
/**
* @testdox The manager has the expected member variables
* @covers phpOMS\Account\AccountManager<extended>
* @group framework
*/
public function testAttributes() : void
{
self::assertInstanceOf('\phpOMS\Account\AccountManager', $this->manager);
/* Testing members */
self::assertObjectHasAttribute('accounts', $this->manager);
}
/**
* @testdox The manager has the expected default values after initialization
* @covers phpOMS\Account\AccountManager<extended>

View File

@ -43,33 +43,6 @@ final class AccountTest extends \PHPUnit\Framework\TestCase
$this->l11nManager = new L11nManager('Api');
}
/**
* @testdox The account has the expected member variables
* @covers phpOMS\Account\Account<extended>
* @group framework
*/
public function testAttributes() : void
{
$account = new Account();
self::assertInstanceOf('\phpOMS\Account\Account', $account);
/* Testing members */
self::assertObjectHasAttribute('id', $account);
self::assertObjectHasAttribute('name1', $account);
self::assertObjectHasAttribute('name2', $account);
self::assertObjectHasAttribute('name3', $account);
self::assertObjectHasAttribute('email', $account);
self::assertObjectHasAttribute('origin', $account);
self::assertObjectHasAttribute('login', $account);
self::assertObjectHasAttribute('lastActive', $account);
self::assertObjectHasAttribute('createdAt', $account);
self::assertObjectHasAttribute('permissions', $account);
self::assertObjectHasAttribute('groups', $account);
self::assertObjectHasAttribute('type', $account);
self::assertObjectHasAttribute('status', $account);
self::assertObjectHasAttribute('l11n', $account);
}
/**
* @testdox The account has the expected default values after initialization
* @covers phpOMS\Account\Account<extended>

View File

@ -28,26 +28,6 @@ require_once __DIR__ . '/../Autoloader.php';
*/
final class GroupTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox The group has the expected member variables
* @covers phpOMS\Account\Group<extended>
* @group framework
*/
public function testAttributes() : void
{
$group = new Group();
self::assertInstanceOf('\phpOMS\Account\Group', $group);
/* Testing members */
self::assertObjectHasAttribute('id', $group);
self::assertObjectHasAttribute('name', $group);
self::assertObjectHasAttribute('description', $group);
self::assertObjectHasAttribute('members', $group);
self::assertObjectHasAttribute('parents', $group);
self::assertObjectHasAttribute('permissions', $group);
self::assertObjectHasAttribute('status', $group);
}
/**
* @testdox The group has the expected default values after initialization
* @covers phpOMS\Account\Group<extended>

View File

@ -35,18 +35,6 @@ final class AssetManagerTest extends \PHPUnit\Framework\TestCase
$this->manager = new AssetManager();
}
/**
* @testdox The manager has the expected member variables
* @group framework
*/
public function testAttributes() : void
{
self::assertInstanceOf('\phpOMS\Asset\AssetManager', $this->manager);
/* Testing members */
self::assertObjectHasAttribute('assets', $this->manager);
}
/**
* @testdox The manager has the expected default values after initialization
* @group framework

View File

@ -25,20 +25,6 @@ require_once __DIR__ . '/../Autoloader.php';
*/
final class OptionsTraitTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox The option helper has the expected attributes
* @group framework
*/
public function testOptionTraitMembers() : void
{
$class = new class() {
use OptionsTrait;
};
/* Testing members */
self::assertObjectHasAttribute('options', $class);
}
/**
* @testdox The option helper has the expected default values after initialization
* @group framework

View File

@ -85,7 +85,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
public function testMysqlCreateTable() : void
{
$query = new Builder($this->con);
$sql = 'CREATE TABLE IF NOT EXISTS `user_roles` (`user_id` INT NOT NULL AUTO_INCREMENT, `role_id` VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `users` (`ext1_id`), FOREIGN KEY (`role_id`) REFERENCES `roles` (`ext2_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = 'CREATE TABLE IF NOT EXISTS `user_roles` (`user_id` INT AUTO_INCREMENT, `role_id` VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `users` (`ext1_id`), FOREIGN KEY (`role_id`) REFERENCES `roles` (`ext2_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
self::assertEquals(
$sql,
$query->createTable('user_roles')

View File

@ -47,16 +47,6 @@ final class DispatcherTest extends \PHPUnit\Framework\TestCase
$this->app->dispatcher = new Dispatcher($this->app);
}
/**
* @testdox The dispatcher has the expected attributes
* @covers phpOMS\Dispatcher\Dispatcher
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('controllers', $this->app->dispatcher);
}
/**
* @testdox A route can be added and dispatched
* @covers phpOMS\Dispatcher\Dispatcher

View File

@ -35,17 +35,6 @@ final class EventManagerTest extends \PHPUnit\Framework\TestCase
$this->event = new EventManager();
}
/**
* @testdox The event manager has the expected member variables
* @covers phpOMS\Event\EventManager
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('groups', $this->event);
self::assertObjectHasAttribute('callbacks', $this->event);
}
/**
* @testdox The event manager has the expected default values after initialization
* @covers phpOMS\Event\EventManager

View File

@ -44,14 +44,4 @@ final class ISO3166NumEnumTest extends \PHPUnit\Framework\TestCase
self::assertTrue($ok);
}
/**
* @testdox The ISO 3166 enum has only unique values
* @group framework
* @coversNothing
*/
public function testUnique() : void
{
self::assertEquals(ISO3166NumEnum::getConstants(), \array_unique(ISO3166NumEnum::getConstants()));
}
}

View File

@ -37,16 +37,6 @@ final class L11nManagerTest extends \PHPUnit\Framework\TestCase
$this->l11nManager = new L11nManager('Api');
}
/**
* @testdox The localization manager has the expected member variables
* @covers phpOMS\Localization\L11nManager
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('language', $this->l11nManager);
}
/**
* @testdox The localization manager has the expected default values after initialization
* @covers phpOMS\Localization\L11nManager

View File

@ -33,12 +33,7 @@ final class MoneyTest extends \PHPUnit\Framework\TestCase
public function testDefaultMemberVariables() : void
{
$money = new Money(0);
self::assertObjectHasAttribute('thousands', $money);
self::assertObjectHasAttribute('decimal', $money);
self::assertObjectHasAttribute('value', $money);
self::assertGreaterThan(0, Money::MAX_DECIMALS);
self::assertEquals(0, $money->getInt());
}

View File

@ -56,17 +56,6 @@ final class FileLoggerTest extends \PHPUnit\Framework\TestCase
}
}
/**
* @testdox The logger has the expected member variables
* @covers phpOMS\Log\FileLogger
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('fp', $this->log);
self::assertObjectHasAttribute('path', $this->log);
}
/**
* @testdox The logger has the expected default values after initialization
* @covers phpOMS\Log\FileLogger

View File

@ -27,7 +27,7 @@ final class RequestStatusCodeTest extends \PHPUnit\Framework\TestCase
*/
public function testEnumCount() : void
{
self::assertCount(55, RequestStatusCode::getConstants());
self::assertCount(63, RequestStatusCode::getConstants());
}
/**

View File

@ -27,7 +27,7 @@ final class RequestStatusTest extends \PHPUnit\Framework\TestCase
*/
public function testEnumCount() : void
{
self::assertCount(55, RequestStatus::getConstants());
self::assertCount(58, RequestStatus::getConstants());
}
/**

View File

@ -22,22 +22,6 @@ use phpOMS\Model\Message\DomAction;
*/
final class DomTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers phpOMS\Model\Message\Dom
* @group framework
*/
public function testAttributes() : void
{
$obj = new Dom();
self::assertInstanceOf('\phpOMS\Model\Message\Dom', $obj);
/* Testing members */
self::assertObjectHasAttribute('delay', $obj);
self::assertObjectHasAttribute('content', $obj);
self::assertObjectHasAttribute('selector', $obj);
self::assertObjectHasAttribute('action', $obj);
}
/**
* @covers phpOMS\Model\Message\Dom
* @group framework

View File

@ -21,19 +21,6 @@ use phpOMS\Model\Message\FormValidation;
*/
final class FormValidationTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers phpOMS\Model\Message\FormValidation
* @group framework
*/
public function testAttributes() : void
{
$obj = new FormValidation([]);
self::assertInstanceOf('\phpOMS\Model\Message\FormValidation', $obj);
/* Testing members */
self::assertObjectHasAttribute('validation', $obj);
}
/**
* @covers phpOMS\Model\Message\FormValidation
* @group framework

View File

@ -22,23 +22,6 @@ use phpOMS\Model\Message\NotifyType;
*/
final class NotifyTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers phpOMS\Model\Message\Notify
* @group framework
*/
public function testAttributes() : void
{
$obj = new Notify();
self::assertInstanceOf('\phpOMS\Model\Message\Notify', $obj);
/* Testing members */
self::assertObjectHasAttribute('delay', $obj);
self::assertObjectHasAttribute('title', $obj);
self::assertObjectHasAttribute('stay', $obj);
self::assertObjectHasAttribute('message', $obj);
self::assertObjectHasAttribute('level', $obj);
}
/**
* @covers phpOMS\Model\Message\Notify
* @group framework

View File

@ -27,7 +27,7 @@ final class NotifyTypeTest extends \PHPUnit\Framework\TestCase
*/
public function testEnumCount() : void
{
self::assertCount(5, NotifyType::getConstants());
self::assertCount(7, NotifyType::getConstants());
}
/**
@ -45,10 +45,10 @@ final class NotifyTypeTest extends \PHPUnit\Framework\TestCase
*/
public function testEnums() : void
{
self::assertEquals(0, NotifyType::BINARY);
self::assertEquals(1, NotifyType::INFO);
self::assertEquals(2, NotifyType::WARNING);
self::assertEquals(3, NotifyType::ERROR);
self::assertEquals(4, NotifyType::FATAL);
self::assertEquals('binary', NotifyType::BINARY);
self::assertEquals('info', NotifyType::INFO);
self::assertEquals('warning', NotifyType::WARNING);
self::assertEquals('error', NotifyType::ERROR);
self::assertEquals('fatal', NotifyType::FATAL);
}
}

View File

@ -21,21 +21,6 @@ use phpOMS\Model\Message\Redirect;
*/
final class RedirectTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers phpOMS\Model\Message\Redirect
* @group framework
*/
public function testAttributes() : void
{
$obj = new Redirect('');
self::assertInstanceOf('\phpOMS\Model\Message\Redirect', $obj);
/* Testing members */
self::assertObjectHasAttribute('uri', $obj);
self::assertObjectHasAttribute('delay', $obj);
self::assertObjectHasAttribute('new', $obj);
}
/**
* @covers phpOMS\Model\Message\Redirect
* @group framework

View File

@ -21,19 +21,6 @@ use phpOMS\Model\Message\Reload;
*/
final class ReloadTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers phpOMS\Model\Message\Reload
* @group framework
*/
public function testAttributes() : void
{
$obj = new Reload();
self::assertInstanceOf('\phpOMS\Model\Message\Reload', $obj);
/* Testing members */
self::assertObjectHasAttribute('delay', $obj);
}
/**
* @covers phpOMS\Model\Message\Reload
* @group framework

View File

@ -57,22 +57,6 @@ final class ModuleManagerTest extends \PHPUnit\Framework\TestCase
$this->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
}
/**
* @testdox The module manager has the expected attributes
* @covers phpOMS\Module\ModuleManager
* @group framework
*/
public function testAttributes() : void
{
self::assertInstanceOf('\phpOMS\Module\ModuleManager', $this->moduleManager);
self::assertObjectHasAttribute('running', $this->moduleManager);
self::assertObjectHasAttribute('installed', $this->moduleManager);
self::assertObjectHasAttribute('active', $this->moduleManager);
self::assertObjectHasAttribute('all', $this->moduleManager);
self::assertObjectHasAttribute('uriLoad', $this->moduleManager);
}
/**
* @testdox Unknown modules return a null module
* @covers phpOMS\Module\ModuleManager

View File

@ -34,18 +34,6 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
$this->address = new Address();
}
/**
* @testdox The address has the expected attributes
* @covers phpOMS\Stdlib\Base\Address
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('recipient', $this->address);
self::assertObjectHasAttribute('fao', $this->address);
self::assertObjectHasAttribute('location', $this->address);
}
/**
* @testdox The address has the expected default values after initialization
* @covers phpOMS\Stdlib\Base\Address

View File

@ -34,21 +34,6 @@ final class LocationTest extends \PHPUnit\Framework\TestCase
$this->location = new Location();
}
/**
* @testdox The location has the expected attributes
* @covers phpOMS\Stdlib\Base\Location
* @group framework
*/
public function testAttributes() : void
{
self::assertObjectHasAttribute('postal', $this->location);
self::assertObjectHasAttribute('city', $this->location);
self::assertObjectHasAttribute('country', $this->location);
self::assertObjectHasAttribute('address', $this->location);
self::assertObjectHasAttribute('state', $this->location);
self::assertObjectHasAttribute('geo', $this->location);
}
/**
* @testdox The location has the expected default values after initialization
* @covers phpOMS\Stdlib\Base\Location