fix phpstan/phpcs

This commit is contained in:
Dennis Eichhorn 2021-06-26 14:38:08 +02:00
parent b01877046c
commit f4c3e8c882
8 changed files with 165 additions and 162 deletions

View File

@ -202,10 +202,10 @@ final class ApiController extends Controller
*/ */
private function createClientAttributeFromRequest(RequestAbstract $request) : ClientAttribute private function createClientAttributeFromRequest(RequestAbstract $request) : ClientAttribute
{ {
$attribute = new ClientAttribute(); $attribute = new ClientAttribute();
$attribute->client = (int) $request->getData('client'); $attribute->client = (int) $request->getData('client');
$attribute->type = new NullClientAttributeType((int) $request->getData('type')); $attribute->type = new NullClientAttributeType((int) $request->getData('type'));
$attribute->value = new NullClientAttributeValue((int) $request->getData('value')); $attribute->value = new NullClientAttributeValue((int) $request->getData('value'));
return $attribute; return $attribute;
} }

View File

@ -68,9 +68,7 @@ class ClientAttributeType implements \JsonSerializable, ArrayableInterface
* *
* @var string | ClientAttributeTypeL11n * @var string | ClientAttributeTypeL11n
*/ */
protected string | protected string|ClientAttributeTypeL11n $l11n;
ClientAttributeTypeL11n $l11n;
/** /**
* Possible default attribute values * Possible default attribute values
@ -113,16 +111,16 @@ class ClientAttributeType implements \JsonSerializable, ArrayableInterface
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void public function setL11n(string|ClientAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
{ {
if ($l11n instanceof ClientAttributeTypeL11n) { if ($l11n instanceof ClientAttributeTypeL11n) {
$this->l11n = $l11n; $this->l11n = $l11n;
} elseif (\is_string($l11n)) { } elseif ($this->l11n instanceof ClientAttributeTypeL11n) {
$this->l11n->title = $l11n;
} else {
$this->l11n = new ClientAttributeTypeL11n(); $this->l11n = new ClientAttributeTypeL11n();
$this->l11n->title = $l11n; $this->l11n->title = $l11n;
$this->l11n->setLanguage($lang); $this->l11n->setLanguage($lang);
} elseif ($this->l11n instanceof ClientAttributeTypeL11n && \is_string($l11n)) {
$this->l11n->title = $l11n;
} }
} }

View File

@ -41,9 +41,7 @@ class ClientAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
* @var int|ClientAttributeType * @var int|ClientAttributeType
* @since 1.0.0 * @since 1.0.0
*/ */
protected int | protected int|ClientAttributeType $type = 0;
ClientAttributeType $type = 0;
/** /**
* Language. * Language.

View File

@ -153,6 +153,13 @@ class ClientAttributeValue implements \JsonSerializable, ArrayableInterface
} }
} }
/**
* Get value
*
* @return null|int|string|float|\DateTimeInterface
*
* @since 1.0.0
*/
public function getValue() : mixed public function getValue() : mixed
{ {
if (!empty($this->valueStr)) { if (!empty($this->valueStr)) {

View File

@ -13,7 +13,7 @@
declare(strict_types=1); declare(strict_types=1);
return ['Navigation' => [ return ['Navigation' => [
'Client' => 'Client', 'Client' => 'Client',
'Region' => 'Region', 'Region' => 'Region',
'SalesRep' => 'SalesRep', 'SalesRep' => 'SalesRep',
]]; ]];

View File

@ -37,11 +37,11 @@ echo $this->getData('nav')->render();
<div class="tab-content"> <div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<form> <form>
<div class="portlet-head"><?= $this->getHtml('Filter'); ?></div> <div class="portlet-head"><?= $this->getHtml('Filter'); ?></div>
<div class="portlet-body"> <div class="portlet-body">
<div class="form-group"> <div class="form-group">
<label for="iId"><?= $this->getHtml('Client'); ?></label> <label for="iId"><?= $this->getHtml('Client'); ?></label>
@ -89,23 +89,23 @@ echo $this->getData('nav')->render();
</div> </div>
<div class="portlet-foot"><input id="iSubmitGeneral" name="submitGeneral" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"></div> <div class="portlet-foot"><input id="iSubmitGeneral" name="submitGeneral" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"></div>
</form> </form>
</section> </section>
</div> </div>
</div> </div>
</div> </div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
Sales / Customers - Monthly Sales / Customers - Monthly
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?> <?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div> </div>
<?php $salesCustomer = $this->getData('monthlySalesCustomer'); ?> <?php $salesCustomer = $this->getData('monthlySalesCustomer'); ?>
<div class="portlet-body"> <div class="portlet-body">
<canvas id="sales-region" data-chart='{ <canvas id="sales-region" data-chart='{
"type": "bar", "type": "bar",
"data": { "data": {
"labels": [ "labels": [
@ -157,10 +157,10 @@ echo $this->getData('nav')->render();
] ]
}, },
"options": { "options": {
"title": { "title": {
"display": false, "display": false,
"text": "Sales / Customers" "text": "Sales / Customers"
}, },
"scales": { "scales": {
"yAxes": [ "yAxes": [
{ {
@ -184,42 +184,42 @@ echo $this->getData('nav')->render();
} }
} }
}'></canvas> }'></canvas>
<div class="more-container"> <div class="more-container">
<input id="more-customer-sales" type="checkbox"> <input id="more-customer-sales" type="checkbox">
<label for="more-customer-sales"> <label for="more-customer-sales">
<span>Data</span> <span>Data</span>
<i class="fa fa-chevron-right expand"></i> <i class="fa fa-chevron-right expand"></i>
</label> </label>
<div> <div>
<table class="default"> <table class="default">
<thead> <thead>
<tr> <tr>
<td>Month <td>Month
<td>Sales <td>Sales
<td>Customer count <td>Customer count
<tbody> <tbody>
<?php <?php
$sum1 = 0; $sum1 = 0;
$sum2 = 0; $sum2 = 0;
foreach ($salesCustomer as $values) : foreach ($salesCustomer as $values) :
$sum1 += ((int) $values['net_sales']) / 1000; $sum1 += ((int) $values['net_sales']) / 1000;
$sum2 += ((int) $values['customers']); $sum2 += ((int) $values['customers']);
?> ?>
<tr> <tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?> <td><?= $values['month'] . '/' . \substr((string) $values['year'], -2); ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?> <td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?> <td><?= ((int) $values['customers']); ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td>Total <td>Total
<td><?= (new Money($sum1))->getCurrency(); ?> <td><?= (new Money($sum1))->getCurrency(); ?>
<td><?= (int) ($sum2 / 12); ?> <td><?= (int) ($sum2 / 12); ?>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
@ -337,15 +337,15 @@ echo $this->getData('nav')->render();
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
Customers per Region - Current Customers per Region - Current
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?> <?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div> </div>
<?php $customerRegion = $this->getData('currentCustomerRegion'); ?> <?php $customerRegion = $this->getData('currentCustomerRegion'); ?>
<div class="portlet-body"> <div class="portlet-body">
<canvas id="sales-region" data-chart='{ <canvas id="sales-region" data-chart='{
"type": "pie", "type": "pie",
"data": { "data": {
"labels": [ "labels": [
@ -371,11 +371,11 @@ echo $this->getData('nav')->render();
}] }]
}, },
"options": { "options": {
"title": { "title": {
"display": false, "display": false,
"text": "Customers per Region - Currently" "text": "Customers per Region - Currently"
} }
} }
}'></canvas> }'></canvas>
<div class="more-container"> <div class="more-container">
@ -386,27 +386,27 @@ echo $this->getData('nav')->render();
</label> </label>
<div> <div>
<table class="default"> <table class="default">
<thead> <thead>
<tr> <tr>
<td>Region <td>Region
<td>Customer count <td>Customer count
<tbody> <tbody>
<?php <?php
$sum = 0; $sum = 0;
foreach ($customerRegion as $region => $values) : $sum += $values; ?> foreach ($customerRegion as $region => $values) : $sum += $values; ?>
<tr> <tr>
<td><?= $region; ?> <td><?= $region; ?>
<td><?= $values; ?> <td><?= $values; ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td>Total <td>Total
<td><?= $sum; ?> <td><?= $sum; ?>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
@ -605,15 +605,15 @@ echo $this->getData('nav')->render();
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
Customers per Rep - Current Customers per Rep - Current
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?> <?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div> </div>
<?php $customersRep = $this->getData('currentCustomersRep'); ?> <?php $customersRep = $this->getData('currentCustomersRep'); ?>
<div class="portlet-body"> <div class="portlet-body">
<canvas id="sales-region" data-chart='{ <canvas id="sales-region" data-chart='{
"type": "horizontalBar", "type": "horizontalBar",
"data": { "data": {
"labels": [ "labels": [
@ -646,10 +646,10 @@ echo $this->getData('nav')->render();
] ]
}, },
"options": { "options": {
"title": { "title": {
"display": false, "display": false,
"text": "Customers per rep" "text": "Customers per rep"
} }
} }
}'></canvas> }'></canvas>
@ -680,8 +680,8 @@ echo $this->getData('nav')->render();
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
@ -717,15 +717,15 @@ echo $this->getData('nav')->render();
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
Customers per Country - Current Customers per Country - Current
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?> <?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div> </div>
<?php $customersCountry = $this->getData('currentCustomersCountry'); ?> <?php $customersCountry = $this->getData('currentCustomersCountry'); ?>
<div class="portlet-body"> <div class="portlet-body">
<canvas height="400px" id="sales-region" data-chart='{ <canvas height="400px" id="sales-region" data-chart='{
"type": "horizontalBar", "type": "horizontalBar",
"data": { "data": {
"labels": [ "labels": [
@ -758,10 +758,10 @@ echo $this->getData('nav')->render();
] ]
}, },
"options": { "options": {
"title": { "title": {
"display": false, "display": false,
"text": "Customers per country" "text": "Customers per country"
} }
} }
}'></canvas> }'></canvas>
@ -773,27 +773,27 @@ echo $this->getData('nav')->render();
</label> </label>
<div> <div>
<table class="default"> <table class="default">
<thead> <thead>
<tr> <tr>
<td>Country <td>Country
<td>Customer count <td>Customer count
<tbody> <tbody>
<?php <?php
$sum = 0; $sum = 0;
foreach ($customersCountry as $country => $values) : $sum += $values['customers']; ?> foreach ($customersCountry as $country => $values) : $sum += $values['customers']; ?>
<tr> <tr>
<td><?= $country; ?> <td><?= $country; ?>
<td><?= $values['customers']; ?> <td><?= $values['customers']; ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td>Total <td>Total
<td><?= $sum; ?> <td><?= $sum; ?>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
@ -831,13 +831,13 @@ echo $this->getData('nav')->render();
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
Customer per Attribute - Current Customer per Attribute - Current
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?> <?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div> </div>
<?php $customerGroups = $this->getData('customerGroups'); ?> <?php $customerGroups = $this->getData('customerGroups'); ?>
<div class="portlet-body"> <div class="portlet-body">
<div class="form-group"> <div class="form-group">
<label for="iOname"><?= $this->getHtml('Attribute'); ?></label> <label for="iOname"><?= $this->getHtml('Attribute'); ?></label>
@ -847,7 +847,7 @@ echo $this->getData('nav')->render();
</div> </div>
<div> <div>
<canvas id="sales-region" data-chart='{ <canvas id="sales-region" data-chart='{
"type": "pie", "type": "pie",
"data": { "data": {
"labels": [ "labels": [
@ -880,11 +880,11 @@ echo $this->getData('nav')->render();
}] }]
}, },
"options": { "options": {
"title": { "title": {
"display": false, "display": false,
"text": "Customers per group" "text": "Customers per group"
} }
} }
}'></canvas> }'></canvas>
</div> </div>
@ -896,27 +896,27 @@ echo $this->getData('nav')->render();
</label> </label>
<div> <div>
<table class="default"> <table class="default">
<thead> <thead>
<tr> <tr>
<td>Groups <td>Groups
<td>Customer count <td>Customer count
<tbody> <tbody>
<?php <?php
$sum = 0; $sum = 0;
foreach ($customerGroups as $groups => $values) : $sum += $values['customers']; ?> foreach ($customerGroups as $groups => $values) : $sum += $values['customers']; ?>
<tr> <tr>
<td><?= $groups; ?> <td><?= $groups; ?>
<td><?= $values['customers']; ?> <td><?= $values['customers']; ?>
<?php endforeach; ?> <?php endforeach; ?>
<tr> <tr>
<td>Total <td>Total
<td><?= $sum; ?> <td><?= $sum; ?>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
@ -1218,7 +1218,7 @@ echo $this->getData('nav')->render();
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">
@ -2283,7 +2283,7 @@ echo $this->getData('nav')->render();
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>> <input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
<div class="tab"> <div class="tab">
<div class="row"> <div class="row">
<div class="col-xs-12 col-lg-6"> <div class="col-xs-12 col-lg-6">
<section class="portlet"> <section class="portlet">
<div class="portlet-head"> <div class="portlet-head">

View File

@ -128,14 +128,14 @@ $items = $this->getData('items') ?? [];
</label> </label>
<tbody> <tbody>
<?php <?php
$count = 0; $count = 0;
foreach ($items as $key => $value) : foreach ($items as $key => $value) :
if ($value->itemNumber === '') { if ($value->itemNumber === '') {
continue; continue;
} }
++$count; ++$count;
$url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId()); $url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId());
?> ?>
<tr data-href="<?= $url; ?>"> <tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="iSalesItemSelect-<?= $key; ?>"> <td><label class="checkbox" for="iSalesItemSelect-<?= $key; ?>">

View File

@ -9,7 +9,7 @@
], ],
"require-dev": { "require-dev": {
"phpunit/phpunit": ">=9.4", "phpunit/phpunit": ">=9.4",
"friendsofphp/php-cs-fixer": ">=2.18", "friendsofphp/php-cs-fixer": ">=3.0",
"squizlabs/php_codesniffer": ">=3.5", "squizlabs/php_codesniffer": ">=3.5",
"phpmd/phpmd": ">=2.9", "phpmd/phpmd": ">=2.9",
"phpstan/phpstan": ">=0.12.58", "phpstan/phpstan": ">=0.12.58",