mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
fix type hinting
This commit is contained in:
parent
0acef08f09
commit
34cc6325da
|
|
@ -94,18 +94,18 @@ class Account implements ArrayableInterface, \JsonSerializable
|
|||
/**
|
||||
* Last activity.
|
||||
*
|
||||
* @var null|\DateTime
|
||||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?\DateTime $lastActive = null;
|
||||
protected \DateTime $lastActive;
|
||||
|
||||
/**
|
||||
* Last activity.
|
||||
*
|
||||
* @var null|\DateTime
|
||||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?\DateTime $createdAt = null;
|
||||
protected \DateTime $createdAt;
|
||||
|
||||
/**
|
||||
* Groups.
|
||||
|
|
@ -145,7 +145,7 @@ class Account implements ArrayableInterface, \JsonSerializable
|
|||
* @var Localization
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?Localization $l11n = null;
|
||||
protected Localization $l11n;
|
||||
|
||||
use PermissionHandlingTrait;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ class BucketSort
|
|||
$buckets = [];
|
||||
$M = $list[0]::max($list);
|
||||
|
||||
if ($bucketCount < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($list as $element) {
|
||||
$buckets[(int) \floor(($bucketCount - 1) * $element->getValue() / $M)][] = $element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,6 @@ class CycleSort implements SortInterface
|
|||
}
|
||||
}
|
||||
|
||||
return $order === SortOrder::ASC ? $list : \array_reverse($list, false);;
|
||||
return $order === SortOrder::ASC ? $list : \array_reverse($list, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package phpOMS\Algorithm\Sort;
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Algorithm\Sort;
|
||||
|
||||
/**
|
||||
* FlashSort class.
|
||||
*
|
||||
* @package phpOMS\Algorithm\Sort;
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class FlashSort implements SortInterface
|
||||
{
|
||||
public static function sort(array $list, int $order = SortOrder::ASC) : array
|
||||
{
|
||||
$n = \count($list);
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
$k = 0;
|
||||
$m = 0.43 * $n;
|
||||
|
||||
if ($m > 262143) {
|
||||
$m = 262143;
|
||||
}
|
||||
|
||||
$l = \array_fill(0, $n, 0);
|
||||
$anmin = $list[0];
|
||||
$anmax = $anmin;
|
||||
$nmax = 0;
|
||||
$nmove = 0;
|
||||
$lk = 0;
|
||||
|
||||
$kmin = null;
|
||||
$kmax = null;
|
||||
|
||||
// todo: replace >>> with Numeric::uRightShift
|
||||
|
||||
for ($i = 0; (($i += 2) - $n) >>> 31;) {
|
||||
if ((($kmax = $list[$i - 1])->getValue() - ($kmin = $list[$i])->getValue()) >>> 31) {
|
||||
if (($kmax->getValue() - $anmin->getValue()) >>> 31) {
|
||||
$anmin = $list[$i - 1];
|
||||
}
|
||||
|
||||
if (($anmax->getValue() - $kmin->getValue()) >>> 31) {
|
||||
$anmax = $list[$i];
|
||||
$nmax = $i;
|
||||
}
|
||||
} else {
|
||||
if (($kmin->getValue() - $anmin->getValue()) >>> 31) {
|
||||
$anmin = $list[$i];
|
||||
}
|
||||
|
||||
if (($anmax->getValue() - $kmin->getValue()) >>> 31) {
|
||||
$anmax = $list[$i - 1];
|
||||
$nmax = $i - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((--$i - $n) >>> 31) {
|
||||
if ((($k = $list[$i])->getValue() - $anmin->getValue()) >>> 31) {
|
||||
$anmin = $list[$i];
|
||||
} elseif (($anmax->getValue() - $k->getValue()) >>> 31) {
|
||||
$anmax = $list[$i];
|
||||
$nmax = $i;
|
||||
}
|
||||
}
|
||||
|
||||
if ($anmin->getValue() === $anmax->getValue()) {
|
||||
return $list;
|
||||
}
|
||||
|
||||
$c1 = (($m - 1) << 13) / ($anmax->getValue() - $anmin->getValue());
|
||||
|
||||
for ($i = -1; (++$i - $n) >>> 31;) {
|
||||
++$l[($c1 * ($list[$i]->getValue() - $anmin->getValue())) >> 13];
|
||||
}
|
||||
|
||||
$lk = $l[0];
|
||||
for ($k = 0; (++$k - $m) >>> 31;) {
|
||||
$lk = ($l[$k] += $lk);
|
||||
}
|
||||
|
||||
$hold = $anmax;
|
||||
$list[$nmax] = $list[0];
|
||||
$list[0] = $hold;
|
||||
|
||||
$flash = null;
|
||||
$j = 0;
|
||||
$k = ($m - 1);
|
||||
$i = ($n - 1);
|
||||
|
||||
while (($nmove - $i) >>> 31) {
|
||||
while ($j !== $lk) {
|
||||
$k = ($c1 * ($list[(++$j)]->getValue() - $anmin->getValue())) >> 13;
|
||||
}
|
||||
|
||||
$flash = $a[$j];
|
||||
$lk = $l[$k];
|
||||
|
||||
while ($j !== $lk)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,18 +14,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace phpOMS;
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Localization\L11nManager;
|
||||
use Model\CoreSettings;
|
||||
use phpOMS\Router\Router;
|
||||
use phpOMS\DataStorage\Session\SessionInterface;
|
||||
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||
use phpOMS\Log\FileLogger;
|
||||
use phpOMS\Event\EventManager;
|
||||
use phpOMS\Module\ModuleManager;
|
||||
use phpOMS\Dispatcher\Dispatcher;
|
||||
use phpOMS\DataStorage\Cache\CachePool;
|
||||
use Model\CoreSettings;
|
||||
use phpOMS\Event\EventManager;
|
||||
use phpOMS\Account\AccountManager;
|
||||
use phpOMS\Log\FileLogger;
|
||||
use phpOMS\Localization\L11nManager;
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\DataStorage\Cache\CachePool;
|
||||
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Application class.
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ final class EventManager implements \Countable
|
|||
/**
|
||||
* Dispatcher.
|
||||
*
|
||||
* @var DispatcherInterface|Object<dispatch>
|
||||
* @var DispatcherInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private ?DispatcherInterface $dispatcher = null;
|
||||
private DispatcherInterface $dispatcher;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ final class Request extends RequestAbstract
|
|||
*/
|
||||
private function init() : void
|
||||
{
|
||||
if ($this->uri === null) {
|
||||
if (!isset($this->uri)) {
|
||||
$this->initCurrentRequest();
|
||||
$this->lock();
|
||||
$this->cleanupGlobals();
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ abstract class RequestAbstract implements MessageInterface
|
|||
/**
|
||||
* Uri.
|
||||
*
|
||||
* @var null|UriInterface
|
||||
* @var UriInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?UriInterface $uri = null;
|
||||
protected UriInterface $uri;
|
||||
|
||||
/**
|
||||
* Request method.
|
||||
|
|
@ -85,10 +85,10 @@ abstract class RequestAbstract implements MessageInterface
|
|||
/**
|
||||
* Request header.
|
||||
*
|
||||
* @var null|HeaderAbstract
|
||||
* @var HeaderAbstract
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?HeaderAbstract $header = null;
|
||||
protected HeaderAbstract $header;
|
||||
|
||||
/**
|
||||
* Get request uri.
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ abstract class ResponseAbstract implements MessageInterface, \JsonSerializable
|
|||
/**
|
||||
* Header.
|
||||
*
|
||||
* @var null|HeaderAbstract
|
||||
* @var HeaderAbstract
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?HeaderAbstract $header = null;
|
||||
protected HeaderAbstract $header;
|
||||
|
||||
/**
|
||||
* Get response by ID.
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ class Head implements RenderableInterface
|
|||
/**
|
||||
* Page meta.
|
||||
*
|
||||
* @var null|Meta
|
||||
* @var Meta
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private ?Meta $meta = null;
|
||||
private Meta $meta;
|
||||
|
||||
/**
|
||||
* html style.
|
||||
|
|
|
|||
59
tests/Algorithm/PathFinding/JumpPointSearchTest.php
Normal file
59
tests/Algorithm/PathFinding/JumpPointSearchTest.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\tests\Algorithm\Sort;
|
||||
|
||||
use phpOMS\Algorithm\PathFinding\Grid;
|
||||
use phpOMS\Algorithm\PathFinding\MovementType;
|
||||
use phpOMS\Algorithm\PathFinding\HeuristicType;
|
||||
use phpOMS\Algorithm\PathFinding\JumpPointNode;
|
||||
use phpOMS\Algorithm\PathFinding\JumpPointSearch;
|
||||
|
||||
require_once __DIR__ . '/../../Autoloader.php';
|
||||
|
||||
/**
|
||||
* @testdox phpOMS\tests\Algorithm\PathFinding: jump point search test
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class JumpPointSearchTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private array $gridArray = [
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
||||
[0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 9, 0, 0, 0, 0,],
|
||||
[0, 0, 1, 0, 9, 0, 0, 0, 0, 0, 9, 0, 9, 9, 9,],
|
||||
[0, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0,],
|
||||
[0, 0, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 9, 9, 9, 9, 0,],
|
||||
[0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 9, 9, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 9, 2, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 9, 9, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
||||
[0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
||||
];
|
||||
|
||||
public function testPathFinding() : void
|
||||
{
|
||||
$grid = Grid::createGridFromArray($this->gridArray, JumpPointNode::class);
|
||||
$path = JumpPointSearch::findPath(
|
||||
2, 5,
|
||||
11, 11,
|
||||
$grid, HeuristicType::EUCLIDEAN, MovementType::DIAGONAL
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user