mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-01-30 17:58:40 +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 string $path File path
|
||||
*
|
||||
* @return InterfaceManager
|
||||
* @return array
|
||||
*
|
||||
* @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 */
|
||||
$module = $app->moduleManager->get('Exchange');
|
||||
|
|
@ -86,12 +86,12 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
$contents = \file_get_contents($path . '/interface.json');
|
||||
if ($contents === false) {
|
||||
return new NullInterfaceManager();
|
||||
return (new NullInterfaceManager())->toArray();
|
||||
}
|
||||
|
||||
$data = \json_decode($contents, true);
|
||||
if (!\is_array($data)) {
|
||||
return new NullInterfaceManager();
|
||||
return (new NullInterfaceManager())->toArray();
|
||||
}
|
||||
|
||||
$request->header->account = 1;
|
||||
|
|
@ -106,7 +106,7 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
$exchangeFiles = \scandir($path);
|
||||
if ($exchangeFiles === false) {
|
||||
return new NullInterfaceManager();
|
||||
return (new NullInterfaceManager())->toArray();
|
||||
}
|
||||
|
||||
foreach ($exchangeFiles as $filePath) {
|
||||
|
|
@ -158,8 +158,13 @@ final class Installer extends InstallerAbstract
|
|||
$module->apiInterfaceInstall($request, $response);
|
||||
\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();
|
||||
if (!empty($request->getData('dbtype'))) {
|
||||
$remoteConnection = ConnectionFactory::create([
|
||||
'db' => $request->getData('dbtype'),
|
||||
'host' => $request->getData('dbhost') ?? null,
|
||||
'port' => $request->getData('dbport') ?? null,
|
||||
'database' => $request->getData('dbdatabase') ?? null,
|
||||
'login' => $request->getData('dblogin') ?? null,
|
||||
'password' => $request->getData('dbpassword') ?? null,
|
||||
'db' => (string) $request->getData('dbtype'),
|
||||
'host' => $request->hasData('dbhost') ? (string) $request->getData('dbhost') : null,
|
||||
'port' => $request->hasData('dbport') ? (int) $request->getData('dbport') : null,
|
||||
'database' => $request->hasData('dbdatabase') ? (string) $request->getData('dbdatabase') : null,
|
||||
'login' => $request->hasData('dblogin') ? (string) $request->getData('dblogin') : 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
|
||||
{
|
||||
$interface = new InterfaceManager();
|
||||
$interface->title = $request->getData('title') ?? '';
|
||||
$interface->title = (string) ($request->getData('title') ?? '');
|
||||
$interface->hasExport = (bool) ($request->getData('export') ?? false);
|
||||
$interface->hasImport = (bool) ($request->getData('import') ?? false);
|
||||
$interface->website = $request->getData('website') ?? '';
|
||||
$interface->version = $request->getData('version') ?? '';
|
||||
$interface->website = (string) ($request->getData('website') ?? '');
|
||||
$interface->version = (string) ($request->getData('version') ?? '');
|
||||
$interface->createdBy = new NullAccount($request->header->account);
|
||||
|
||||
if ($collectionId > 0) {
|
||||
|
|
@ -426,7 +426,7 @@ final class ApiController extends Controller
|
|||
private function createSettingFromRequest(RequestAbstract $request) : ExchangeSetting
|
||||
{
|
||||
$setting = new ExchangeSetting();
|
||||
$setting->title = $request->getData('title') ?? '';
|
||||
$setting->title = (string) ($request->getData('title') ?? '');
|
||||
$setting->exchange = (int) ($request->getData('id') ?? 0);
|
||||
$setting->setData(\json_decode((string) ($request->getData('data') ?? '{}'), true));
|
||||
|
||||
|
|
|
|||
|
|
@ -511,6 +511,7 @@ final class Importer extends ImporterAbstract
|
|||
*/
|
||||
private function createItemL11nTypes() : array
|
||||
{
|
||||
/** @var array{name1:ItemL11nType, name2:ItemL11nType, info:ItemL11nType} $itemL11nType */
|
||||
$itemL11nType = [];
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
/** @var array{name1:ItemL11nType, name2:ItemL11nType, info:ItemL11nType} $itemL11nType */
|
||||
return $itemL11nType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and get item attribute types
|
||||
*
|
||||
* @return ItemAttributeType[]
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -152,7 +152,11 @@ class InterfaceManager
|
|||
|
||||
$contents = \file_get_contents($this->path);
|
||||
|
||||
/** @var array $info */
|
||||
$info = \json_decode($contents === false ? '[]' : $contents, true);
|
||||
if ($info === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->title = $info['name'];
|
||||
$this->version = $info['version'];
|
||||
|
|
@ -216,4 +220,24 @@ class InterfaceManager
|
|||
|
||||
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