fix phpstan lvl 9 bugs

This commit is contained in:
Dennis Eichhorn 2022-12-26 20:52:58 +01:00
parent 7a91d0b537
commit 520be0d9e1
4 changed files with 22 additions and 8 deletions

View File

@ -108,6 +108,7 @@ final class Installer extends InstallerAbstract
$apiApp->moduleManager = $app->moduleManager; $apiApp->moduleManager = $app->moduleManager;
$apiApp->eventManager = $app->eventManager; $apiApp->eventManager = $app->eventManager;
/** @var array{type:array} $editorData */
foreach ($editorData as $editor) { foreach ($editorData as $editor) {
switch ($editor['type']) { switch ($editor['type']) {
case 'type': case 'type':
@ -126,11 +127,11 @@ final class Installer extends InstallerAbstract
* @param ApplicationAbstract $app Application * @param ApplicationAbstract $app Application
* @param array $data Type info * @param array $data Type info
* *
* @return EditorDocType * @return array
* *
* @since 1.0.0 * @since 1.0.0
*/ */
private static function createType(ApplicationAbstract $app, array $data) : EditorDocType private static function createType(ApplicationAbstract $app, array $data) : array
{ {
/** @var \Modules\Editor\Controller\ApiController $module */ /** @var \Modules\Editor\Controller\ApiController $module */
$module = $app->moduleManager->get('Editor'); $module = $app->moduleManager->get('Editor');
@ -143,7 +144,13 @@ final class Installer extends InstallerAbstract
$module->apiEditorDocTypeCreate($request, $response); $module->apiEditorDocTypeCreate($request, $response);
$type = $response->get('')['response']; $responseData = $response->get('');
if (!\is_array($responseData)) {
return [];
}
/** @var \Modules\Editor\Models\EditorDocType $type */
$type = $responseData['response'];
$id = $type->getId(); $id = $type->getId();
foreach ($data['l11n'] as $l11n) { foreach ($data['l11n'] as $l11n) {
@ -158,6 +165,6 @@ final class Installer extends InstallerAbstract
$module->apiEditorDocTypeL11nCreate($request, $response); $module->apiEditorDocTypeL11nCreate($request, $response);
} }
return $type; return $type->toArray();
} }
} }

View File

@ -109,7 +109,7 @@ final class ApiController extends Controller
private function createDocTypeFromRequest(RequestAbstract $request) : EditorDocType private function createDocTypeFromRequest(RequestAbstract $request) : EditorDocType
{ {
$type = new EditorDocType(); $type = new EditorDocType();
$type->name = $request->getData('name'); $type->name = (string) ($request->getData('name') ?? '');
if (!empty($request->getData('title'))) { if (!empty($request->getData('title'))) {
$type->setL11n($request->getData('title'), $request->getData('lang') ?? $request->getLanguage()); $type->setL11n($request->getData('title'), $request->getData('lang') ?? $request->getLanguage());
@ -376,7 +376,12 @@ final class ApiController extends Controller
$internalResponse = new HttpResponse(); $internalResponse = new HttpResponse();
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null); $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
$doc->addTag($internalResponse->get($request->uri->__toString())['response']);
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) {
continue;
}
$doc->addTag($data['response']);
} else { } else {
$doc->addTag(new NullTag((int) $tag['id'])); $doc->addTag(new NullTag((int) $tag['id']));
} }
@ -418,7 +423,8 @@ final class ApiController extends Controller
public function apiEditorUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiEditorUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
/** @var \Modules\Editor\Models\EditorDoc $old */ /** @var \Modules\Editor\Models\EditorDoc $old */
$old = clone EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute(); $old = EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute();
$old = clone $old;
$new = $this->updateEditorFromRequest($request); $new = $this->updateEditorFromRequest($request);
$this->updateModel($request->header->account, $old, $new, EditorDocMapper::class, 'doc', $request->getOrigin()); $this->updateModel($request->header->account, $old, $new, EditorDocMapper::class, 'doc', $request->getOrigin());

View File

@ -226,6 +226,7 @@ class TextView extends View
*/ */
public function render(mixed ...$data) : string public function render(mixed ...$data) : string
{ {
/** @var array{0:null|string, 1:null|string, 2:null|string, 3:null|string, 4:null|string, 5:null|string, 6:null|string, 7:null|string, 8:null|string} $data */
$this->id = $data[0] ?? ''; $this->id = $data[0] ?? '';
$this->name = $data[1] ?? ''; $this->name = $data[1] ?? '';
$this->form = $data[2] ?? ''; $this->form = $data[2] ?? '';

View File

@ -40,7 +40,7 @@ echo $this->getData('nav')->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-6 overflowfix"> <div class="col-xs-6 overflowfix">
<?php foreach ($tags as $tag) : ?> <?php foreach ($tags as $tag) : ?>
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span> <span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !emptty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?php if ($editable) : ?> <?php if ($editable) : ?>