phpstan, phpcs, phpunit fixes

This commit is contained in:
Dennis Eichhorn 2023-01-27 22:12:09 +01:00
parent 5584be47cf
commit 58a8ffad90
12 changed files with 29 additions and 19 deletions

View File

@ -41,7 +41,7 @@
"billing_type_is_template": { "billing_type_is_template": {
"description": "What kind of bill is it?", "description": "What kind of bill is it?",
"name": "billing_type_is_template", "name": "billing_type_is_template",
"type": "TINYINT", "type": "TINYINT(1)",
"null": false "null": false
} }
} }
@ -659,7 +659,7 @@
}, },
"billing_bill_subscription_account": { "billing_bill_subscription_account": {
"name": "billing_bill_subscription_account", "name": "billing_bill_subscription_account",
"type": "TINYINT(1)", "type": "INT",
"null": true, "null": true,
"default": null, "default": null,
"foreignTable": "account", "foreignTable": "account",

View File

@ -37,6 +37,7 @@ use Modules\Media\Models\UploadStatus;
use Modules\SupplierManagement\Models\NullSupplier; use Modules\SupplierManagement\Models\NullSupplier;
use Modules\SupplierManagement\Models\SupplierMapper; use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\Autoloader; use phpOMS\Autoloader;
use phpOMS\Localization\BaseStringL11n;
use phpOMS\Localization\ISO639x1Enum; use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Localization\Money; use phpOMS\Localization\Money;
use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpRequest;

View File

@ -622,13 +622,13 @@ class Bill implements \JsonSerializable
/** /**
* Add Bill element. * Add Bill element.
* *
* @param mixed $element Bill element * @param BillElement $element Bill element
* *
* @return void * @return void
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function addElement($element) : void public function addElement(BillElement $element) : void
{ {
$this->elements[] = $element; $this->elements[] = $element;
} }
@ -713,13 +713,13 @@ class Bill implements \JsonSerializable
/** /**
* Get media file by type * Get media file by type
* *
* @param null|int $type Media type * @param int $type Media type
* *
* @return Media * @return Media
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getFileByType(int $type = null) : Media public function getFileByType(int $type) : Media
{ {
foreach ($this->media as $file) { foreach ($this->media as $file) {
if ($file->type->getId() === $type) { if ($file->type->getId() === $type) {

View File

@ -66,7 +66,7 @@ final class BillElementMapper extends DataMapperFactory
/** /**
* Belongs to. * Belongs to.
* *
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}> * @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const BELONGS_TO = [ public const BELONGS_TO = [

View File

@ -86,7 +86,7 @@ class BillMapper extends DataMapperFactory
/** /**
* Has many relation. * Has many relation.
* *
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}> * @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const HAS_MANY = [ public const HAS_MANY = [
@ -113,7 +113,7 @@ class BillMapper extends DataMapperFactory
/** /**
* Has one relation. * Has one relation.
* *
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}> * @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const OWNS_ONE = [ public const OWNS_ONE = [
@ -130,7 +130,7 @@ class BillMapper extends DataMapperFactory
/** /**
* Belongs to. * Belongs to.
* *
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}> * @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const BELONGS_TO = [ public const BELONGS_TO = [

View File

@ -54,6 +54,8 @@ class BillType implements \JsonSerializable
*/ */
protected string | BaseStringL11n $l11n; protected string | BaseStringL11n $l11n;
public bool $isTemplate = false;
/** /**
* Constructor. * Constructor.
* *
@ -94,7 +96,8 @@ class BillType implements \JsonSerializable
if ($l11n instanceof BaseStringL11n) { if ($l11n instanceof BaseStringL11n) {
$this->l11n = $l11n; $this->l11n = $l11n;
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
$this->l11n->content = $l11n; $this->l11n->content = $l11n;
$this->l11n->setLanguage($lang);
} else { } else {
$this->l11n = new BaseStringL11n(); $this->l11n = new BaseStringL11n();
$this->l11n->content = $l11n; $this->l11n->content = $l11n;
@ -110,6 +113,10 @@ class BillType implements \JsonSerializable
*/ */
public function getL11n() : string public function getL11n() : string
{ {
if (!isset($this->l11n)) {
return '';
}
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
} }

View File

@ -59,7 +59,7 @@ final class BillTypeL11nMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var string * @var class-string
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BaseStringL11n::class; public const MODEL = BaseStringL11n::class;

View File

@ -40,12 +40,13 @@ final class BillTypeMapper extends DataMapperFactory
'billing_type_template' => ['name' => 'billing_type_template', 'type' => 'int', 'internal' => 'template'], 'billing_type_template' => ['name' => 'billing_type_template', 'type' => 'int', 'internal' => 'template'],
'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'], 'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'],
'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'], 'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'],
'billing_type_is_template' => ['name' => 'billing_type_is_template', 'type' => 'bool', 'internal' => 'isTemplate'],
]; ];
/** /**
* Belongs to. * Belongs to.
* *
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}> * @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const OWNS_ONE = [ public const OWNS_ONE = [
@ -58,7 +59,7 @@ final class BillTypeMapper extends DataMapperFactory
/** /**
* Has many relation. * Has many relation.
* *
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}> * @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0 * @since 1.0.0
*/ */
public const HAS_MANY = [ public const HAS_MANY = [
@ -74,7 +75,7 @@ final class BillTypeMapper extends DataMapperFactory
/** /**
* Belongs to. * Belongs to.
* *
* @var array<string, array{mapper:string, self:string}> * @var array<string, array{mapper:class-string, self:string}>
* @since 1.0.0 * @since 1.0.0
*/ */
/* /*
@ -89,7 +90,7 @@ final class BillTypeMapper extends DataMapperFactory
/** /**
* Model to use by the mapper. * Model to use by the mapper.
* *
* @var string * @var class-string
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = BillType::class; public const MODEL = BillType::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 string * @var class-string
* @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 string * @var class-string
* @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 string * @var class-string
* @since 1.0.0 * @since 1.0.0
*/ */
public const MODEL = Bill::class; public const MODEL = Bill::class;

View File

@ -20,6 +20,7 @@
"Admin": "1.0.0", "Admin": "1.0.0",
"Sales": "1.0.0", "Sales": "1.0.0",
"Media": "1.0.0", "Media": "1.0.0",
"Calendar": "1.0.0",
"ItemManagement": "1.0.0", "ItemManagement": "1.0.0",
"ClientManagement": "1.0.0", "ClientManagement": "1.0.0",
"SupplierManagement": "1.0.0" "SupplierManagement": "1.0.0"