mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
phpstan fixes
This commit is contained in:
parent
a42f662062
commit
f43df4c7c2
|
|
@ -211,7 +211,7 @@ class Account implements \JsonSerializable, ArrayableInterface
|
|||
*
|
||||
* @param int $id Group id
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ final class ApplicationManager
|
|||
$destination = \rtrim($destination, '\\/');
|
||||
$source = \rtrim($source, '/\\');
|
||||
|
||||
if (!\is_dir($source) || \is_dir($destination) || !\is_file($source . '/Admin/Installer.php')) {
|
||||
if (!\is_dir($source) || ($path = \realpath($destination)) === false || !\is_file($source . '/Admin/Installer.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -109,8 +109,9 @@ final class ApplicationManager
|
|||
$this->installFiles($source, $destination);
|
||||
$this->replacePlaceholder($destination);
|
||||
|
||||
$classPath = \substr(\realpath($destination) . '/Admin/Installer', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
$classPath = \substr($path . '/Admin/Installer', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
// @var class-string<InstallerAbstract> $class
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
$class::install($this->app->dbPool, $info, $this->app->appSettings);
|
||||
|
||||
|
|
@ -132,7 +133,7 @@ final class ApplicationManager
|
|||
public function uninstall(string $source) : bool
|
||||
{
|
||||
$source = \rtrim($source, '/\\');
|
||||
if (!\is_dir($source) || !\is_file($source . '/Admin/Uninstaller.php')) {
|
||||
if (($path = \realpath($source)) === false || !\is_file($source . '/Admin/Uninstaller.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +141,9 @@ final class ApplicationManager
|
|||
$info = $this->loadInfo($source . '/info.json');
|
||||
$this->installed[$info->getInternalName()] = $info;
|
||||
|
||||
$classPath = \substr(\realpath($source) . '/Admin/Uninstaller', $t = \strlen(\realpath(__DIR__ . '/../../')));
|
||||
$classPath = \substr($path . '/Admin/Uninstaller', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
// @var class-string<UninstallerAbstract> $class
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
$class::uninstall($this->app->dbPool, $info, $this->app->appSettings);
|
||||
|
||||
|
|
@ -169,7 +171,12 @@ final class ApplicationManager
|
|||
return;
|
||||
}
|
||||
|
||||
$classPath = \substr(\realpath($appPath) . '/Admin/Installer', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath($appPath)) === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
// @var class-string<InstallerAbstract> $class
|
||||
$classPath = \substr($path . '/Admin/Installer', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
||||
/** @var $class InstallerAbstract */
|
||||
|
|
@ -223,6 +230,10 @@ final class ApplicationManager
|
|||
if (empty($this->installed) || !$useCache) {
|
||||
$apps = \scandir($basePath);
|
||||
|
||||
if ($apps === false) {
|
||||
return $this->installed; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
foreach ($apps as $app) {
|
||||
if ($app === '.' || $app === '..' || !\is_file($basePath . '/' . $app . '/info.json')) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,10 @@ abstract class InstallerAbstract
|
|||
}
|
||||
|
||||
$dirs = \scandir($path);
|
||||
if ($dirs === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!\is_dir($path. '/' . $dir) || $dir === '.' || $dir === '..') {
|
||||
continue;
|
||||
|
|
@ -130,8 +134,13 @@ abstract class InstallerAbstract
|
|||
*/
|
||||
protected static function activate(DatabasePool $dbPool, ApplicationInfo $info) : void
|
||||
{
|
||||
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath(static::PATH)) === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
// @var class-string<StatusAbstract> $class
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
||||
if (!Autoloader::exists($class)) {
|
||||
|
|
@ -152,8 +161,13 @@ abstract class InstallerAbstract
|
|||
*/
|
||||
public static function reInit(ApplicationInfo $info) : void
|
||||
{
|
||||
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath(static::PATH)) === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
// @var class-string<StatusAbstract> $class
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
||||
if (!Autoloader::exists($class)) {
|
||||
|
|
|
|||
|
|
@ -2113,7 +2113,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
public static function populateOwnsOne(string $member, array $result, int $depth = 3, mixed $default = null) : mixed
|
||||
{
|
||||
/** @var self|string $mapper */
|
||||
/** @var class-string<self> $mapper */
|
||||
$mapper = static::$ownsOne[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
|
|
@ -2153,7 +2153,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
public static function populateOwnsOneArray(string $member, array $result, int $depth = 3, mixed $default = null) : array
|
||||
{
|
||||
/** @var self|string $mapper */
|
||||
/** @var class-string<self> $mapper */
|
||||
$mapper = static::$ownsOne[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
|
|
@ -2194,7 +2194,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
public static function populateBelongsTo(string $member, array $result, int $depth = 3, mixed $default = null) : mixed
|
||||
{
|
||||
/** @var self|string $mapper */
|
||||
/** @var class-string<self> $mapper */
|
||||
$mapper = static::$belongsTo[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
|
|
@ -2242,7 +2242,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
public static function populateBelongsToArray(string $member, array $result, int $depth = 3, mixed $default = null) : array
|
||||
{
|
||||
/** @var self|string $mapper */
|
||||
/** @var class-string<self> $mapper */
|
||||
$mapper = static::$belongsTo[$member]['mapper'];
|
||||
|
||||
if ($depth < 1) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class FileSession implements SessionInterface
|
|||
$this->sessionData = $_SESSION ?? [];
|
||||
$_SESSION = null;
|
||||
$this->sessionData['lastActivity'] = \time();
|
||||
$this->sid = \session_id();
|
||||
$this->sid = (string) \session_id();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ final class FileSessionHandler implements \SessionHandlerInterface, \SessionIdIn
|
|||
*/
|
||||
public function create_sid() : string
|
||||
{
|
||||
return \session_create_id('s-');
|
||||
return ($sid = \session_create_id('s-')) === false ? '' : $sid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ final class HttpSession implements SessionInterface
|
|||
$this->sessionData = $_SESSION ?? [];
|
||||
$_SESSION = null;
|
||||
$this->sessionData['lastActivity'] = \time();
|
||||
$this->sid = \session_id();
|
||||
$this->sid = (string) \session_id();
|
||||
|
||||
$this->setCsrfProtection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,9 +95,13 @@ abstract class InstallerAbstract
|
|||
*/
|
||||
protected static function activate(DatabasePool $dbPool, ModuleInfo $info) : void
|
||||
{
|
||||
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath(static::PATH)) === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var StatusAbstract $class */
|
||||
$classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
/** @var class-string<StatusAbstract> $class */
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
||||
if (!Autoloader::exists($class)) {
|
||||
|
|
@ -119,9 +123,13 @@ abstract class InstallerAbstract
|
|||
*/
|
||||
public static function reInit(ModuleInfo $info, ApplicationInfo $appInfo = null) : void
|
||||
{
|
||||
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath(static::PATH)) === false) {
|
||||
return; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/** @var StatusAbstract $class */
|
||||
$classPath = \substr($path . '/Status', \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
/** @var class-string<StatusAbstract> $class */
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
||||
if (!Autoloader::exists($class)) {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,11 @@ final class ModuleManager
|
|||
\chdir($this->modulePath);
|
||||
$files = \glob('*', \GLOB_ONLYDIR);
|
||||
|
||||
$c = $files === false ? 0 : \count($files);
|
||||
if ($files === false) {
|
||||
return $this->all; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$c = \count($files);
|
||||
for ($i = 0; $i < $c; ++$i) {
|
||||
$info = $this->loadInfo($files[$i]);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,12 @@ abstract class UninstallerAbstract
|
|||
*/
|
||||
protected static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void
|
||||
{
|
||||
/** @var StatusAbstract $class */
|
||||
$classPath = \substr(\realpath(static::PATH) . '/Status', \strlen(\realpath(__DIR__ . '/../../')));
|
||||
if (($path = \realpath(static::PATH)) === false) {
|
||||
return; // @codeCoverageIgnore;
|
||||
}
|
||||
|
||||
/** @var string $classPath */
|
||||
$classPath = \substr($path . '/Status', \strlen((string) \realpath(__DIR__ . '/../../')));
|
||||
|
||||
/** @var StatusAbstract $class */
|
||||
$class = \str_replace('/', '\\', $classPath);
|
||||
|
|
|
|||
|
|
@ -211,7 +211,13 @@ class SmartDateTime extends \DateTime
|
|||
*/
|
||||
public function getFirstDayOfMonth() : int
|
||||
{
|
||||
return \getdate(\mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y')))['wday'];
|
||||
$time = \mktime(0, 0, 0, (int) $this->format('m'), 1, (int) $this->format('Y'));
|
||||
|
||||
if ($time === false) {
|
||||
return -1; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return \getdate($time)['wday'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ class Graph
|
|||
->setWeight($this->getEdge(
|
||||
$node1->getId(),
|
||||
$node2->getId()
|
||||
)->getWeight()
|
||||
)?->getWeight() ?? 0.0
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user