Merge pull request #29143 from mdeweerd/fix/phpstan4

Fix Multiple fixes inspired by phpstan level 5 and phan
This commit is contained in:
Laurent Destailleur 2024-03-31 13:56:24 +02:00 committed by GitHub
commit 21bedea607
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 112 additions and 107 deletions

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* 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
@ -86,7 +87,7 @@ if ($action == 'updateform') {
if (!preg_match('/^0/', $tmpumask)) {
$tmpumask = '0'.$tmpumask;
}
if (empty($tmpumask) || $tmpumask === '0') {
if (empty($tmpumask)) { // Also matches '0'
$tmpumask = '0664';
}

View file

@ -7,6 +7,7 @@
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
* Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024 Jon Bendtsen <jon.bendtsen.github@jonb.dk>
* 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
@ -213,7 +214,7 @@ class Notify
$texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("NoNotificationsWillBeSent");
} elseif ($nb == 1) {
$texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("ANotificationsWillBeSent");
} elseif ($nb >= 2) {
} else { // Always >= 2 if ($nb >= 2) {
$texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("SomeNotificationsWillBeSent", $nb);
}
@ -485,7 +486,7 @@ class Notify
$newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
$resarray[$newval2] = array('type' => 'tocontact', 'code' => trim($obj->code), 'emaildesc' => 'Contact id '.$obj->rowid, 'email' => $newval2, 'contactid' => $obj->rowid, 'isemailvalid' => $isvalid);
}
}
$i++;
@ -524,7 +525,7 @@ class Notify
$newval2 = trim($obj->email);
$isvalid = isValidEmail($newval2);
if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
$resarray[$newval2] = array('type' => 'touser', 'code' => trim($obj->code), 'emaildesc' => 'User id '.$obj->rowid, 'email' => $newval2, 'userid' => $obj->rowid, 'isemailvalid' => $isvalid);
}
}
$i++;
@ -575,7 +576,7 @@ class Notify
if ($newval2) {
$isvalid = isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) {
$resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
$resarray[$newval2] = array('type' => 'tofixedemail', 'code' => trim($key), 'emaildesc' => trim($val2), 'email' => $newval2, 'isemailvalid' => $isvalid);
}
}
}
@ -889,7 +890,7 @@ class Notify
$dir_output = $conf->$object_type->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object, $object_type);
$template = $notifcode.'_TEMPLATE';
$mesg = $outputlangs->transnoentitiesnoconv('Notify_'.$notifcode).' '.$newref.' '.$dir_output;
break;
break;
}
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
@ -915,7 +916,7 @@ class Notify
$ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref.".pdf";
if (!dol_is_file($pdf_path)||(is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
if (!dol_is_file($pdf_path) || (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) {
// We can't add PDF as it is not generated yet.
$filepdf = '';
} else {
@ -944,7 +945,7 @@ class Notify
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
}
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse);
$parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'replyto' => $replyto, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'outputlangs' => $outputlangs, 'labeltouse' => $labeltouse);
if (!isset($action)) {
$action = '';
}
@ -1210,7 +1211,7 @@ class Notify
}
if ($sendto) {
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'subject'=>&$subject, 'message'=>&$message);
$parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'replyto' => $replyto, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'subject' => &$subject, 'message' => &$message);
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
if (!empty($hookmanager->resArray['files'])) {

View file

@ -75,9 +75,9 @@ if (defined('PHP-BARCODE_PATH_COMMAND')) {
*
* @param string $code Code
* @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...)
* @param integer $scale Scale
* @param int<1,max> $scale Scale
* @param string $mode 'png' or 'jpg' ...
* @return array|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
* @return array{encoding:string,bars:string,text:string}|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
*/
function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
{
@ -124,7 +124,7 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
*
* @param string $code Code
* @param string $encoding Encoding
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
* @return array{encoding:string,bars:string,text:string}|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
*/
function barcode_encode($code, $encoding)
{
@ -172,7 +172,7 @@ function barcode_encode($code, $encoding)
* Calculate EAN sum
*
* @param string $ean EAN to encode
* @return integer Sum
* @return int<0,9> EAN Sum
*/
function barcode_gen_ean_sum($ean)
{
@ -206,8 +206,8 @@ function barcode_gen_ean_bars($ean)
$line = $guards[0];
for ($i = 1; $i < 13; $i++) {
$str = $digits[$ean[$i]];
if ($i < 7 && $mirror[$ean[0]][$i - 1] == 1) {
$str = $digits[(int) $ean[$i]];
if ($i < 7 && $mirror[(int) $ean[0]][$i - 1] == 1) {
$line .= strrev($str);
} else {
$line .= $str;
@ -226,7 +226,7 @@ function barcode_gen_ean_bars($ean)
*
* @param string $ean Code
* @param string $encoding Encoding
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)
* @return array{encoding:string,bars:string,text:string,error:string}|array{text:string,error:string} array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)
*/
function barcode_encode_ean($ean, $encoding = "EAN-13")
{
@ -282,7 +282,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
*
* @param string $upc Code
* @param string $encoding Encoding
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)
* @return array{encoding:string,bars:string,text:string,error:string}|array{text:string,error:string} array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info, 'error': error message if error)
*/
function barcode_encode_upc($upc, $encoding = "UPC")
{
@ -332,7 +332,7 @@ function barcode_encode_upc($upc, $encoding = "UPC")
*
* @param string $code Code
* @param string $encoding Encoding
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
* @return array{encoding:string,bars:string,text:string}|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
*/
function barcode_encode_genbarcode($code, $encoding)
{
@ -403,10 +403,10 @@ function barcode_encode_genbarcode($code, $encoding)
*
* @param string $text the text-line (<position>:<font-size>:<character> ...)
* @param string $bars where to place the bars (<space-width><bar-width><space-width><bar-width>...)
* @param int $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!))
* @param int<1,max> $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!))
* @param string $mode png,gif,jpg (default='png')
* @param int $total_y the total height of the image ( default: scale * 60 )
* @param array $space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale;
* @param array{}|array{top:int,bottom:int,left:int,right:int} $space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale;
* @return string|void
*/
function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = [])
@ -424,7 +424,7 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
if ($total_y < 1) {
$total_y = (int) $scale * 60;
}
if (!$space) {
if (!is_array($space) || empty($space)) {
$space = array('top' => 2 * $scale, 'bottom' => 2 * $scale, 'left' => 2 * $scale, 'right' => 2 * $scale);
}
@ -435,7 +435,7 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
for ($i = 0; $i < $ln; $i++) {
$val = strtolower($bars[$i]);
if ($width) {
$xpos += $val * $scale;
$xpos += (int) $val * $scale;
$width = false;
continue;
}

View file

@ -8992,8 +8992,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
* $mesg = make_substitutions($mesg, $substitutionarray, $langs);
*
* @param string $text Source string in which we must do substitution
* @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
* @param Translate $outputlangs Output language
* @param array<string,string> $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
* @param ?Translate $outputlangs Output language
* @param int $converttextinhtmlifnecessary 0=Convert only value into HTML if text is already in HTML
* 1=Will also convert initial $text into HTML if we try to insert one value that is HTML
* @return string Output string after substitutions

View file

@ -31,9 +31,9 @@
* @param string $objectname Name of object
* @param string $newmask New mask
* @param string $readdir Directory source (use $destdir when not defined)
* @param array $addfieldentry Array of 1 field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure')
* @param array{}|array{name:string,key:string,type:string,label:string,picot?:string,enabled:int<0,1>,notnull:int<0,1>,position:int,visible:int,noteditable?:int<0,1>,alwayseditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int<0,1>,css?:string,cssview?:string,csslist?:string,help?:string,showoncombobox?:int<0,1>,disabled?:int<0,1>,autofocusoncreate?:int<0,1>,arrayofkeyval?:array<string,string>,validate?:int<0,1>,comment?:string} $addfieldentry Array of 1 field entry to add
* @param string $delfieldentry Id of field to remove
* @return int|object Return integer <=0 if KO, Object if OK
* @return int<-7,-1>|CommonObject Return integer <=0 if KO, Object if OK
* @see rebuildObjectSql()
*/
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
@ -89,6 +89,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
} else {
return -4;
}
'@phan-var-force CommonObject $object';
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
@ -138,7 +139,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
if (!empty($val['alwayseditable'])) {
$texttoinsert .= ' "alwayseditable"=>"'.dol_escape_php($val['alwayseditable']).'",';
}
if (!empty($val['default']) || (isset($val['default']) && $val['default'] === '0')) {
if (array_key_exists('default', $val) && (!empty($val['default']) || $val['default'] === '0')) {
$texttoinsert .= ' "default"=>"'.dol_escape_php($val['default']).'",';
}
if (!empty($val['index'])) {
@ -549,11 +550,11 @@ function compareFirstValue($a, $b)
* @param string $file filename or path
* @param array<int,string[]> $permissions permissions existing in file
* @param int|null $key key for permission needed
* @param array|null $right $right to update or add
* @param array{0:string,1:string}|null $right $right to update or add
* @param string|null $objectname name of object
* @param string|null $module name of module
* @param int<-2,2> $action 0 for delete, 1 for add, 2 for update, -1 when delete object completely, -2 for generate rights after add
* @return int 1 if OK,-1 if KO
* @return int<-1,1> 1 if OK,-1 if KO
*/
function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $module, $action)
{
@ -672,7 +673,7 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $
* Converts a formatted properties string into an associative array.
*
* @param string $string The formatted properties string.
* @return array The resulting associative array.
* @return array<string,bool|int|float|string|mixed[]> The resulting associative array.
*/
function parsePropertyString($string)
{
@ -874,7 +875,7 @@ function getFromFile($file, $start, $end)
* Write all permissions of each object in AsciiDoc format
* @param string $file path of the class
* @param string $destfile file where write table of permissions
* @return int 1 if OK, -1 if KO
* @return int<-1,1> 1 if OK, -1 if KO
*/
function writePermsInAsciiDoc($file, $destfile)
{
@ -959,9 +960,9 @@ function writePermsInAsciiDoc($file, $destfile)
*
* @param string $srcfile Source file to use as example
* @param string $file Path of modified file
* @param array $objects Array of objects in the module
* @param string[] $objects Array of objects in the module
* @param string $modulename Name of module
* @return int Return 1 if OK, -1 if KO
* @return int<-1,1> Return 1 if OK, -1 if KO
*/
function addObjectsToApiFile($srcfile, $file, $objects, $modulename)
{
@ -1044,9 +1045,9 @@ function addObjectsToApiFile($srcfile, $file, $objects, $modulename)
* Remove Object variables and methods from API_Module File
*
* @param string $file File api module
* @param array $objects Array of objects in the module
* @param string[] $objects Array of objects in the module
* @param string $objectname Name of object want to remove
* @return int 1 if OK, -1 if KO
* @return int<-1,1> 1 if OK, -1 if KO
*/
function removeObjectFromApiFile($file, $objects, $objectname)
{
@ -1091,12 +1092,12 @@ function removeObjectFromApiFile($file, $objects, $objectname)
/**
* @param string $file path of filename
* @param mixed $menus all menus for module
* @param mixed|null $menuWantTo menu get for do actions
* @param int|null $key key for the concerned menu
* @param int $action for specify what action (0 = delete, 1 = add, 2 = update, -1 = when delete object)
* @return int 1 if OK, -1 if KO
* @param string $file path of filename
* @param array<int,array{fk_menu:string,type:string,titre:string,mainmenu:string,leftmenu:string,url:string,langs:string,position:int,enabled:int,perms:string,target:string,user:int}> $menus all menus for module
* @param mixed|null $menuWantTo menu get for do actions
* @param int|null $key key for the concerned menu
* @param int<-1,2> $action for specify what action (0 = delete, 1 = add, 2 = update, -1 = when delete object)
* @return int<-1,1> 1 if OK, -1 if KO
*/
function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action)
{
@ -1194,7 +1195,7 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action)
*
* @param string $module The name of the module.
* @param string $file The path to the module descriptor file.
* @param array $dicts The dictionary data to be updated.
* @param array<string,string|array<string,int|string>> $dicts The dictionary data to be updated.
* @return int Returns the number of replacements made in the file.
*/
function updateDictionaryInFile($module, $file, $dicts)
@ -1267,8 +1268,8 @@ function updateDictionaryInFile($module, $file, $dicts)
* @param string $modulename The lowercase name of the module for which the dictionary table is being created.
* @param string $file The file path to the Dolibarr module builder file where the dictionaries are defined.
* @param string $namedic The name of the dictionary, which will also be used as the base for the table name.
* @param array|null $dictionnaires An optional array containing pre-existing dictionary data, including 'tabname', 'tablib', 'tabsql', etc.
* @return int|void Return int < 0 if error, return nothing on success
* @param array<string,string|array<string,int|string>> $dictionnaires An optional array containing pre-existing dictionary data, including 'tabname', 'tablib', 'tabsql', etc.
* @return int<-1,-1>|void Return int < 0 if error, return nothing on success
*/
function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = null)
{
@ -1289,10 +1290,10 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul
$columns = array(
'rowid' => array('type' => 'integer', 'value' => 11, 'extra' => 'AUTO_INCREMENT'),
'code' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'),
'label' => array('type' => 'varchar', 'value' => 255, 'null'=>'NOT NULL'),
'position' => array('type' => 'integer', 'value' => 11, 'null'=>'NULL'),
'use_default' => array('type' => 'varchar', 'value' => 11, 'default'=>'1'),
'code' => array('type' => 'varchar', 'value' => 255, 'null' => 'NOT NULL'),
'label' => array('type' => 'varchar', 'value' => 255, 'null' => 'NOT NULL'),
'position' => array('type' => 'integer', 'value' => 11, 'null' => 'NULL'),
'use_default' => array('type' => 'varchar', 'value' => 11, 'default' => '1'),
'active' => array('type' => 'integer', 'value' => 3)
);
@ -1348,7 +1349,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul
*
* @param string $file_api filename or path of api
* @param string $file_doc filename or path of documentation
* @return int -1 if KO, 1 if OK, 0 if nothing change
* @return int<-1,1> -1 if KO, 1 if OK, 0 if nothing change
*/
function writeApiUrlsInDoc($file_api, $file_doc)
{

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* 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
@ -160,7 +161,7 @@ class pdf_standard_actions
global $action;
$object = new stdClass();
$parameters = array('file'=>$file, 'outputlangs'=>$outputlangs);
$parameters = array('file' => $file, 'outputlangs' => $outputlangs);
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$pdf = pdf_getInstance($this->format);
@ -204,7 +205,7 @@ class pdf_standard_actions
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
$parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@ -214,7 +215,7 @@ class pdf_standard_actions
dolChmod($file);
$this->result = array('fullpath'=>$file);
$this->result = array('fullpath' => $file);
return 1;
}
@ -355,7 +356,7 @@ class pdf_standard_actions
* @param TCPDF $pdf Object PDF
* @param Translate $outputlangs Object lang for output
* @param int $pagenb Page nb
* @return float|int Return topshift value
* @return float Return topshift value
*/
private function _pagehead(&$pdf, $outputlangs, $pagenb)
{

View file

@ -5,6 +5,7 @@
* Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
* Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
* 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,16 +154,16 @@ $fk_usergroup1 = GETPOST('fk_usergroup1');
</tr>
<tr>
<td><?php
echo $langs->trans('OrJobToCompare') . '</td><td>';
$j = new Job($db);
$jobs = $j->fetchAll();
$TJobs = array();
echo $langs->trans('OrJobToCompare') . '</td><td>';
$j = new Job($db);
$jobs = $j->fetchAll();
$TJobs = array();
foreach ($jobs as &$j) {
$TJobs[$j->id] = $j->label;
}
print img_picto('', 'jobprofile', 'class="pictofixedwidth"').$form->selectarray('fk_job', $TJobs, $fk_job, 1);
print img_picto('', 'jobprofile', 'class="pictofixedwidth"').$form->selectarray('fk_job', $TJobs, $fk_job, 1);
?></td>
</tr>
</table>
@ -502,8 +503,8 @@ function displayUsersListWithPicto(&$TUser, $fk_usergroup = 0, $namelist = 'list
*
* Allow to get skill(s) of a user
*
* @param array $TUser array of employees we need to get skills
* @return array|int
* @param int[] $TUser array of employees we need to get skills
* @return array<int,stdClass>
*/
function getSkillForUsers($TUser)
{
@ -515,12 +516,12 @@ function getSkillForUsers($TUser)
}
$sql = 'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill, ';
$sql.= ' MAX(sr.rankorder) as rankorder';
$sql.= ' FROM '.MAIN_DB_PREFIX.'hrm_skill sk';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
$sql.= " WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."'";
$sql.= ' AND sr.fk_object IN ('.$db->sanitize(implode(',', $TUser)).')';
$sql.= " GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill "; // group par competence
$sql .= ' MAX(sr.rankorder) as rankorder';
$sql .= ' FROM '.MAIN_DB_PREFIX.'hrm_skill sk';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'hrm_skillrank sr ON (sk.rowid = sr.fk_skill)';
$sql .= " WHERE sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."'";
$sql .= ' AND sr.fk_object IN ('.$db->sanitize(implode(',', $TUser)).')';
$sql .= " GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill "; // group par competence
$resql = $db->query($sql);
$Tab = array();
@ -530,10 +531,10 @@ function getSkillForUsers($TUser)
$num = 0;
while ($obj = $db->fetch_object($resql)) {
$sql1 = "SELECT COUNT(rowid) as how_many_max FROM ".MAIN_DB_PREFIX."hrm_skillrank as sr";
$sql1.=" WHERE sr.rankorder = ".((int) $obj->rankorder);
$sql1.=" AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."'";
$sql1.=" AND sr.fk_skill = ".((int) $obj->fk_skill);
$sql1.=" AND sr.fk_object IN (".$db->sanitize(implode(',', $TUser)).")";
$sql1 .= " WHERE sr.rankorder = ".((int) $obj->rankorder);
$sql1 .= " AND sr.objecttype = '".$db->escape(SkillRank::SKILLRANK_TYPE_USER)."'";
$sql1 .= " AND sr.fk_skill = ".((int) $obj->fk_skill);
$sql1 .= " AND sr.fk_object IN (".$db->sanitize(implode(',', $TUser)).")";
$resql1 = $db->query($sql1);
$objMax = $db->fetch_object($resql1);
@ -561,7 +562,7 @@ function getSkillForUsers($TUser)
* Allow to get skill(s) of a job
*
* @param int $fk_job job we need to get required skills
* @return array|int
* @return stdClass[]
*/
function getSkillForJob($fk_job)
{
@ -572,12 +573,12 @@ function getSkillForJob($fk_job)
}
$sql = 'SELECT sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill,';
$sql.= " MAX(sr.rankorder) as rankorder";
$sql.=' FROM '.MAIN_DB_PREFIX.'hrm_skill as sk';
$sql.=' LEFT JOIN '.MAIN_DB_PREFIX.'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
$sql.=" WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB."'";
$sql.=' AND sr.fk_object = '.((int) $fk_job);
$sql.=' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill'; // group par competence*/
$sql .= " MAX(sr.rankorder) as rankorder";
$sql .= ' FROM '.MAIN_DB_PREFIX.'hrm_skill as sk';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'hrm_skillrank as sr ON (sk.rowid = sr.fk_skill)';
$sql .= " WHERE sr.objecttype = '".SkillRank::SKILLRANK_TYPE_JOB."'";
$sql .= ' AND sr.fk_object = '.((int) $fk_job);
$sql .= ' GROUP BY sk.rowid, sk.label, sk.description, sk.skill_type, sr.fk_object, sr.objecttype, sr.fk_skill'; // group par competence*/
$resql = $db->query($sql);
$Tab = array();

View file

@ -220,10 +220,10 @@ function testSqlAndScriptInject($val, $type)
/**
* Return true if security check on parameters are OK, false otherwise.
*
* @param string|array $var Variable name
* @param int $type 1=GET, 0=POST, 2=PHP_SELF
* @param int $stopcode 0=No stop code, 1=Stop code (default) if injection found
* @return boolean|null True if there is no injection.
* @param string|array<string,string> $var Variable name
* @param int<0,2> $type 1=GET, 0=POST, 2=PHP_SELF
* @param int<0,1> $stopcode 0=No stop code, 1=Stop code (default) if injection found
* @return boolean True if there is no injection.
*/
function analyseVarsForSqlAndScriptsInjection(&$var, $type, $stopcode = 1)
{
@ -1599,8 +1599,8 @@ if (!function_exists("llxHeader")) {
/**
* Show HTTP header. Called by top_htmlhead().
*
* @param string $contenttype Content type. For example, 'text/html'
* @param int $forcenocache Force disabling of cache for the page
* @param string $contenttype Content type. For example, 'text/html'
* @param int<0,1> $forcenocache Force disabling of cache for the page
* @return void
*/
function top_httphead($contenttype = 'text/html', $forcenocache = 0)
@ -1730,15 +1730,15 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0)
* Output html header of a page. It calls also top_httphead()
* This code is also duplicated into security2.lib.php::dol_loginfunction
*
* @param string $head Optional head lines
* @param string $title HTML title
* @param int $disablejs Disable js output
* @param int $disablehead Disable head output
* @param array $arrayofjs Array of complementary js files
* @param array $arrayofcss Array of complementary css files
* @param int $disableforlogin Do not load heavy js and css for login pages
* @param int $disablenofollow Disable nofollow tag for meta robots
* @param int $disablenoindex Disable noindex tag for meta robots
* @param string $head Optional head lines
* @param string $title HTML title
* @param int<0,1> $disablejs Disable js output
* @param int<0,1> $disablehead Disable head output
* @param string[] $arrayofjs Array of complementary js files
* @param string[] $arrayofcss Array of complementary css files
* @param int<0,1> $disableforlogin Do not load heavy js and css for login pages
* @param int<0,1> $disablenofollow Disable nofollow tag for meta robots
* @param int<0,1> $disablenoindex Disable noindex tag for meta robots
* @return void
*/
function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = array(), $arrayofcss = array(), $disableforlogin = 0, $disablenofollow = 0, $disablenoindex = 0)
@ -2146,10 +2146,10 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
* @param string $head Lines in the HEAD
* @param string $title Title of web page
* @param string $target Target to use in menu links (Example: '' or '_top')
* @param int $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax)
* @param int $disablehead Do not output head section
* @param array $arrayofjs Array of js files to add in header
* @param array $arrayofcss Array of css files to add in header
* @param int<0,1> $disablejs Do not output links to js (Ex: qd fonction utilisee par sous formulaire Ajax)
* @param int<0,1> $disablehead Do not output head section
* @param string[] $arrayofjs Array of js files to add in header
* @param string[] $arrayofcss Array of css files to add in header
* @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails)
* @param string $helppagename Name of wiki page for help ('' by default).
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage
@ -2412,7 +2412,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
/**
* Build the tooltip on user login
*
* @param int $hideloginname Hide login name. Show only the image.
* @param int<0,1> $hideloginname Hide login name. Show only the image.
* @param string $urllogout URL for logout (Will use DOL_URL_ROOT.'/user/logout.php?token=...' if empty)
* @return string HTML content
*/
@ -3201,15 +3201,15 @@ function top_menu_search()
/**
* Show left menu bar
*
* @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprecated and must be provided to ''.
* @param string $helppagename Name of wiki page for help ('' by default).
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage
* For other external page: http://server/url
* @param string $notused Deprecated. Used in past to add content into left menu. Hooks can be used now.
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
* @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules.
* @param string $title Title of web page
* @param int $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @param string $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprecated and must be provided to ''.
* @param string $helppagename Name of wiki page for help ('' by default).
* Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage|DE:GermanPage
* For other external page: http://server/url
* @param string $notused Deprecated. Used in past to add content into left menu. Hooks can be used now.
* @param array $menu_array_after Table of menu entries to show after entries of menu handler
* @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules.
* @param string $title Title of web page
* @param int<0,1> $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return void
*/
function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_array_after = array(), $leftmenuwithoutmainarea = 0, $title = '', $acceptdelayedhtml = 0)
@ -3523,7 +3523,7 @@ function main_area($title = '')
*
* @param string $helppagename Page name ('EN:xxx,ES:eee,FR:fff,DE:ddd...' or 'http://localpage')
* @param Translate $langs Language
* @return array Array of help urls
* @return array{helpbaseurl:string,helppage:string,mode:string} Array of help urls
*/
function getHelpParamFor($helppagename, $langs)
{