fix phpstan sendXXX expects int (#30519)

* fix sendXXX expects int

* fix sendEmailTo expects int

* fix regression

* fix loadxxx expects int

* fix loadxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int

* fix getxxx expects int
This commit is contained in:
Frédéric FRANCE 2024-08-13 20:39:40 +02:00 committed by GitHub
parent a9f93f35c7
commit 803c3c2f30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 33 additions and 30 deletions

View File

@ -169,7 +169,7 @@ if (!getDolGlobalString('MAIN_MAIL_SENDMODE')) {
$conf->global->MAIN_MAIL_SENDMODE = 'mail';
}
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT', ini_get('smtp_port'));
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT', (int) ini_get('smtp_port'));
if (!$port) {
$port = 25;
}

View File

@ -140,7 +140,7 @@ if (preg_match('/^mac/i', PHP_OS)) {
if (!getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')) {
$conf->global->MAIN_MAIL_SENDMODE_EMAILING = 'default';
}
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_EMAILING', ini_get('smtp_port'));
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_EMAILING', (int) ini_get('smtp_port'));
if (!$port) {
$port = 25;
}

View File

@ -138,7 +138,7 @@ if (preg_match('/^mac/i', PHP_OS)) {
if (!getDolGlobalString('MAIN_MAIL_SENDMODE_PASSWORDRESET')) {
$conf->global->MAIN_MAIL_SENDMODE_PASSWORDRESET = 'default';
}
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_PASSWORDRESET', ini_get('smtp_port'));
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_PASSWORDRESET', (int) ini_get('smtp_port'));
if (!$port) {
$port = 25;
}

View File

@ -138,7 +138,7 @@ if (preg_match('/^mac/i', PHP_OS)) {
if (!getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')) {
$conf->global->MAIN_MAIL_SENDMODE_TICKET = 'default';
}
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', ini_get('smtp_port'));
$port = getDolGlobalInt('MAIN_MAIL_SMTP_PORT_TICKET', (int) ini_get('smtp_port'));
if (!$port) {
$port = 25;
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Alice Adminson <aadminson@example.com>
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Alice Adminson <aadminson@example.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
@ -248,7 +249,7 @@ if ($action == 'create') {
exit;
}
print load_fiche_titre($langs->trans("NewAvailabilities"), '', '', 'object_'.$object->picto);
print load_fiche_titre($langs->trans("NewAvailabilities"), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
if ($error != 0) {

View File

@ -309,7 +309,8 @@ abstract class CommonDocGenerator
$mysoc->country = $outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code);
}
if (empty($mysoc->state) && !empty($mysoc->state_code)) {
$mysoc->state = getState($mysoc->state_code, '0');
$state_id = dol_getIdFromCode($this->db, $mysoc->state_code, 'c_departements', 'code_departement', 'rowid');
$mysoc->state = getState($state_id, '0');
}
$logotouse = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
@ -365,7 +366,8 @@ abstract class CommonDocGenerator
$object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code);
}
if (empty($object->state) && !empty($object->state_code)) {
$object->state = getState($object->state_code, '0');
$state_id = dol_getIdFromCode($this->db, $object->state_code, 'c_departements', 'code_departement', 'rowid');
$object->state = getState($state_id, '0');
}
$array_thirdparty = array(
@ -431,7 +433,8 @@ abstract class CommonDocGenerator
$object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code);
}
if (empty($object->state) && !empty($object->state_code)) {
$object->state = getState($object->state_code, '0');
$state_id = dol_getIdFromCode($this->db, $object->state_code, 'c_departements', 'code_departement', 'rowid');
$object->state = getState($state_id, '0');
}
$array_contact = array(

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2020-2024 Laurent Destailleur <eldy@users.sourceforge.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

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
@ -2385,7 +2385,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// Fields to show current time
$tableCell = '';
$modeinput = 'hours';
$TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
$TFirstDay = getFirstDayOfEachWeek($TWeek, (int) date('Y', $firstdaytoshow));
$TFirstDay[reset($TWeek)] = 1;
$firstdaytoshowarray = dol_getdate($firstdaytoshow);

View File

@ -1260,7 +1260,7 @@ class pdf_crabe extends ModelePDFFactures
$langs->loadLangs(array('payment', 'paybox', 'stripe'));
$servicename = $langs->transnoentities('Online');
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', '');
$paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0);
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
$pdf->SetXY($this->marge_gauche, $posy);

View File

@ -1462,7 +1462,7 @@ class pdf_octopus extends ModelePDFFactures
$langs->loadLangs(array('payment', 'paybox', 'stripe'));
$servicename = $langs->transnoentities('Online');
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', '');
$paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0);
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
$pdf->SetXY($this->marge_gauche, $posy);

View File

@ -1360,7 +1360,7 @@ class pdf_sponge extends ModelePDFFactures
$langs->loadLangs(array('payment', 'paybox', 'stripe'));
$servicename = $langs->transnoentities('Online');
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, 0, '', '');
$paiement_url = getOnlinePaymentUrl(0, 'invoice', $object->ref, 0, '', 0);
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' <a href="'.$paiement_url.'">'.$outputlangs->transnoentities("ClickHere").'</a>';
$pdf->SetXY($this->marge_gauche, $posy);

