mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-02-15 17:28:41 +00:00
fix phpstan lvl 9 bugs
This commit is contained in:
parent
56c2e86835
commit
80e16b2613
|
|
@ -72,11 +72,11 @@ final class Installer extends InstallerAbstract
|
||||||
* @param ApplicationAbstract $app Application
|
* @param ApplicationAbstract $app Application
|
||||||
* @param string $path File path
|
* @param string $path File path
|
||||||
*
|
*
|
||||||
* @return InterfaceManager
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createInterface(ApplicationAbstract $app, string $path) : InterfaceManager
|
private static function createInterface(ApplicationAbstract $app, string $path) : array
|
||||||
{
|
{
|
||||||
/** @var \Modules\Exchange\Controller\ApiController $module */
|
/** @var \Modules\Exchange\Controller\ApiController $module */
|
||||||
$module = $app->moduleManager->get('Exchange');
|
$module = $app->moduleManager->get('Exchange');
|
||||||
|
|
@ -86,12 +86,12 @@ final class Installer extends InstallerAbstract
|
||||||
|
|
||||||
$contents = \file_get_contents($path . '/interface.json');
|
$contents = \file_get_contents($path . '/interface.json');
|
||||||
if ($contents === false) {
|
if ($contents === false) {
|
||||||
return new NullInterfaceManager();
|
return (new NullInterfaceManager())->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = \json_decode($contents, true);
|
$data = \json_decode($contents, true);
|
||||||
if (!\is_array($data)) {
|
if (!\is_array($data)) {
|
||||||
return new NullInterfaceManager();
|
return (new NullInterfaceManager())->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->header->account = 1;
|
$request->header->account = 1;
|
||||||
|
|
@ -106,7 +106,7 @@ final class Installer extends InstallerAbstract
|
||||||
|
|
||||||
$exchangeFiles = \scandir($path);
|
$exchangeFiles = \scandir($path);
|
||||||
if ($exchangeFiles === false) {
|
if ($exchangeFiles === false) {
|
||||||
return new NullInterfaceManager();
|
return (new NullInterfaceManager())->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($exchangeFiles as $filePath) {
|
foreach ($exchangeFiles as $filePath) {
|
||||||
|
|
@ -158,8 +158,13 @@ final class Installer extends InstallerAbstract
|
||||||
$module->apiInterfaceInstall($request, $response);
|
$module->apiInterfaceInstall($request, $response);
|
||||||
\rmdir($tmpPath);
|
\rmdir($tmpPath);
|
||||||
|
|
||||||
$interface = $response->get('')['response'];
|
$responseData = $response->get('');
|
||||||
|
if (!\is_array($responseData)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return $interface;
|
return !\is_array($responseData['response'])
|
||||||
|
? $responseData['response']->toArray()
|
||||||
|
: $responseData['response'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,12 @@ final class ApiController extends Controller
|
||||||
$remoteConnection = new NullConnection();
|
$remoteConnection = new NullConnection();
|
||||||
if (!empty($request->getData('dbtype'))) {
|
if (!empty($request->getData('dbtype'))) {
|
||||||
$remoteConnection = ConnectionFactory::create([
|
$remoteConnection = ConnectionFactory::create([
|
||||||
'db' => $request->getData('dbtype'),
|
'db' => (string) $request->getData('dbtype'),
|
||||||
'host' => $request->getData('dbhost') ?? null,
|
'host' => $request->hasData('dbhost') ? (string) $request->getData('dbhost') : null,
|
||||||
'port' => $request->getData('dbport') ?? null,
|
'port' => $request->hasData('dbport') ? (int) $request->getData('dbport') : null,
|
||||||
'database' => $request->getData('dbdatabase') ?? null,
|
'database' => $request->hasData('dbdatabase') ? (string) $request->getData('dbdatabase') : null,
|
||||||
'login' => $request->getData('dblogin') ?? null,
|
'login' => $request->hasData('dblogin') ? (string) $request->getData('dblogin') : null,
|
||||||
'password' => $request->getData('dbpassword') ?? null,
|
'password' => $request->hasData('dbpassword') ? (string) $request->getData('dbpassword') : null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,11 +251,11 @@ final class ApiController extends Controller
|
||||||
private function createInterfaceFromRequest(RequestAbstract $request, int $collectionId) : InterfaceManager
|
private function createInterfaceFromRequest(RequestAbstract $request, int $collectionId) : InterfaceManager
|
||||||
{
|
{
|
||||||
$interface = new InterfaceManager();
|
$interface = new InterfaceManager();
|
||||||
$interface->title = $request->getData('title') ?? '';
|
$interface->title = (string) ($request->getData('title') ?? '');
|
||||||
$interface->hasExport = (bool) ($request->getData('export') ?? false);
|
$interface->hasExport = (bool) ($request->getData('export') ?? false);
|
||||||
$interface->hasImport = (bool) ($request->getData('import') ?? false);
|
$interface->hasImport = (bool) ($request->getData('import') ?? false);
|
||||||
$interface->website = $request->getData('website') ?? '';
|
$interface->website = (string) ($request->getData('website') ?? '');
|
||||||
$interface->version = $request->getData('version') ?? '';
|
$interface->version = (string) ($request->getData('version') ?? '');
|
||||||
$interface->createdBy = new NullAccount($request->header->account);
|
$interface->createdBy = new NullAccount($request->header->account);
|
||||||
|
|
||||||
if ($collectionId > 0) {
|
if ($collectionId > 0) {
|
||||||
|
|
@ -426,7 +426,7 @@ final class ApiController extends Controller
|
||||||
private function createSettingFromRequest(RequestAbstract $request) : ExchangeSetting
|
private function createSettingFromRequest(RequestAbstract $request) : ExchangeSetting
|
||||||
{
|
{
|
||||||
$setting = new ExchangeSetting();
|
$setting = new ExchangeSetting();
|
||||||
$setting->title = $request->getData('title') ?? '';
|
$setting->title = (string) ($request->getData('title') ?? '');
|
||||||
$setting->exchange = (int) ($request->getData('id') ?? 0);
|
$setting->exchange = (int) ($request->getData('id') ?? 0);
|
||||||
$setting->setData(\json_decode((string) ($request->getData('data') ?? '{}'), true));
|
$setting->setData(\json_decode((string) ($request->getData('data') ?? '{}'), true));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -511,6 +511,7 @@ final class Importer extends ImporterAbstract
|
||||||
*/
|
*/
|
||||||
private function createItemL11nTypes() : array
|
private function createItemL11nTypes() : array
|
||||||
{
|
{
|
||||||
|
/** @var array{name1:ItemL11nType, name2:ItemL11nType, info:ItemL11nType} $itemL11nType */
|
||||||
$itemL11nType = [];
|
$itemL11nType = [];
|
||||||
|
|
||||||
if (($itemL11nType['name1'] = ItemL11nTypeMapper::get()->where('title', 'name1')->execute()) instanceof NullItemL11nType) {
|
if (($itemL11nType['name1'] = ItemL11nTypeMapper::get()->where('title', 'name1')->execute()) instanceof NullItemL11nType) {
|
||||||
|
|
@ -528,13 +529,14 @@ final class Importer extends ImporterAbstract
|
||||||
ItemL11nTypeMapper::create()->execute($itemL11nType['info']);
|
ItemL11nTypeMapper::create()->execute($itemL11nType['info']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var array{name1:ItemL11nType, name2:ItemL11nType, info:ItemL11nType} $itemL11nType */
|
||||||
return $itemL11nType;
|
return $itemL11nType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create and get item attribute types
|
* Create and get item attribute types
|
||||||
*
|
*
|
||||||
* @return ItemAttributeType[]
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,11 @@ class InterfaceManager
|
||||||
|
|
||||||
$contents = \file_get_contents($this->path);
|
$contents = \file_get_contents($this->path);
|
||||||
|
|
||||||
|
/** @var array $info */
|
||||||
$info = \json_decode($contents === false ? '[]' : $contents, true);
|
$info = \json_decode($contents === false ? '[]' : $contents, true);
|
||||||
|
if ($info === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->title = $info['name'];
|
$this->title = $info['name'];
|
||||||
$this->version = $info['version'];
|
$this->version = $info['version'];
|
||||||
|
|
@ -216,4 +220,24 @@ class InterfaceManager
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'path' => $this->path,
|
||||||
|
'title' => $this->title,
|
||||||
|
'version' => $this->version,
|
||||||
|
'website' => $this->website,
|
||||||
|
'hasExport' => $this->hasExport,
|
||||||
|
'hasImport' => $this->hasImport,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user