fix phpstan level 4 (#29954)

* fix phpstan level 4

* fix phpstan level 4
This commit is contained in:
Frédéric FRANCE 2024-06-09 13:26:45 +02:00 committed by GitHub
parent 5d5d1ea8c5
commit acd8fdc24e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 81 additions and 79 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -339,11 +339,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
// Make substitution
$substitutionarray = array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_tva
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_tva
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
@ -424,44 +424,39 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
}
}
// Replace tags of lines
$foundtagforlines = 1;
try {
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
} catch (OdfExceptionSegmentNotFound $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
} catch (OdfException $e) {
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
$linenumber = 0;
foreach ($object->lines as $line) {
$linenumber++;
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
$listlines = $odfHandler->setSegment('lines');
} catch (OdfExceptionSegmentNotFound $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
$linenumber = 0;
foreach ($object->lines as $line) {
$linenumber++;
$tmparray = $this->get_substitutionarray_lines($line, $outputlangs, $linenumber);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}
$listlines->merge();
}
$odfHandler->mergeSegment($listlines);
$listlines->merge();
}
try {
$odfHandler->mergeSegment($listlines);
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -422,46 +422,41 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
}
}
// Replace tags of lines
$foundtagforlines = 1;
try {
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
} catch (OdfExceptionSegmentNotFound $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
} catch (OdfException $e) {
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
foreach ($object->members as $u) {
$tmparray = $this->get_substitutionarray_each_var_object($u, $outputlangs);
unset($tmparray['object_pass']);
unset($tmparray['object_pass_indatabase']);
complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
// Call the ODTSubstitutionLine hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$u);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val) {
try {
if (!is_array($val)) {
$listlines->setVars($key, $val, true, 'UTF-8');
}
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_WARNING);
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_WARNING);
$listlines = $odfHandler->setSegment('lines');
} catch (OdfExceptionSegmentNotFound $e) {
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
foreach ($object->members as $u) {
$tmparray = $this->get_substitutionarray_each_var_object($u, $outputlangs);
unset($tmparray['object_pass']);
unset($tmparray['object_pass_indatabase']);
complete_substitutions_array($tmparray, $outputlangs, $object, $user, "completesubstitutionarray_users");
// Call the ODTSubstitutionLine hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$u);
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val) {
try {
if (!is_array($val)) {
$listlines->setVars($key, $val, true, 'UTF-8');
}
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_WARNING);
}
$listlines->merge();
}
$odfHandler->mergeSegment($listlines);
$listlines->merge();
}
try {
$odfHandler->mergeSegment($listlines);
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2018 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -27,11 +28,20 @@
*/
class CdavLib
{
/**
* @var DoliDB
*/
private $db;
/**
* @var User
*/
private $user;
private $langs;
/**
* @var Translate
*/
private $langs; // @phpstan-ignore-line
/**
* Constructor

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2010-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -257,7 +258,7 @@ class ActionsCardProduct
*
* @return void
*/
private function getFieldListCanvas()
private function getFieldListCanvas() // @phpstan-ignore-line
{
global $conf, $langs;

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -773,7 +774,7 @@ class Users extends DolibarrApi
* @return array
* @throws RestException
*/
private function _validate($data)
private function _validate($data) // @phpstan-ignore-line
{
$account = array();
foreach (Users::$FIELDS as $field) {