mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 21:28:40 +00:00
phpstan/array typehint fixes
This commit is contained in:
parent
8d48e3b317
commit
6c917b5486
|
|
@ -60,10 +60,10 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
/**
|
/**
|
||||||
* Database data.
|
* Database data.
|
||||||
*
|
*
|
||||||
* @var array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string}
|
* @var array{db:string, database:string, prefix:string}|array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string}
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected array $dbdata = [];
|
protected array $dbdata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database type.
|
* Database type.
|
||||||
|
|
@ -146,7 +146,7 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
*/
|
*/
|
||||||
public function getPort() : int
|
public function getPort() : int
|
||||||
{
|
{
|
||||||
return (int) $this->dbdata['port'] ?? 0;
|
return (int) ($this->dbdata['port'] ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -178,7 +178,9 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
* Connect to database
|
||||||
|
*
|
||||||
|
* @param null|array{db:string, database:string, prefix:string}|array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ final class ConnectionFactory
|
||||||
*
|
*
|
||||||
* Overwrites current connection if existing
|
* Overwrites current connection if existing
|
||||||
*
|
*
|
||||||
* @param array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
* @param array{db:string, database:string, prefix:string}|array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
||||||
*
|
*
|
||||||
* @return ConnectionAbstract
|
* @return ConnectionAbstract
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ final class SQLiteConnection extends ConnectionAbstract
|
||||||
*
|
*
|
||||||
* Creates the database object and overwrites all default values.
|
* Creates the database object and overwrites all default values.
|
||||||
*
|
*
|
||||||
* @param array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
* @param array{db:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -58,7 +58,13 @@ final class SQLiteConnection extends ConnectionAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* Connect to database
|
||||||
|
*
|
||||||
|
* @param null|array{db:string, database:string, prefix:string} $dbdata the basic database information for establishing a connection
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function connect(array $dbdata = null) : void
|
public function connect(array $dbdata = null) : void
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ final class SqlServerConnection extends ConnectionAbstract
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
||||||
$this->dbdata = $dbdata ?? $this->dbdata;
|
$this->dbdata = $dbdata ?? $this->dbdata;
|
||||||
$this->prefix = $dbdata['prefix'];
|
|
||||||
|
|
||||||
if (!isset($this->dbdata['db'], $this->dbdata['host'], $this->dbdata['port'], $this->dbdata['database'], $this->dbdata['login'], $this->dbdata['password'])
|
if (!isset($this->dbdata['db'], $this->dbdata['host'], $this->dbdata['port'], $this->dbdata['database'], $this->dbdata['login'], $this->dbdata['password'])
|
||||||
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
|| !DatabaseType::isValidValue($this->dbdata['db'])
|
||||||
|
|
@ -74,6 +73,9 @@ final class SqlServerConnection extends ConnectionAbstract
|
||||||
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
throw new InvalidConnectionConfigException((string) \json_encode($this->dbdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->close();
|
||||||
|
$this->prefix = $dbdata['prefix'] ?? '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->con = new \PDO('sqlsrv:Server=' . $this->dbdata['host'] . ',' . $this->dbdata['port'] . ';Database=' . $this->dbdata['database'] . ';ConnectionPooling=0', $this->dbdata['login'], $this->dbdata['password']);
|
$this->con = new \PDO('sqlsrv:Server=' . $this->dbdata['host'] . ',' . $this->dbdata['port'] . ';Database=' . $this->dbdata['database'] . ';ConnectionPooling=0', $this->dbdata['login'], $this->dbdata['password']);
|
||||||
$this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
$this->con->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ final class DatabasePool implements DataStoragePoolInterface
|
||||||
/**
|
/**
|
||||||
* Create database.
|
* Create database.
|
||||||
*
|
*
|
||||||
* @param string $key Database key
|
* @param string $key Database key
|
||||||
* @param array $config Database config data
|
* @param array{db:string, database:string, prefix:string}|array{db:string, host:string, port:int, login:string, password:string, database:string, prefix:string} $config Database config data
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ final class Currency
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private string $number = 0;
|
private string $number = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency subunits.
|
* Currency subunits.
|
||||||
|
|
@ -78,7 +78,7 @@ final class Currency
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private string $decimals = 0;
|
private string $decimals = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currency countries.
|
* Currency countries.
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ final class L11nManager
|
||||||
/**
|
/**
|
||||||
* Language.
|
* Language.
|
||||||
*
|
*
|
||||||
* @var array<string, string>
|
* @var array<string, array<int|string, array<string, string>>>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $language = [];
|
private array $language = [];
|
||||||
|
|
@ -128,7 +128,7 @@ final class L11nManager
|
||||||
* @param string $language Language iso code
|
* @param string $language Language iso code
|
||||||
* @param string $module Module name
|
* @param string $module Module name
|
||||||
*
|
*
|
||||||
* @return array<string, string>|array<string, array<string, string>>
|
* @return array<int|string, array<string, string>>|array<string, string>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ final class FileLogger implements LoggerInterface
|
||||||
$temp = \explode(' ', \microtime());
|
$temp = \explode(' ', \microtime());
|
||||||
$mtime = ((float) $temp[1]) + ((float) $temp[0]);
|
$mtime = ((float) $temp[1]) + ((float) $temp[0]);
|
||||||
|
|
||||||
self::$timings[$id] = ['start' => $mtime];
|
self::$timings[$id] = ['start' => $mtime, 'end' => 0.0, 'time' => 0.0];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param array[] $coord 2 Dimensional coordinate array where the indices are x and y
|
* @param array<int, array{x:int|float, y:int|float}> $coord 2 Dimensional coordinate array where the indices are x and y
|
||||||
*
|
*
|
||||||
* @example Polygon([['x' => 1, 'y' => 2], ['x' => ...], ...])
|
* @example Polygon([['x' => 1, 'y' => 2], ['x' => ...], ...])
|
||||||
*
|
*
|
||||||
|
|
@ -59,7 +59,7 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Point polygon relative position
|
* Point polygon relative position
|
||||||
*
|
*
|
||||||
* @param array<string, float|int> $point Point location
|
* @param array{x:int|float, y:int|float} $point Point location
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
|
|
@ -76,8 +76,8 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Point polygon relative position
|
* Point polygon relative position
|
||||||
*
|
*
|
||||||
* @param array<string, float|int> $point Point location
|
* @param array{x:int|float, y:int|float} $point Point location
|
||||||
* @param array<int, array<string, float|int>> $polygon Polygon definition
|
* @param array<int, array{x:int|float, y:int|float}> $polygon Polygon definition
|
||||||
*
|
*
|
||||||
* @return int -1 inside polygon 0 on vertice 1 outside
|
* @return int -1 inside polygon 0 on vertice 1 outside
|
||||||
*
|
*
|
||||||
|
|
@ -141,8 +141,8 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Is point on vertex?
|
* Is point on vertex?
|
||||||
*
|
*
|
||||||
* @param array<string, float|int> $point Point location
|
* @param array{x:int|float, y:int|float} $point Point location
|
||||||
* @param array<int, array<string, float|int>> $polygon Polygon definition
|
* @param array<int, array{x:int|float, y:int|float}> $polygon Polygon definition
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
@ -239,7 +239,7 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Get barycenter
|
* Get barycenter
|
||||||
*
|
*
|
||||||
* @return array<string, float|int>
|
* @return array{x:int|float, y:int|float}
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ final class Head implements RenderableInterface
|
||||||
/**
|
/**
|
||||||
* Assets bound to this page instance.
|
* Assets bound to this page instance.
|
||||||
*
|
*
|
||||||
* @var array<string, array<type:int, attributes:array>>
|
* @var array|array<string, array{type:int, attributes:array}>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $assets = [];
|
private array $assets = [];
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ final class ModuleManager
|
||||||
/**
|
/**
|
||||||
* Installed modules.
|
* Installed modules.
|
||||||
*
|
*
|
||||||
* @var array<string, array>
|
* @var array<string, InfoManager>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $installed = [];
|
private array $installed = [];
|
||||||
|
|
@ -264,7 +264,7 @@ final class ModuleManager
|
||||||
$content = \file_get_contents($path);
|
$content = \file_get_contents($path);
|
||||||
$json = \json_decode($content === false ? '[]' : $content, true);
|
$json = \json_decode($content === false ? '[]' : $content, true);
|
||||||
|
|
||||||
$this->all[$json['name']['internal']] = $json === false ? [] : $json;
|
$this->all[(string) ($json['name']['internal'] ?? '?')] = $json === false ? [] : $json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,7 +288,7 @@ final class ModuleManager
|
||||||
*
|
*
|
||||||
* @param bool $useCache Use Cache
|
* @param bool $useCache Use Cache
|
||||||
*
|
*
|
||||||
* @return array<string, array>
|
* @return array<string, InfoManager>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -311,10 +311,7 @@ final class ModuleManager
|
||||||
// throw new PathException($path);
|
// throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = \file_get_contents($path);
|
$this->installed[$module] = $this->loadInfo($module);
|
||||||
$json = \json_decode($content === false ? '[]' : $content, true);
|
|
||||||
|
|
||||||
$this->installed[$json['name']['internal']] = $json === false ? [] : $json;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,13 +231,13 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* Delete element.
|
* Delete element.
|
||||||
*
|
*
|
||||||
* @param mixed $id Element to delete
|
* @param int $id Element to delete
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function delete($id) : bool
|
public function delete(int $id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->queue[$id])) {
|
if (isset($this->queue[$id])) {
|
||||||
unset($this->queue[$id]);
|
unset($this->queue[$id]);
|
||||||
|
|
@ -251,14 +251,14 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* Set element priority.
|
* Set element priority.
|
||||||
*
|
*
|
||||||
* @param mixed $id Element ID
|
* @param int $id Element ID
|
||||||
* @param float $priority Element priority
|
* @param float $priority Element priority
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setPriority($id, float $priority) : void
|
public function setPriority(int $id, float $priority) : void
|
||||||
{
|
{
|
||||||
if ($this->type === PriorityMode::FIFO || $this->type === PriorityMode::LIFO) {
|
if ($this->type === PriorityMode::FIFO || $this->type === PriorityMode::LIFO) {
|
||||||
$this->queue[$id]['priority'] = $priority;
|
$this->queue[$id]['priority'] = $priority;
|
||||||
|
|
@ -279,13 +279,13 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* Get element
|
* Get element
|
||||||
*
|
*
|
||||||
* @param mixed $id Element ID
|
* @param int $id Element ID
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function get($id) : array
|
public function get(int $id) : array
|
||||||
{
|
{
|
||||||
return $this->queue[$id] ?? [];
|
return $this->queue[$id] ?? [];
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,7 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* Get element
|
* Get element
|
||||||
*
|
*
|
||||||
* @return array<array>
|
* @return array<int, array{data:mixed, priority:float}>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ final class Storage
|
||||||
/**
|
/**
|
||||||
* Registered storage.
|
* Registered storage.
|
||||||
*
|
*
|
||||||
* @var array<string, StorageAbstract|string>
|
* @var array<string, StorageAbstract|string|ContainerInterface>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static array $registered = [];
|
private static array $registered = [];
|
||||||
|
|
@ -87,8 +87,8 @@ final class Storage
|
||||||
/**
|
/**
|
||||||
* Register storage environment.
|
* Register storage environment.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the environment
|
* @param string $name Name of the environment
|
||||||
* @param StorageAbstract|string $class Class to register. This can be either a namespace path, a anonymous class or storage implementation.
|
* @param ContainerInterface|StorageAbstract|string $class Class to register. This can be either a namespace path, a anonymous class or storage implementation.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ final class Dictionary
|
||||||
$this->min = -1;
|
$this->min = -1;
|
||||||
$this->max = -1;
|
$this->max = -1;
|
||||||
|
|
||||||
|
/** @var array<int, array<int, string|array>> $count */
|
||||||
$count = [];
|
$count = [];
|
||||||
while (isset($source[0])) {
|
while (isset($source[0])) {
|
||||||
$count[] = [\substr_count($source, $source[0]), $source[0]];
|
$count[] = [\substr_count($source, $source[0]), $source[0]];
|
||||||
|
|
@ -98,8 +99,8 @@ final class Dictionary
|
||||||
/**
|
/**
|
||||||
* Fill dictionary.
|
* Fill dictionary.
|
||||||
*
|
*
|
||||||
* @param array<int, array<int, string>> $entry Source data to generate dictionary from
|
* @param array<int, array<int, string|array>> $entry Source data to generate dictionary from
|
||||||
* @param string $value Dictionary value
|
* @param string $value Dictionary value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class Commit
|
||||||
/**
|
/**
|
||||||
* Files.
|
* Files.
|
||||||
*
|
*
|
||||||
* @var array<string, array{old:string, new:string}>
|
* @var array<string, array<int, array{old:string, new:string}>>
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private array $files = [];
|
private array $files = [];
|
||||||
|
|
@ -165,7 +165,7 @@ class Commit
|
||||||
/**
|
/**
|
||||||
* Get files of this commit.
|
* Get files of this commit.
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return array<string, array<int, array{old:string, new:string}>>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user