fix static analysis

This commit is contained in:
Dennis Eichhorn 2023-04-09 06:03:39 +02:00
parent f1562c4307
commit 55654b2f44
12 changed files with 147 additions and 63 deletions

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
@ -15,9 +15,10 @@ declare(strict_types=1);
$data = $this->getData('data') ?? []; $data = $this->getData('data') ?? [];
$out = \fopen('php://output', 'w'); $out = \fopen('php://output', 'w');
if ($out !== false) {
foreach ($data as $row) {
\fputcsv($out, $row);
}
foreach ($data as $row) { \fclose($out);
fputcsv($out, $row);
} }
\fclose($out);

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0

View File

@ -1,4 +1,15 @@
<?php <?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Media
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1); declare(strict_types=1);
use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter; use PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter;

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
@ -14,11 +14,12 @@ declare(strict_types=1);
require_once __DIR__ . '/../phpOMS/Autoloader.php'; require_once __DIR__ . '/../phpOMS/Autoloader.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
use phpOMS\Autoloader; use phpOMS\Autoloader;
Autoloader::addPath(__DIR__ . '/../Resources'); Autoloader::addPath(__DIR__ . '/../Resources');
use PhpOffice\PhpSpreadsheet\IOFactory; /** @var \phpOMS\Views\View $this */
$media = $this->getData('media'); $media = $this->getData('media');
$data = $this->getData('data') ?? []; $data = $this->getData('data') ?? [];
@ -37,6 +38,9 @@ $file = \tempnam(\sys_get_temp_dir(), 'oms_');
$writer = IOFactory::createWriter($excel, 'Xlsx'); $writer = IOFactory::createWriter($excel, 'Xlsx');
$writer->save($file); $writer->save($file);
echo \file_get_contents($file); $content = \file_get_contents($file);
if ($content !== false) {
echo $content;
}
\unlink($file); \unlink($file);

View File

