Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qual: Fix phan/phpstan notices in class files (part 2) #31523

Merged
merged 8 commits into from
Oct 26, 2024
107 changes: 36 additions & 71 deletions dev/tools/phan/baseline.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion htdocs/admin/barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
}
}
}
'@phan-var-force array<string,ModeleBarCode> $barcodelist';
'@phan-var-force array<string,string> $barcodelist';


// Select barcode numbering module
Expand Down
41 changes: 21 additions & 20 deletions htdocs/admin/defaultvalues.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017-2020 Laurent Destailleur <[email protected]>
* Copyright (C) 2017-2018 Regis Houssin <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -141,13 +142,13 @@

if (!$error) {
if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
$object->type=$mode;
$object->user_id=0;
$object->page=$defaulturl;
$object->param=$defaultkey;
$object->value=$defaultvalue;
$object->entity=$conf->entity;
$result=$object->create($user);
$object->type = $mode;
$object->user_id = 0;
$object->page = $defaulturl;
$object->param = $defaultkey;
$object->value = $defaultvalue;
$object->entity = $conf->entity;
$result = $object->create($user);
if ($result < 0) {
$action = '';
setEventMessages($object->error, $object->errors, 'errors');
Expand All @@ -160,14 +161,14 @@
}
}
if (GETPOST('actionmodify')) {
$object->id=$id;
$object->type=$mode;
$object->page=$urlpage;
$object->param=$key;
$object->value=$value;
$object->entity=$conf->entity;
$result=$object->update($user);
if ($result<0) {
$object->id = $id;
$object->type = $mode;
$object->page = $urlpage;
$object->param = $key;
$object->value = $value;
$object->entity = $conf->entity;
$result = $object->update($user);
if ($result < 0) {
$action = '';
setEventMessages($object->error, $object->errors, 'errors');
} else {
Expand All @@ -183,9 +184,9 @@

// Delete line from delete picto
if ($action == 'delete') {
$object->id=$id;
$result=$object->delete($user);
if ($result<0) {
$object->id = $id;
$result = $object->delete($user);
if ($result < 0) {
$action = '';
setEventMessages($object->error, $object->errors, 'errors');
}
Expand Down Expand Up @@ -356,7 +357,7 @@
print '</td>'."\n";
print '</tr>'."\n";

$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode, 't.entity'=>array($user->entity,$conf->entity)));
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type' => $mode, 't.entity' => array($user->entity,$conf->entity)));

if (!is_array($result) && $result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
Expand Down Expand Up @@ -396,7 +397,7 @@
// Multicompany
print '<td>';
if (isModEnabled('multicompany')) {
print dol_escape_htmltag($defaultvalue->entity);
print dol_escape_htmltag((string) $defaultvalue->entity);
}
print '</td>';

Expand Down
3 changes: 2 additions & 1 deletion htdocs/categories/photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2014 Jean-François Ferry <[email protected]>
* Copyright (C) 2015 Raphaël Doursenaud <[email protected]>
* Copyright (C) 2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -193,7 +194,7 @@
if ($action == 'ajout_photo' && $user->hasRight('categorie', 'creer') && getDolGlobalString('MAIN_UPLOAD_DOC')) {
// Affiche formulaire upload
$formfile = new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;type='.$type, $langs->trans("AddPhoto"), 1, '', $user->hasRight('categorie', 'creer'), 50, $object, '', false, '', 0);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;type='.$type, $langs->trans("AddPhoto"), 1, 0, $user->hasRight('categorie', 'creer'), 50, $object, '', false, '', 0);
}

// Affiche photos
Expand Down
10 changes: 5 additions & 5 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,19 @@ public function insert_discount($idremise)
$line->desc = $remise->description; // Description ligne
$line->vat_src_code = $remise->vat_src_code;
$line->tva_tx = $remise->tva_tx;
$line->subprice = -$remise->amount_ht;
$line->subprice = -(float) $remise->amount_ht;
$line->fk_product = 0; // Id produit predefined
$line->qty = 1;
$line->remise_percent = 0;
$line->rang = -1;
$line->info_bits = 2;

// TODO deprecated
$line->price = -$remise->amount_ht;
$line->price = -(float) $remise->amount_ht;

$line->total_ht = -$remise->amount_ht;
$line->total_tva = -$remise->amount_tva;
$line->total_ttc = -$remise->amount_ttc;
$line->total_ht = -(float) $remise->amount_ht;
$line->total_tva = -(float) $remise->amount_tva;
$line->total_ttc = -(float) $remise->amount_ttc;

$result = $line->insert();
if ($result > 0) {
Expand Down
10 changes: 5 additions & 5 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2056,17 +2056,17 @@ public function insert_discount($idremise)
$line->desc = $remise->description; // Description ligne
$line->vat_src_code = $remise->vat_src_code;
$line->tva_tx = $remise->tva_tx;
$line->subprice = -$remise->amount_ht;
$line->price = -$remise->amount_ht;
$line->subprice = -(float) $remise->amount_ht;
$line->price = -(float) $remise->amount_ht;
$line->fk_product = 0; // Id produit predefini
$line->qty = 1;
$line->remise_percent = 0;
$line->rang = -1;
$line->info_bits = 2;

$line->total_ht = -$remise->amount_ht;
$line->total_tva = -$remise->amount_tva;
$line->total_ttc = -$remise->amount_ttc;
$line->total_ht = -(float) $remise->amount_ht;
$line->total_tva = -(float) $remise->amount_tva;
$line->total_ttc = -(float) $remise->amount_ttc;

$result = $line->insert();
if ($result > 0) {
Expand Down
16 changes: 8 additions & 8 deletions htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@ public function insert_discount($idremise)
$facligne->desc = $remise->description; // Description ligne
$facligne->vat_src_code = $remise->vat_src_code;
$facligne->tva_tx = $remise->tva_tx;
$facligne->subprice = -$remise->amount_ht;
$facligne->subprice = -(float) $remise->amount_ht;
$facligne->fk_product = 0; // Id produit predefini
$facligne->qty = 1;
$facligne->remise_percent = 0;
Expand All @@ -2689,14 +2689,14 @@ public function insert_discount($idremise)
$facligne->pa_ht = $arraytmp['pa_total'];
}

$facligne->total_ht = -$remise->amount_ht;
$facligne->total_tva = -$remise->amount_tva;
$facligne->total_ttc = -$remise->amount_ttc;
$facligne->total_ht = -(float) $remise->amount_ht;
$facligne->total_tva = -(float) $remise->amount_tva;
$facligne->total_ttc = -(float) $remise->amount_ttc;

$facligne->multicurrency_subprice = -$remise->multicurrency_subprice;
$facligne->multicurrency_total_ht = -$remise->multicurrency_amount_ht;
$facligne->multicurrency_total_tva = -$remise->multicurrency_amount_tva;
$facligne->multicurrency_total_ttc = -$remise->multicurrency_amount_ttc;
$facligne->multicurrency_subprice = -(float) $remise->multicurrency_subprice;
$facligne->multicurrency_total_ht = -(float) $remise->multicurrency_amount_ht;
$facligne->multicurrency_total_tva = -(float) $remise->multicurrency_amount_tva;
$facligne->multicurrency_total_ttc = -(float) $remise->multicurrency_amount_ttc;

$lineid = $facligne->insert();
if ($lineid > 0) {
Expand Down
6 changes: 3 additions & 3 deletions htdocs/compta/facture/class/factureligne.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ public function fetch($rowid)
/**
* Insert line into database
*
* @param int $notrigger 1 no triggers
* @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another
* @return int Return integer <0 if KO, >0 if OK
* @param int<0,1> $notrigger 1 no triggers
* @param int<0,1> $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another
* @return int Return integer <0 if KO, >0 if OK
*/
public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/ajax/ajaxdirpreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
// var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm(permtoeditline)=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm, '', $sortfield, $sortorder);
$formfile->list_of_documents($filearray, null, $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm, '', $sortfield, $sortorder);
}
}

Expand Down
23 changes: 21 additions & 2 deletions htdocs/core/class/commonorder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ abstract class CommonOrderLine extends CommonObjectLine
{
/**
* Custom label of line. Not used by default.
* @deprecated
* @deprecated Use $product_label
* @var string
*/
public $label;

/**
* Product ref
* @var string
* @deprecated Use product_ref
* @deprecated Use $product_ref
* @see $product_ref
*/
public $ref;
Expand Down Expand Up @@ -249,10 +250,28 @@ abstract class CommonOrderLine extends CommonObjectLine
*/
public $special_code = 0;

/**
* @var int
*/
public $fk_multicurrency;
/**
* @var string
*/
public $multicurrency_code;
/**
* @var float
*/
public $multicurrency_subprice;
/**
* @var float
*/
public $multicurrency_total_ht;
/**
* @var float
*/
public $multicurrency_total_tva;
/**
* @var float
*/
public $multicurrency_total_ttc;
}
7 changes: 7 additions & 0 deletions htdocs/core/class/ctypent.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2007-2011 Laurent Destailleur <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,7 +36,13 @@ class Ctypent extends CommonDict
*/
public $country_id;

/**
* @var string
*/
public $libelle;
/**
* @var string
*/
public $module;

/**
Expand Down
7 changes: 5 additions & 2 deletions htdocs/core/class/ctyperesource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function fetch($id, $code = '', $label = '')
* @param string $sortfield Sort field
* @param int $limit Limit
* @param int $offset Offset limit
* @param string|array $filter filter array
* @param string|array<string,mixed> $filter Filter array
* @param string $filtermode filter mode (AND or OR)
* @return int Return integer <0 if KO, >0 if OK
*/
Expand Down Expand Up @@ -473,7 +473,7 @@ class CtyperesourceLine
public $id;

/**
* @var mixed Sample line property 1
* @var string Sample line property 1
*/
public $code;

Expand All @@ -482,5 +482,8 @@ class CtyperesourceLine
*/
public $label;

/**
* @var int
*/
public $active;
}
Loading
Loading