diff --git a/dev/build/phpstan/phpstan-baseline.neon b/dev/build/phpstan/phpstan-baseline.neon
index da315d3f2dc..2bbb031bff7 100644
--- a/dev/build/phpstan/phpstan-baseline.neon
+++ b/dev/build/phpstan/phpstan-baseline.neon
@@ -2952,12 +2952,6 @@ parameters:
count: 1
path: ../../../htdocs/compta/facture/class/facture.class.php
- -
- message: '#^Property CommonInvoice\:\:\$subtype \(int\) in isset\(\) is not nullable\.$#'
- identifier: isset.property
- count: 2
- path: ../../../htdocs/compta/facture/class/facture.class.php
-
-
message: '#^Property CommonInvoice\:\:\$totalcreditnotes \(float\|int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
@@ -5382,108 +5376,6 @@ parameters:
count: 1
path: ../../../htdocs/core/class/commonorder.class.php
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Avery_Code has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Avery_Name has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_COUNTX has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_COUNTY has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Char_Size has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_First has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Height has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Line_Height has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Margin_Left has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Margin_Top has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Metric has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Metric_Doc has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Width has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_X_Number has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_X_Space has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Y_Number has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
- -
- message: '#^Property CommonStickerGenerator\:\:\$_Y_Space has no type specified\.$#'
- identifier: missingType.property
- count: 1
- path: ../../../htdocs/core/class/commonstickergenerator.class.php
-
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@@ -9438,12 +9330,6 @@ parameters:
count: 1
path: ../../../htdocs/fourn/class/fournisseur.facture-rec.class.php
- -
- message: '#^Property CommonInvoice\:\:\$subtype \(int\) in isset\(\) is not nullable\.$#'
- identifier: isset.property
- count: 1
- path: ../../../htdocs/fourn/class/fournisseur.facture-rec.class.php
-
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
@@ -9474,12 +9360,6 @@ parameters:
count: 2
path: ../../../htdocs/fourn/class/fournisseur.facture.class.php
- -
- message: '#^Property CommonInvoice\:\:\$subtype \(int\) in isset\(\) is not nullable\.$#'
- identifier: isset.property
- count: 1
- path: ../../../htdocs/fourn/class/fournisseur.facture.class.php
-
-
message: '#^Property CommonInvoice\:\:\$totalpaid \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 8944b4318f5..23b2b1549c6 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -629,7 +629,7 @@ if ($type == Categorie::TYPE_PRODUCT) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("ProductsAndServices"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'products');
@@ -709,7 +709,7 @@ if ($type == Categorie::TYPE_CUSTOMER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Customers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
@@ -791,7 +791,7 @@ if ($type == Categorie::TYPE_SUPPLIER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Suppliers"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'companies');
@@ -875,7 +875,7 @@ if ($type == Categorie::TYPE_MEMBER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Member"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'members');
@@ -961,7 +961,7 @@ if ($type == Categorie::TYPE_CONTACT) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Contact"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'contact');
@@ -1044,7 +1044,7 @@ if ($type == Categorie::TYPE_ACCOUNT) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Banque"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'bank');
@@ -1064,8 +1064,8 @@ if ($type == Categorie::TYPE_PROJECT) {
if ($objects < 0) {
dol_print_error($db, $object->error, $object->errors);
} else {
- /** @var Project $object */
- '@phan-var-force Project $object';
+ /** @var Project[] $objects */
+ '@phan-var-force Project[] $objects';
// Form to add record into a category
print '
'."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Project"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'project');
@@ -1204,7 +1204,7 @@ if ($type == Categorie::TYPE_USER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'user');
@@ -1275,7 +1275,7 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Warehouse"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'stock');
@@ -1355,7 +1355,7 @@ if ($type == Categorie::TYPE_TICKET) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Ticket"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'ticket');
@@ -1442,7 +1442,7 @@ if ($type == Categorie::TYPE_FICHINTER) {
print '| '.$langs->trans("ThisCategoryHasNoItems").' |
';
}
print "\n";
- print ''."\n";
+ print "\n";
}
} else {
print_barre_liste($langs->trans("Intervention"), null, $_SERVER["PHP_SELF"], '', '', '', '', 0, '', 'fichinter');
@@ -1527,7 +1527,7 @@ if ($type == Categorie::TYPE_ORDER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
}
@@ -1608,7 +1608,7 @@ if ($type == Categorie::TYPE_INVOICE) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
}
@@ -1690,7 +1690,7 @@ if ($type == Categorie::TYPE_SUPPLIER_ORDER) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
}
@@ -1768,7 +1768,7 @@ if ($type == Categorie::TYPE_SUPPLIER_INVOICE) {
}
print "\n";
- print ''."\n";
+ print "\n";
}
}
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 7a80f23d626..11813560d86 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -1230,7 +1230,7 @@ if ($action == 'create') {
// Invoice subtype
if (getDolGlobalInt('INVOICE_SUBTYPE_ENABLED')) {
print "| ".$langs->trans("InvoiceSubtype")." | ";
- print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOST('subtype') : $sourceInvoice->subtype, 'subtype', 0, 0, '');
+ print $form->getSelectInvoiceSubtype(GETPOSTISSET('subtype') ? GETPOSTINT('subtype') : $sourceInvoice->subtype, 'subtype', 0, 0, '');
print " |
";
}
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 9c61b02b7a3..74d4db5672a 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -391,7 +391,7 @@ class FactureRec extends CommonInvoice
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($this->titre ? $this->titre : $this->title)."'";
$sql .= ", ".((int) $this->socid);
- $sql .= ", ".($this->subtype ? "'".$this->db->escape((string) $this->subtype)."'" : "null");
+ $sql .= ", ".(isset($this->subtype) ? (int) $this->subtype : "null");
$sql .= ", ".((int) $conf->entity);
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".(!empty($facsrc->total_ttc) ? ((float) $facsrc->total_ttc) : '0');
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 66d542f102c..c3bbee67f11 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -725,7 +725,7 @@ class Facture extends CommonInvoice
$sql .= ", ".(int) $this->entity;
$sql .= ", ".($this->ref_ext ? "'".$this->db->escape($this->ref_ext)."'" : "null");
$sql .= ", '".$this->db->escape((string) $this->type)."'";
- $sql .= ", ".($this->subtype ? "'".$this->db->escape((string) $this->subtype)."'" : "null");
+ $sql .= ", ".(isset($this->subtype) ? (int) $this->subtype : "null");
$sql .= ", ".((int) $socid);
$sql .= ", '".$this->db->idate($this->date_creation)."'";
// Date of invoice is a full day, if entered the 27-01 at 22:00 in timezone of user, it must be 27-01 00:00 after the conversion by idate, so when SQL is truncated we keep the 27-01.
@@ -2703,7 +2703,7 @@ class Facture extends CommonInvoice
$this->type = self::TYPE_STANDARD;
}
if (isset($this->subtype)) {
- $this->subtype = (int) trim((string) $this->subtype);
+ $this->subtype = (int) $this->subtype;
}
if (isset($this->ref)) {
$this->ref = trim($this->ref);
@@ -2756,7 +2756,7 @@ class Facture extends CommonInvoice
$sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
$sql .= " type=".(isset($this->type) ? $this->db->escape((string) $this->type) : "null").",";
- $sql .= " subtype=".(isset($this->subtype) ? $this->db->escape((string) $this->subtype) : "null").",";
+ $sql .= " subtype=".(isset($this->subtype) ? (int) $this->subtype : "null").",";
$sql .= " ref_client=".(!empty($this->ref_customer) ? "'".$this->db->escape($this->ref_customer)."'" : (isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null")).",";
$sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").",";
$sql .= " fk_soc=".(isset($this->socid) ? $this->db->escape((string) $this->socid) : "null").",";
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index d3f8238bf36..8451b6c3395 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -48,7 +48,7 @@ abstract class CommonInvoice extends CommonObject
public $type = self::TYPE_STANDARD;
/**
- * @var int Sub type of invoice (A subtype code coming from llx_invoice_subtype table. May be used by some countries like Greece)
+ * @var ?int Sub type of invoice (A subtype code coming from llx_invoice_subtype table, we store the rowid. May be used by some countries like Greece)
*/
public $subtype;
diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php
index 3822d62ce7b..e6e22f30798 100644
--- a/htdocs/fourn/class/fournisseur.facture-rec.class.php
+++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php
@@ -408,7 +408,7 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ', generate_pdf';
$sql .= ') VALUES (';
$sql .= "'".$this->db->escape($this->title)."'";
- $sql .= ", ".($this->subtype ? "'".$this->db->escape((string) $this->subtype)."'" : "null");
+ $sql .= ", ".(isset($this->subtype) ? (int) $this->subtype : "NULL");
$sql .= ", '".$this->db->escape($this->ref_supplier)."'";
$sql .= ", ".((int) $conf->entity);
$sql .= ", ".((int) $facfourn_src->socid);
@@ -583,7 +583,7 @@ class FactureFournisseurRec extends CommonInvoice
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_rec SET";
$sql .= " titre = '" . (!empty($this->title) ? $this->db->escape($this->title) : "")."'," ;
- $sql .= " subtype=".(isset($this->subtype) ? $this->db->escape((string) $this->subtype) : "null").",";
+ $sql .= " subtype=".(isset($this->subtype) ? (int) $this->subtype : "NULL").",";
$sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
$sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
if (!empty($this->socid) && $this->socid > 0) {
@@ -700,7 +700,7 @@ class FactureFournisseurRec extends CommonInvoice
$this->id = $obj->rowid;
$this->titre = $obj->title;
$this->title = $obj->title;
- $this->subtype = $obj->subtype;
+ $this->subtype = $obj->subtype;
$this->ref = $obj->title;
$this->ref_supplier = $obj->ref_supplier;
$this->entity = $obj->entity;
@@ -1446,16 +1446,14 @@ class FactureFournisseurRec extends CommonInvoice
$invoiceidgenerated = $new_fac_fourn->create($user);
$laststep = "Create invoiceidgenerated $invoiceidgenerated";
if ($invoiceidgenerated <= 0) {
- $this->errors = $new_fac_fourn->errors;
- $this->error = $new_fac_fourn->error;
+ $this->setErrorsFromObject($new_fac_fourn);
$error++;
}
if (!$error && ($facturerec->auto_validate || $forcevalidation)) {
$result = $new_fac_fourn->validate($user);
$laststep = "Validate by user {$user->login}";
if ($result <= 0) {
- $this->errors = $new_fac_fourn->errors;
- $this->error = $new_fac_fourn->error;
+ $this->setErrorsFromObject($new_fac_fourn);
$error++;
}
}
@@ -1467,8 +1465,7 @@ class FactureFournisseurRec extends CommonInvoice
$laststep = "GenerateDocument ".$new_fac_fourn->id;
$result = $new_fac_fourn->generateDocument($facturerec->model_pdf, $langs);
if ($result < 0) {
- $this->errors = $new_fac_fourn->errors;
- $this->error = $new_fac_fourn->error;
+ $this->setErrorsFromObject($new_fac_fourn);
$error++;
}
}
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 52e5973c75e..db1bbeb0101 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -582,7 +582,7 @@ class FactureFournisseur extends CommonInvoice
$sql .= ", '".$this->db->escape($this->ref_ext)."'";
$sql .= ", ".((int) $this->entity);
$sql .= ", '".$this->db->escape((string) $this->type)."'";
- $sql .= ", ".((int) $this->subtype);
+ $sql .= ", ".(isset($this->subtype) ? (int) $this->subtype : "null");
$sql .= ", '".$this->db->escape(isset($this->label) ? $this->label : (isset($this->libelle) ? $this->libelle : ''))."'";
$sql .= ", ".((int) $this->socid);
$sql .= ", '".$this->db->idate($now)."'";
@@ -953,7 +953,7 @@ class FactureFournisseur extends CommonInvoice
$this->ref_ext = $obj->ref_ext;
$this->entity = $obj->entity;
$this->type = empty($obj->type) ? self::TYPE_STANDARD : $obj->type;
- $this->subtype = (int) $obj->subtype;
+ $this->subtype = $obj->subtype;
$this->socid = $obj->fk_soc;
$this->date = $this->db->jdate($obj->datef);
$this->date_creation = $this->db->jdate($obj->datec);
@@ -1273,7 +1273,7 @@ class FactureFournisseur extends CommonInvoice
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
$sql .= " entity=".(isset($this->entity) ? ((int) $this->entity) : "null").",";
$sql .= " type=".(isset($this->type) ? ((int) $this->type) : "null").",";
- $sql .= " subtype=".((int) $this->subtype).",";
+ $sql .= " subtype=".(isset($this->subtype) ? (int) $this->subtype : "null").",";
$sql .= " fk_soc=".(isset($this->socid) ? ((int) $this->socid) : "null").",";
$sql .= " datec=".(dol_strlen((string) $this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " datef=".(dol_strlen((string) $this->date) != 0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 8812205707b..6610c05706a 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -175,7 +175,7 @@ class User extends CommonObject
public $personal_mobile;
/**
- * @var int 1 if admin 0 if standard user
+ * @var int<0,1> 1 if admin 0 if standard user
*/
public $admin;