fix static analysis

This commit is contained in:
Dennis Eichhorn 2023-04-11 00:20:12 +02:00
parent 587718774b
commit ac6b22c47f
20 changed files with 87 additions and 37 deletions

View File

@ -8,11 +8,14 @@ assignees: ''
--- ---
# What is the feature you request # What is the feature you request
* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] * A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
* A clear and concise description of what you want to happen. * A clear and concise description of what you want to happen.
# Alternatives # Alternatives
A clear and concise description of any alternative solutions or features you've considered. A clear and concise description of any alternative solutions or features you've considered.
# Additional Information # Additional Information
Add any other context or screenshots about the feature request here. Add any other context or screenshots about the feature request here.

View File

@ -63,7 +63,12 @@ final class Installer extends InstallerAbstract
return; return;
} }
/** @var array $types */
$types = \json_decode($fileContent, true); $types = \json_decode($fileContent, true);
if ($types === false) {
return;
}
self::createBillTypes($app, $types, $defaultTemplate); self::createBillTypes($app, $types, $defaultTemplate);
/* Tax types */ /* Tax types */
@ -72,7 +77,12 @@ final class Installer extends InstallerAbstract
return; return;
} }
/** @var array $taxes */
$taxes = \json_decode($fileContent, true); $taxes = \json_decode($fileContent, true);
if ($taxes === false) {
return;
}
self::createTaxCombination($app, $taxes); self::createTaxCombination($app, $taxes);
/* Attributes */ /* Attributes */
@ -81,7 +91,12 @@ final class Installer extends InstallerAbstract
return; return;
} }
/** @var array $attributes */
$attributes = \json_decode($fileContent, true); $attributes = \json_decode($fileContent, true);
if ($attributes === false) {
return;
}
$attrTypes = self::createBillAttributeTypes($app, $attributes); $attrTypes = self::createBillAttributeTypes($app, $attributes);
$attrValues = self::createBillAttributeValues($app, $attrTypes, $attributes); $attrValues = self::createBillAttributeValues($app, $attrTypes, $attributes);
} }

View File

@ -205,7 +205,6 @@ final class ApiBillController extends Controller
$bill->payment = 0; $bill->payment = 0;
$bill->paymentText = ''; $bill->paymentText = '';
/** @var \Modules\Billing\Modles\BillType */
$bill->type = BillTypeMapper::get() $bill->type = BillTypeMapper::get()
->where('name', 'sales_invoice') ->where('name', 'sales_invoice')
->execute(); ->execute();
@ -245,9 +244,9 @@ final class ApiBillController extends Controller
]; ];
} }
$billLanguage = $validLanguages[0]; $billLanguage = $validLanguages[0] ?? ISO639x1Enum::_EN;
$clientBillLanguage = $client->getAttribute('bill_language')?->value->getValue(); $clientBillLanguage = $client->getAttribute('bill_language')?->value->valueStr;
if (!empty($clientBillLanguage) && \in_array($clientBillLanguage, $validLanguages)) { if (!empty($clientBillLanguage) && \in_array($clientBillLanguage, $validLanguages)) {
$billLanguage = $clientBillLanguage; $billLanguage = $clientBillLanguage;
} else { } else {
@ -330,18 +329,16 @@ final class ApiBillController extends Controller
$bill = new Bill(); $bill = new Bill();
$bill->createdBy = new NullAccount($request->header->account); $bill->createdBy = new NullAccount($request->header->account);
$bill->type = $billType; $bill->type = $billType;
$bill->billTo = (string) ($request->getDataString('billto') $bill->billTo = $request->getDataString('billto') ?? (
?? ($account->account->name1 . (!empty($account->account->name2) $account->account->name1 . (!empty($account->account->name2)
? ', ' . $account->account->name2 ? ', ' . $account->account->name2
: '' : ''
))); ));
$bill->billAddress = (string) ($request->getDataString('billaddress') ?? $account->mainAddress->address); $bill->billAddress = (string) ($request->getDataString('billaddress') ?? $account->mainAddress->address);
$bill->billZip = (string) ($request->getDataString('billtopostal') ?? $account->mainAddress->postal); $bill->billZip = (string) ($request->getDataString('billtopostal') ?? $account->mainAddress->postal);
$bill->billCity = (string) ($request->getDataString('billtocity') ?? $account->mainAddress->city); $bill->billCity = (string) ($request->getDataString('billtocity') ?? $account->mainAddress->city);
$bill->billCountry = (string) ( $bill->billCountry = $request->getDataString('billtocountry') ?? (
$request->getDataString('billtocountry') ?? ( ($country = $account->mainAddress->getCountry()) === ISO3166TwoEnum::_XXX ? '' : $country);
($country = $account->mainAddress->getCountry()) === ISO3166TwoEnum::_XXX ? '' : $country)
);
$bill->client = !$request->hasData('client') ? null : $account; $bill->client = !$request->hasData('client') ? null : $account;
$bill->supplier = !$request->hasData('supplier') ? null : $account; $bill->supplier = !$request->hasData('supplier') ? null : $account;
$bill->performanceDate = $request->getDataDateTime('performancedate') ?? new \DateTime('now'); $bill->performanceDate = $request->getDataDateTime('performancedate') ?? new \DateTime('now');
@ -933,7 +930,7 @@ final class ApiBillController extends Controller
} }
$model = $response->get($request->uri->__toString())['response']; $model = $response->get($request->uri->__toString())['response'];
$this->createModelRelation($request->header->account, $request->getData('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin()); $this->createModelRelation($request->header->account, $request->getDataInt('id'), $model->getId(), BillMapper::class, 'bill_note', '', $request->getOrigin());
} }
/** /**

View File

@ -84,7 +84,7 @@ final class ApiPriceController extends Controller
$supplier = null; $supplier = null;
if ($request->hasData('price_client')) { if ($request->hasData('price_client')) {
/** @var null|\Modules\ClientManagement\Models\Client $client */ /** @var \Modules\ClientManagement\Models\Client $client */
$client = ClientMapper::get() $client = ClientMapper::get()
->with('attributes') ->with('attributes')
->with('attributes/type') ->with('attributes/type')
@ -92,10 +92,10 @@ final class ApiPriceController extends Controller
->where('id', (int) $request->getData('price_client')) ->where('id', (int) $request->getData('price_client'))
->execute(); ->execute();
/** @var null|\Modules\ClientManagement\Models\Client|\Modules\SupplierManagement\Models\Supplier $account */ /** @var \Modules\ClientManagement\Models\Client */
$account = $client; $account = $client;
} else { } else {
/** @var null|\Modules\SupplierManagement\Models\Supplier $supplier */ /** @var \Modules\SupplierManagement\Models\Supplier $supplier */
$supplier = SupplierMapper::get() $supplier = SupplierMapper::get()
->with('attributes') ->with('attributes')
->with('attributes/type') ->with('attributes/type')
@ -103,7 +103,7 @@ final class ApiPriceController extends Controller
->where('id', (int) $request->getData('price_supplier')) ->where('id', (int) $request->getData('price_supplier'))
->execute(); ->execute();
/** @var null|\Modules\ClientManagement\Models\Client|\Modules\SupplierManagement\Models\Supplier $account */ /** @var \Modules\SupplierManagement\Models\Supplier $account */
$account = $supplier; $account = $supplier;
} }