View File

@ -113,7 +113,7 @@ function getDParameters($part)
*
* @param integer $jk Number of email
* @param object $mbox object connection imap
* @return array<array{type:string,filename:string,pos:int}> type, filename, pos
* @return array<array{type:int,filename:string,pos:int}> type, filename, pos
*/
function getAttachments($jk, $mbox)
{

View File

@ -2224,7 +2224,7 @@ class Project extends CommonObject
$obj = $this->db->fetch_object($resql);
if (!empty($obj->element_date)) {
$date = explode('-', $obj->element_date);
$week_number = getWeekNumber($date[2], $date[1], $date[0]);
$week_number = getWeekNumber((int) $date[2], (int) $date[1], (int) $date[0]);
}
'@phan-var-force int $week_number'; // Needed because phan considers it might be null
if (empty($weekalreadyfound[$week_number])) {

View File

@ -910,7 +910,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer') && (empty($object-
$linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss' => 'reposition marginleftonly'));
//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask', '', '', '', $massactionbutton);
print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask', 0, '', '', $massactionbutton);
$objecttmp = new Task($db);
$trackid = 'task'.$taskstatic->id;

View File

@ -4381,10 +4381,11 @@ class Societe extends CommonObject
//TODO This could be replicated for region but function `getRegion` didn't exist, so I didn't added it.
// We define state_id, state_code and state
$state_id = 0;
$state_code = $state_label = '';
$state_code = '';
$state_label = '';
if (getDolGlobalString('MAIN_INFO_SOCIETE_STATE')) {
$tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_STATE'));
$state_id = $tmp[0];
$state_id = (int) $tmp[0];
if (!empty($tmp[1])) { // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label"
$state_code = $tmp[1];
$state_label = $tmp[2];

View File

@ -72,17 +72,13 @@ parameters:
- '#expects int\|null#'
- '#expects int<-2, 2>, bool given.#'
- '#expects int<0, 1>#'
- '#load.* expects int, string#'
- '#ajax.* expects int, string#'
- '#measu.* expects int, string#'
- '#color.* expects int, string#'
- '#imap.* expects int, string#'
- '#show.* expects int, string#'
- '#dol.* expects int, string#'
- '#get.* expects int, string#'
- '#send.* expects int, string#'
- '#convert.* expects int, string#'
#- '#constructor expects int, string#'
- '#\(\) expects int, string#'
- '#run_sql expects int, string#'
- '#expects int, float#'

View File

@ -1,10 +1,11 @@
#!/usr/bin/env php
<?php
/*
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -153,7 +154,7 @@ if ($resql) {
if ($startbreak) {
// Break onto sales representative (new email or cid)
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) {
sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, $duration_value);
sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, (int) $duration_value);
$trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else {
if ($oldemail != 'none') {
@ -207,7 +208,7 @@ if ($resql) {
// If there are remaining messages to send in the buffer
if ($foundtoprocess) {
if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) { // Break onto email (new email)
sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, $duration_value);
sendEmailTo($mode, $oldemail, $message, $total, $oldlang, $oldtarget, (int) $duration_value);
$trackthirdpartiessent[$oldsid.'|'.$oldemail] = 'contact id '.$oldcid;
} else {
if ($oldemail != 'none') {