mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-05 12:08:42 +00:00
PhpStan fixes
This commit is contained in:
parent
5bfba4b202
commit
a95b0ea026
|
|
@ -420,7 +420,8 @@ class Grammar extends GrammarAbstract
|
||||||
* Compile on.
|
* Compile on.
|
||||||
*
|
*
|
||||||
* @param Builder $query Builder
|
* @param Builder $query Builder
|
||||||
* @param array $joins Joins
|
* @param array $ons On values
|
||||||
|
* @param bool $first Is first on element
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -158,22 +158,25 @@ final class Localization
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (\stripos($file, $langCode) === 0) {
|
if (\stripos($file, $langCode) === 0) {
|
||||||
$this->importLocale(
|
$fileContent = \file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/' . $file);
|
||||||
\json_decode(
|
|
||||||
\file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/' . $file),
|
if ($fileContent === false) {
|
||||||
true
|
return;
|
||||||
)
|
}
|
||||||
);
|
|
||||||
|
$this->importLocale(\json_decode($fileContent, true));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->importLocale(
|
$fileContent = \file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/en_US.json');
|
||||||
\json_decode(
|
|
||||||
\file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/en_US.json'),
|
if ($fileContent === false) {
|
||||||
true
|
return;
|
||||||
)
|
}
|
||||||
);
|
|
||||||
|
$this->importLocale(\json_decode($fileContent, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,8 @@ final class Polygon implements D2ShapeInterface
|
||||||
/**
|
/**
|
||||||
* Point polygon relative position
|
* Point polygon relative position
|
||||||
*
|
*
|
||||||
* @param array<string, int|float> $point Point location
|
* @param array<string, int|float> $point Point location
|
||||||
* @param array<int, array<string, int|float> $polygon Polygon definition
|
* @param array<int, array<string, 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, int|float> $point Point location
|
* @param array<string, int|float> $point Point location
|
||||||
* @param array<int, array<string, int|float> $polygon Polygon definition
|
* @param array<int, array<string, int|float>> $polygon Polygon definition
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
public function setMatrix(array $matrix) : Matrix
|
public function setMatrix(array $matrix) : Matrix
|
||||||
{
|
{
|
||||||
$this->m = \count($matrix);
|
$this->m = \count($matrix);
|
||||||
$this->n = \count($matrix[0] ?? 1);
|
$this->n = \count($matrix[0] ?? [1]);
|
||||||
$this->matrix = $matrix;
|
$this->matrix = $matrix;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ final class Integer
|
||||||
*
|
*
|
||||||
* @param int $value Integer to factorize
|
* @param int $value Integer to factorize
|
||||||
*
|
*
|
||||||
* @return array<int>
|
* @return array<float|int>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,7 @@ final class MeasureOfDispersion
|
||||||
--$count;
|
--$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var int $count */
|
||||||
$count /= 2;
|
$count /= 2;
|
||||||
|
|
||||||
\sort($x);
|
\sort($x);
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,9 @@ class ChiSquaredDistribution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = \key(\end(self::TABLE[$df]));
|
$tableCopy = self::TABLE[$df];
|
||||||
$p = 1 - ($p ?? ($key === false ? 1 : (float) $key));
|
$key = \key(\end($tableCopy));
|
||||||
|
$p = 1 - ($p ?? ($key === false ? 1 : (float) $key));
|
||||||
|
|
||||||
return ['P' => $p, 'H0' => ($p > $significance), 'df' => $df];
|
return ['P' => $p, 'H0' => ($p > $significance), 'df' => $df];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,12 +168,8 @@ final class Request extends RequestAbstract
|
||||||
return 'EN';
|
return 'EN';
|
||||||
}
|
}
|
||||||
|
|
||||||
$components = \explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
$components = \explode(';', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
|
$locals = \stripos($components[0], ',') !== false ? $locals = \explode(',', $components[0]) : $components;
|
||||||
if (\stripos($components[0], ',') !== false) {
|
|
||||||
$locals = \explode(',', $components[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$firstLocalComponents = \explode('-', $locals[0]);
|
$firstLocalComponents = \explode('-', $locals[0]);
|
||||||
|
|
||||||
return $firstLocalComponents[0];
|
return $firstLocalComponents[0];
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,8 @@ final class ModuleManager
|
||||||
$files = $this->getUriLoad($request);
|
$files = $this->getUriLoad($request);
|
||||||
|
|
||||||
$lang = [];
|
$lang = [];
|
||||||
if (isset($files[5])) {
|
if (isset($files['5'])) {
|
||||||
foreach ($files[5] as $module) {
|
foreach ($files['5'] as $module) {
|
||||||
$lang[] = '/Modules/' . $module['module_load_from'] . '/Theme/' . $this->app->appName . '/Lang/' . $module['module_load_file'];
|
$lang[] = '/Modules/' . $module['module_load_from'] . '/Theme/' . $this->app->appName . '/Lang/' . $module['module_load_file'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -689,8 +689,8 @@ final class ModuleManager
|
||||||
$files = $this->getUriLoad($request);
|
$files = $this->getUriLoad($request);
|
||||||
$modules = [];
|
$modules = [];
|
||||||
|
|
||||||
if (isset($files[4])) {
|
if (isset($files['4'])) {
|
||||||
foreach ($files[4] as $module) {
|
foreach ($files['4'] as $module) {
|
||||||
$modules[] = $module['module_load_file'];
|
$modules[] = $module['module_load_file'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,8 @@ final class Router
|
||||||
/**
|
/**
|
||||||
* Route request.
|
* Route request.
|
||||||
*
|
*
|
||||||
* @param string|RequestAbstract $request Request to route
|
* @param string $request Request to route
|
||||||
* @param int $verb Route verb
|
* @param int $verb Route verb
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class Edge
|
||||||
/**
|
/**
|
||||||
* Is graph/edge directed
|
* Is graph/edge directed
|
||||||
*
|
*
|
||||||
* @var Node
|
* @var bool
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $isDirected = false;
|
private $isDirected = false;
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* Pop element.
|
* Pop element.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -687,7 +687,7 @@ class Repository
|
||||||
* @param \DateTime $start Start date
|
* @param \DateTime $start Start date
|
||||||
* @param \DateTime $end End date
|
* @param \DateTime $end End date
|
||||||
*
|
*
|
||||||
* @return array<string>
|
* @return array<Author>
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -747,7 +747,10 @@ class Repository
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
\preg_match('/^[0-9]*/', $line, $matches);
|
\preg_match('/^[0-9]*/', $line, $matches);
|
||||||
|
|
||||||
$commits[\substr($line, \strlen($matches[0]) + 1)] = (int) $matches[0];
|
$temp = \substr($line, \strlen($matches[0]) + 1);
|
||||||
|
if ($temp !== false) {
|
||||||
|
$commits[$temp] = (int) $matches[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $commits;
|
return $commits;
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ class ArrayParser
|
||||||
return 'null';
|
return 'null';
|
||||||
} elseif (\is_scalar($value)) {
|
} elseif (\is_scalar($value)) {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
} elseif ($value instanceOf \Serializable) {
|
} elseif ($value instanceof \Serializable) {
|
||||||
return self::parseVariable($value->serialize());
|
return self::parseVariable($value->serialize());
|
||||||
} elseif ($value instanceOf \jsonSerializable) {
|
} elseif ($value instanceof \JsonSerializable) {
|
||||||
return self::parseVariable($value->jsonSerialize());
|
return self::parseVariable($value->jsonSerialize());
|
||||||
} else {
|
} else {
|
||||||
throw new \UnexpectedValueException();
|
throw new \UnexpectedValueException();
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ final class StringUtils
|
||||||
*
|
*
|
||||||
* The validation is done case sensitive.
|
* The validation is done case sensitive.
|
||||||
*
|
*
|
||||||
* @param string $haystack Haystack
|
* @param string $haystack Haystack
|
||||||
* @param array<string, float, int> $needles Needles to check if any of them are part of the haystack
|
* @param array<string> $needles Needles to check if any of them are part of the haystack
|
||||||
*
|
*
|
||||||
* @example StringUtils::contains('This string', ['This', 'test']); // true
|
* @example StringUtils::contains('This string', ['This', 'test']); // true
|
||||||
*
|
*
|
||||||
|
|
@ -71,8 +71,8 @@ final class StringUtils
|
||||||
*
|
*
|
||||||
* The validation is done case sensitive.
|
* The validation is done case sensitive.
|
||||||
*
|
*
|
||||||
* @param string $haystack Haystack
|
* @param string $haystack Haystack
|
||||||
* @param array<string, float, int> $needles Needles to check if any of them are part of the haystack
|
* @param array<string> $needles Needles to check if any of them are part of the haystack
|
||||||
*
|
*
|
||||||
* @example StringUtils::mb_contains('This string', ['This', 'test']); // true
|
* @example StringUtils::mb_contains('This string', ['This', 'test']); // true
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ final class TestUtils
|
||||||
*/
|
*/
|
||||||
public static function getMember(object $obj, string $name)
|
public static function getMember(object $obj, string $name)
|
||||||
{
|
{
|
||||||
$reflectionClass = new \ReflectionClass(\is_string($obj) ? $obj : \get_class($obj));
|
$reflectionClass = new \ReflectionClass($obj);
|
||||||
|
|
||||||
if (!$reflectionClass->hasProperty($name)) {
|
if (!$reflectionClass->hasProperty($name)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ class AccountTest extends \PHPUnit\Framework\TestCase
|
||||||
]);
|
]);
|
||||||
self::assertEquals(4, \count($account->getPermissions()));
|
self::assertEquals(4, \count($account->getPermissions()));
|
||||||
|
|
||||||
self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 1, 1, 1, 1));
|
self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1));
|
||||||
self::assertTrue($account->hasPermission(PermissionType::NONE));
|
self::assertTrue($account->hasPermission(PermissionType::NONE));
|
||||||
|
|
||||||
$account->setL11n(new Localization());
|
$account->setL11n(new Localization());
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ class Autoloader
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation.
|
|
||||||
*
|
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function defaultAutoloader(string $class) : void
|
public static function defaultAutoloader(string $class) : void
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', 'abc')->toSql());
|
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', 'abc')->toSql());
|
||||||
|
|
||||||
$query = new Builder($this->con);
|
$query = new Builder($this->con);
|
||||||
$datetime = new \Datetime('now');
|
$datetime = new \DateTime('now');
|
||||||
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'' . $datetime->format('Y-m-d H:i:s') . '\';';
|
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'' . $datetime->format('Y-m-d H:i:s') . '\';';
|
||||||
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', $datetime)->toSql());
|
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', $datetime)->toSql());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testClosure()
|
public function testClosure()
|
||||||
{
|
{
|
||||||
$l11nManager = new L11nManager();
|
$localization = new Localization();
|
||||||
$localization = new Localization($l11nManager);
|
|
||||||
|
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
!empty(
|
!empty(
|
||||||
|
|
@ -60,8 +59,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testPathMethod()
|
public function testPathMethod()
|
||||||
{
|
{
|
||||||
$l11nManager = new L11nManager();
|
$localization = new Localization();
|
||||||
$localization = new Localization($l11nManager);
|
|
||||||
|
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
!empty(
|
!empty(
|
||||||
|
|
@ -76,8 +74,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testPathMethodInArray()
|
public function testPathMethodInArray()
|
||||||
{
|
{
|
||||||
$l11nManager = new L11nManager();
|
$localization = new Localization();
|
||||||
$localization = new Localization($l11nManager);
|
|
||||||
|
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
!empty(
|
!empty(
|
||||||
|
|
@ -92,8 +89,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testPathStatic()
|
public function testPathStatic()
|
||||||
{
|
{
|
||||||
$l11nManager = new L11nManager();
|
$localization = new Localization();
|
||||||
$localization = new Localization($l11nManager);
|
|
||||||
|
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
!empty(
|
!empty(
|
||||||
|
|
@ -108,8 +104,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
public function testArray()
|
public function testArray()
|
||||||
{
|
{
|
||||||
$l11nManager = new L11nManager();
|
$localization = new Localization();
|
||||||
$localization = new Localization($l11nManager);
|
|
||||||
|
|
||||||
self::assertTrue(
|
self::assertTrue(
|
||||||
!empty(
|
!empty(
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class ArrayParserTest extends \PHPUnit\Framework\TestCase
|
||||||
public function unserialize($raw) {}
|
public function unserialize($raw) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
$jsonSerialize = new class implements \jsonSerializable {
|
$jsonSerialize = new class implements \JsonSerializable {
|
||||||
public function jsonSerialize() { return [6, 7]; }
|
public function jsonSerialize() { return [6, 7]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user