View File

@ -126,13 +126,15 @@ final class BackendController extends Controller
$view->setData('bill', $bill); $view->setData('bill', $bill);
/** @var \Modules\Auditor\Models\Auditor[] $logsBill */
$logsBill = AuditMapper::getAll() $logsBill = AuditMapper::getAll()
->with('createdBy') ->with('createdBy')
->where('module', 'Billing') ->where('module', 'Billing')
->where('type', StringUtils::intHash(BillMapper::class)) ->where('type', StringUtils::intHash(BillMapper::class))
->where('ref', $bill->getId()) ->where('ref', $bill->getId())
->execute(); ->execute();
/** @var \Modules\Auditor\Models\Auditor[] $logsElements */
$logsElements = AuditMapper::getAll() $logsElements = AuditMapper::getAll()
->with('createdBy') ->with('createdBy')
->where('module', 'Billing') ->where('module', 'Billing')

View File

@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of Attribute
* @extends DataMapperFactory<T>
*/ */
final class BillAttributeMapper extends DataMapperFactory final class BillAttributeMapper extends DataMapperFactory
{ {
@ -60,7 +63,7 @@ final class BillAttributeMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Attribute::class; public const MODEL = Attribute::class;

View File

@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/ */
final class BillAttributeTypeL11nMapper extends DataMapperFactory final class BillAttributeTypeL11nMapper extends DataMapperFactory
{ {
@ -59,7 +62,7 @@ final class BillAttributeTypeL11nMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BaseStringL11n::class; public const MODEL = BaseStringL11n::class;

View File

@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of AttributeType
* @extends DataMapperFactory<T>
*/ */
final class BillAttributeTypeMapper extends DataMapperFactory final class BillAttributeTypeMapper extends DataMapperFactory
{ {
@ -68,7 +71,7 @@ final class BillAttributeTypeMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = AttributeType::class; public const MODEL = AttributeType::class;

View File

@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/ */
final class BillAttributeValueL11nMapper extends DataMapperFactory final class BillAttributeValueL11nMapper extends DataMapperFactory
{ {
@ -59,7 +62,7 @@ final class BillAttributeValueL11nMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BaseStringL11n::class; public const MODEL = BaseStringL11n::class;

View File

@ -24,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of AttributeValue
* @extends DataMapperFactory<T>
*/ */
final class BillAttributeValueMapper extends DataMapperFactory final class BillAttributeValueMapper extends DataMapperFactory
{ {
@ -63,7 +66,7 @@ final class BillAttributeValueMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = AttributeValue::class; public const MODEL = AttributeValue::class;

View File

@ -86,10 +86,10 @@ class Bill implements \JsonSerializable
/** /**
* Bill created at. * Bill created at.
* *
* @var null|\DateTime * @var \DateTime
* @since 1.0.0 * @since 1.0.0
*/ */
public ?\DateTime $billDate = null; public \DateTime $billDate;
/** /**
* Bill created at. * Bill created at.
@ -463,6 +463,7 @@ class Bill implements \JsonSerializable
$this->netDiscount = new Money(0); $this->netDiscount = new Money(0);
$this->grossDiscount = new Money(0); $this->grossDiscount = new Money(0);
$this->billDate = new \DateTime('now');
$this->createdAt = new \DateTimeImmutable(); $this->createdAt = new \DateTimeImmutable();
$this->createdBy = new NullAccount(); $this->createdBy = new NullAccount();
$this->referral = new NullAccount(); $this->referral = new NullAccount();

View File

@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of BillElement
* @extends DataMapperFactory<T>
*/ */
final class BillElementMapper extends DataMapperFactory final class BillElementMapper extends DataMapperFactory
{ {

View File

@ -30,6 +30,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of Bill
* @extends DataMapperFactory<T>
*/ */
class BillMapper extends DataMapperFactory class BillMapper extends DataMapperFactory
{ {

View File

@ -24,6 +24,9 @@ use phpOMS\Localization\BaseStringL11n;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of BaseStringL11n
* @extends DataMapperFactory<T>
*/ */
final class BillTypeL11nMapper extends DataMapperFactory final class BillTypeL11nMapper extends DataMapperFactory
{ {
@ -59,7 +62,7 @@ final class BillTypeL11nMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BaseStringL11n::class; public const MODEL = BaseStringL11n::class;

View File

@ -15,7 +15,6 @@ declare(strict_types=1);
namespace Modules\Billing\Models; namespace Modules\Billing\Models;
use Modules\Media\Models\CollectionMapper; use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/** /**
@ -25,6 +24,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of BillType
* @extends DataMapperFactory<T>
*/ */
final class BillTypeMapper extends DataMapperFactory final class BillTypeMapper extends DataMapperFactory
{ {
@ -97,7 +99,7 @@ final class BillTypeMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BillType::class; public const MODEL = BillType::class;

View File

@ -14,9 +14,9 @@ declare(strict_types=1);
namespace Modules\Billing\Models\Price; namespace Modules\Billing\Models\Price;
use Modules\Attribute\Models\AttributeValueMapper;
use Modules\ClientManagement\Models\ClientAttributeValueMapper; use Modules\ClientManagement\Models\ClientAttributeValueMapper;
use Modules\ClientManagement\Models\ClientMapper; use Modules\ClientManagement\Models\ClientMapper;
use Modules\Attribute\Models\AttributeValueMapper;
use Modules\ItemManagement\Models\ItemMapper; use Modules\ItemManagement\Models\ItemMapper;
use Modules\SupplierManagement\Models\SupplierMapper; use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
@ -29,6 +29,9 @@ use phpOMS\Localization\Defaults\CountryMapper;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of Price
* @extends DataMapperFactory<T>
*/ */
final class PriceMapper extends DataMapperFactory final class PriceMapper extends DataMapperFactory
{ {
@ -131,7 +134,7 @@ final class PriceMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Price::class; public const MODEL = Price::class;

View File

@ -32,7 +32,7 @@ final class PurchaseBillMapper extends BillMapper
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Bill::class; public const MODEL = Bill::class;

View File

@ -32,7 +32,7 @@ final class SalesBillMapper extends BillMapper
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Bill::class; public const MODEL = Bill::class;

View File

@ -29,7 +29,7 @@ final class StockBillMapper extends BillMapper
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Bill::class; public const MODEL = Bill::class;

View File

@ -14,8 +14,8 @@ declare(strict_types=1);
namespace Modules\Billing\Models\Tax; namespace Modules\Billing\Models\Tax;
use Modules\ClientManagement\Models\ClientAttributeValueMapper;
use Modules\Attribute\Models\AttributeValueMapper; use Modules\Attribute\Models\AttributeValueMapper;
use Modules\ClientManagement\Models\ClientAttributeValueMapper;
use Modules\SupplierManagement\Models\SupplierAttributeValueMapper; use Modules\SupplierManagement\Models\SupplierAttributeValueMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
@ -26,6 +26,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
* @license OMS License 2.0 * @license OMS License 2.0
* @link https://jingga.app * @link https://jingga.app
* @since 1.0.0 * @since 1.0.0
*
* @template T of TaxCombination
* @extends DataMapperFactory<T>
*/ */
final class TaxCombinationMapper extends DataMapperFactory final class TaxCombinationMapper extends DataMapperFactory
{ {
@ -75,7 +78,7 @@ final class TaxCombinationMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var class-string * @var class-string<T>
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = TaxCombination::class; public const MODEL = TaxCombination::class;