@ -20,7 +20,7 @@ declare(strict_types=1);
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
* *
* @phpstan-import-type TCPDF from ../../../../../Resources/tcpdf.php * @phpstan-import-type TCPDF from ../../../../../Resources/tcpdf/tcpdf.php
*/ */
class DefaultPdf extends TCPDF class DefaultPdf extends TCPDF
{ {

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
@ -15,10 +15,14 @@ declare(strict_types=1);
require_once __DIR__ . '/../phpOMS/Autoloader.php'; require_once __DIR__ . '/../phpOMS/Autoloader.php';
use phpOMS\Autoloader; use phpOMS\Autoloader;
Autoloader::addPath(__DIR__ . '/../Resources'); Autoloader::addPath(__DIR__ . '/../Resources');
/** @var \phpOMS\Views\View $this */
$media = $this->getData('media'); $media = $this->getData('media');
$data = $this->getData('data') ?? [];
/** @var array<array> $data */
$data = $this->getData('data') ?? [];
include $media->getSourceByName('template.php')->getAbsolutePath(); include $media->getSourceByName('template.php')->getAbsolutePath();

View File

@ -1,7 +1,32 @@
<?php <?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Media
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1); declare(strict_types=1);
class DefaultWord extends \PhpOffice\PhpWord\PhpWord { /**
* Default Word class.
*
* @package Modules\Media
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
class DefaultWord extends \PhpOffice\PhpWord\PhpWord
{
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -32,7 +57,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$table->addCell(1300)->addImage(__DIR__ . '/../Web/Backend/img/logo.png', ['width' => 50, 'height' => 50]); $table->addCell(1300)->addImage(__DIR__ . '/../Web/Backend/img/logo.png', ['width' => 50, 'height' => 50]);
//second column //second column
$cell = $table->addCell(8700, ['valign' => 'bottom']); $cell = $table->addCell(8700, ['valign' => 'bottom']);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]); $textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]);
@ -51,7 +76,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
// columns // columns
$cell = $table->addCell(500); $cell = $table->addCell(500);
$cell = $table->addCell(2000); $cell = $table->addCell(2000);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -59,7 +84,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2700); $cell = $table->addCell(2700);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -67,7 +92,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2700); $cell = $table->addCell(2700);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -75,7 +100,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2100); $cell = $table->addCell(2100);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -98,14 +123,14 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
]); ]);
$header = $section->addHeader(); $header = $section->addHeader();
$table = $header->addTable(); $table = $header->addTable();
$table->addRow(); $table->addRow();
// first column // first column
$table->addCell(1300)->addImage(__DIR__ . '/../Web/Backend/img/logo.png', ['width' => 50, 'height' => 50]); $table->addCell(1300)->addImage(__DIR__ . '/../Web/Backend/img/logo.png', ['width' => 50, 'height' => 50]);
//second column //second column
$cell = $table->addCell(8700, ['valign' => 'bottom']); $cell = $table->addCell(8700, ['valign' => 'bottom']);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]); $textrun->addText('Jingga', ['name' => 'helvetica', 'bold' => true, 'size' => 20]);
@ -122,7 +147,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
// columns // columns
$cell = $table->addCell(500); $cell = $table->addCell(500);
$cell = $table->addCell(2000); $cell = $table->addCell(2000);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Jingga e.K.', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -130,7 +155,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('61206 Woellstadt', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2700); $cell = $table->addCell(2700);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Geschäftsführer: Dennis Eichhorn', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -138,7 +163,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('USt Id: DE ??????????', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2700); $cell = $table->addCell(2700);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('Volksbank Mittelhessen', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
@ -146,7 +171,7 @@ class DefaultWord extends \PhpOffice\PhpWord\PhpWord {
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('IBAN: ???????????', ['name' => 'helvetica', 'size' => 7]);
$cell = $table->addCell(2100); $cell = $table->addCell(2100);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]); $textrun->addText('www.jingga.app', ['name' => 'helvetica', 'size' => 7]);
$textrun = $cell->addTextRun(); $textrun = $cell->addTextRun();

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
@ -15,19 +15,24 @@ declare(strict_types=1);
require_once __DIR__ . '/../phpOMS/Autoloader.php'; require_once __DIR__ . '/../phpOMS/Autoloader.php';
use phpOMS\Autoloader; use phpOMS\Autoloader;
Autoloader::addPath(__DIR__ . '/../Resources'); Autoloader::addPath(__DIR__ . '/../Resources');
/** @var \phpOMS\Views\View $this */
$media = $this->getData('media'); $media = $this->getData('media');
$data = $this->getData('data') ?? []; $data = $this->getData('data') ?? [];
include $media->getSourceByName('template.php')->getAbsolutePath(); include $media->getSourceByName('template.php')->getAbsolutePath();
$word = new DefaultWord(); $word = new DefaultWord();
$section = $word->createFirstPage(); $section = $word->createFirstPage();
$file = \tempnam(\sys_get_temp_dir(), 'oms_'); $file = \tempnam(\sys_get_temp_dir(), 'oms_');
$writer->save($file); $writer->save($file);
echo \file_get_contents($file); $content = \file_get_contents($file);
if ($content !== false) {
echo $content;
}
\unlink($file); \unlink($file);

View File

@ -4,7 +4,7 @@
* *
* PHP Version 8.1 * PHP Version 8.1
* *
* @package Modules\Admin * @package Modules\Media
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 2.0 * @license OMS License 2.0
* @version 1.0.0 * @version 1.0.0
@ -15,14 +15,18 @@ declare(strict_types=1);
require_once __DIR__ . '/../phpOMS/Autoloader.php'; require_once __DIR__ . '/../phpOMS/Autoloader.php';
use phpOMS\Autoloader; use phpOMS\Autoloader;
Autoloader::addPath(__DIR__ . '/../Resources'); Autoloader::addPath(__DIR__ . '/../Resources');
/** @var \phpOMS\Views\View $this */
$media = $this->getData('media'); $media = $this->getData('media');
$data = $this->getData('data') ?? [];
/** @var array<array> $data */
$data = $this->getData('data') ?? [];
include $media->getSourceByName('template.php')->getAbsolutePath(); include $media->getSourceByName('template.php')->getAbsolutePath();
$word = new DefaultWord(); $word = new DefaultWord();
$section = $word->createFirstPage(); $section = $word->createFirstPage();
$tbl = '<table border="1" cellpadding="0" cellspacing="0">'; $tbl = '<table border="1" cellpadding="0" cellspacing="0">';
@ -52,4 +56,4 @@ $writer->save($file);
echo \file_get_contents($file); echo \file_get_contents($file);
\unlink($file); \unlink($file);

View File

@ -18,6 +18,7 @@ use phpOMS\Autoloader;
Autoloader::addPath(__DIR__ . '/../Resources'); Autoloader::addPath(__DIR__ . '/../Resources');
/** @var \phpOMS\Views\View $this */
$media = $this->getData('media'); $media = $this->getData('media');
$data = $this->getData('data') ?? []; $data = $this->getData('data') ?? [];
@ -29,6 +30,11 @@ $section = $word->createFirstPage();
$file = \tempnam(\sys_get_temp_dir(), 'oms_'); $file = \tempnam(\sys_get_temp_dir(), 'oms_');
$writer->save($file); $writer->save($file);
echo \file_get_contents($file); if ($file !== false) {
$content = \file_get_contents($file);
if ($content !== false) {
echo $content;
}
}
\unlink($file); \unlink($file);

View File

@ -1,5 +1,15 @@
<?php <?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Admin\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1); declare(strict_types=1);
use Modules\Admin\Models\SettingsEnum; use Modules\Admin\Models\SettingsEnum;

View File

@ -1333,12 +1333,15 @@ final class ApiController extends Controller
*/ */
public function apiGroupFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiGroupFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
/** @var \Modules\Admin\Models\Group[] $groups */
$groups = GroupMapper::getAll()
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute();
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
$request->uri->__toString(), $request->uri->__toString(),
\array_values( \array_values($groups)
GroupMapper::getAll()->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')->execute()
)
); );
} }
@ -1385,18 +1388,19 @@ final class ApiController extends Controller
*/ */
public function apiAccountFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiAccountFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
/** @var \Modules\Admin\Models\Account[] $accounts */
$accounts = AccountMapper::getAll()
->where('login', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->where('email', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name1', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name2', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name3', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->execute();
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
$request->uri->__toString(), $request->uri->__toString(),
\array_values( \array_values($accounts)
AccountMapper::getAll()
->where('login', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->where('email', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name1', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name2', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name3', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->execute()
)
); );
} }
@ -1416,19 +1420,15 @@ final class ApiController extends Controller
public function apiAccountGroupFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiAccountGroupFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
/** @var Account[] $accounts */ /** @var Account[] $accounts */
$accounts = \array_values( $accounts = AccountMapper::getAll()
AccountMapper::getAll() ->where('login', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->where('login', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('email', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('email', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR') ->where('name1', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name1', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR') ->where('name2', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name2', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR') ->where('name3', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('name3', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR') ->execute();
->execute()
);
/** @var Group[] $groups */ $data = [];
$groups = \array_values(GroupMapper::getAll()->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')->execute());
$data = [];
foreach ($accounts as $account) { foreach ($accounts as $account) {
/** @var array $temp */ /** @var array $temp */
@ -1439,6 +1439,11 @@ final class ApiController extends Controller
$data[] = $temp; $data[] = $temp;
} }
/** @var Group[] $groups */
$groups = GroupMapper::getAll()
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute();
foreach ($groups as $group) { foreach ($groups as $group) {
/** @var array $temp */ /** @var array $temp */
$temp = $group->jsonSerialize(); $temp = $group->jsonSerialize();
@ -1731,7 +1736,10 @@ final class ApiController extends Controller
); );
if (!empty($defaultGroupSettings)) { if (!empty($defaultGroupSettings)) {
$defaultGroupIds = \array_merge($defaultGroupIds, \json_decode($defaultGroupSettings->content, true)); $defaultGroupIds = \array_merge(
$defaultGroupIds,
\json_decode($defaultGroupSettings->content, true)
);
} }
} }
@ -1744,7 +1752,10 @@ final class ApiController extends Controller
); );
if (!empty($defaultGroupSettings)) { if (!empty($defaultGroupSettings)) {
$defaultGroupIds = \array_merge($defaultGroupIds, \json_decode($defaultGroupSettings->content, true)); $defaultGroupIds = \array_merge(
$defaultGroupIds,
\json_decode($defaultGroupSettings->content, true)
);
} }
} }
@ -2069,10 +2080,12 @@ final class ApiController extends Controller
if (!$request->hasData('locale')) { if (!$request->hasData('locale')) {
$account->l11n = Localization::fromJson( $account->l11n = Localization::fromJson(
$this->app->l11nServer === null ? $request->header->l11n->jsonSerialize() : $this->app->l11nServer->jsonSerialize() $this->app->l11nServer === null
? $request->header->l11n->jsonSerialize()
: $this->app->l11nServer->jsonSerialize()
); );
} else { } else {
$locale = \explode('_', $request->getData('locale')); $locale = \explode('_', $request->getdataString('locale') ?? '');
$account->l11n $account->l11n
->loadFromLanguage( ->loadFromLanguage(
@ -3069,6 +3082,7 @@ final class ApiController extends Controller
if ($cliEventHandling) { if ($cliEventHandling) {
$count = \count($data); $count = \count($data);
/** @var string $cliPath */
$cliPath = \realpath(__DIR__ . '/../../../cli.php'); $cliPath = \realpath(__DIR__ . '/../../../cli.php');
if ($cliPath === false) { if ($cliPath === false) {
return; return;