diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 0d14ae43f2d50..38dcbb2bff17c 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -276,7 +276,7 @@ 'obj' => '\CommonObject', // Deprecated 'object_rights' => 'int|stdClass', 'objectoffield' => '\CommonObject', - 'senderissupplier' => 'int<0,1,2>', + 'senderissupplier' => 'int<0,2>', 'user' => '\User', 'website' => 'string', // See discussion https://github.com/Dolibarr/dolibarr/pull/28891#issuecomment-2002268334 // Disable because Phan infers Website type 'websitepage' => '\WebSitePage', @@ -613,7 +613,7 @@ // 'PhanPluginInconsistentReturnMethod', 'PhanTypeExpectedObjectPropAccessButGotNull', // 'PhanUndeclaredClassAttribute', - 'PhanNonClassMethodCall', + // 'PhanNonClassMethodCall', // 'PhanPluginNoAssert', // 'PhanTypeMismatchReturnSuperType', // 'PhanTypeMismatchArgumentSuperType', diff --git a/dev/tools/phan/config_extended.php b/dev/tools/phan/config_extended.php index f5ed4df6b2cce..535f52f70b2e6 100644 --- a/dev/tools/phan/config_extended.php +++ b/dev/tools/phan/config_extended.php @@ -199,34 +199,57 @@ 'simplify_ast' => true, 'analyzed_file_extensions' => ['php','inc'], 'globals_type_map' => [ + 'action' => 'string', + 'actioncode' => 'string', + 'badgeStatus0' => 'string', + 'badgeStatus1' => 'string', + 'badgeStatus11' => 'string', + 'badgeStatus3' => 'string', + 'badgeStatus4' => 'string', + 'badgeStatus6' => 'string', + 'badgeStatus8' => 'string', + 'badgeStatus9' => 'string', + 'classname' => 'string', 'conf' => '\Conf', + 'conffile' => 'string', + 'conffiletoshow' => 'string', + 'conffiletoshowshort' => 'string', 'db' => '\DoliDB', + 'disableedit' => 'int<0,1>', + 'disablemove' => 'int<0,1>', + 'disableremove' => 'int<0,1>', + 'dolibarr_main_authentication' => 'string', + 'dolibarr_main_data_root' => 'string', + 'dolibarr_main_data_root' => 'string', + 'dolibarr_main_db_encrypted_pass' => 'string', + 'dolibarr_main_db_host' => 'string', + 'dolibarr_main_db_pass' => 'string', + 'dolibarr_main_demo' => 'string', + 'dolibarr_main_document_root' => 'string', + 'dolibarr_main_url_root' => 'string', + 'errormsg' => 'string', 'extrafields' => '\ExtraFields', + 'filter' => 'string', + 'filtert' => 'int', + 'forceall' => 'int<0,1>', + 'form' => '\Form', 'hookmanager' => '\HookManager', + 'inputalsopricewithtax' => 'int<0,1>', 'langs' => '\Translate', + 'leftmenu' => 'string', + 'mainmenu' => 'string', + 'menumanager' => '\MenuManager', 'mysoc' => '\Societe', 'nblines' => '\int', - 'user' => '\User', - 'dolibarr_main_data_root' => 'string', - 'dolibarr_main_authentication' => 'string', - 'dolibarr_main_demo' => 'string', - 'menumanager' => '\MenuManager', - 'errormsg' => 'string', - 'form' => '\Form', + 'obj' => '\CommonObject', // Deprecated 'object_rights' => 'int|stdClass', - 'disableedit' => 'int<0,1>', - 'disablemove' => 'int<0,1>', - 'disableremove' => 'int<0,1>', - // Found in dol_eval + 'objectoffield' => '\CommonObject', + 'senderissupplier' => 'int<0,2>', + 'user' => '\User', 'website' => 'string', // See discussion https://github.com/Dolibarr/dolibarr/pull/28891#issuecomment-2002268334 // Disable because Phan infers Website type 'websitepage' => '\WebSitePage', 'websitepagefile' => 'string', - 'action' => 'string', - 'mainmenu' => 'string', - 'leftmenu' => 'string', - 'objectoffield' => '\CommonObject', // 'object' => '\CommonObject', // Deprecated, not enabled because conflicts with $object assignments - 'obj' => '\CommonObject', // Deprecated ], // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 844f897547f3f..aa0211df49526 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -1,6 +1,7 @@ * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2024 MDW * * 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 @@ -516,7 +517,16 @@ $client->connect(); $f = $client->getFolders(false, $object->source_directory); - $nbemail = $f[0]->examine()["exists"]; + if ($f->total() >= 1) { + $folder = $f[0]; + if ($folder instanceof Webklex\PHPIMAP\Folder) { + $nbemail = $folder->examine()["exists"]; + } else { + $nbemail = 0; + } + } else { + $nbemail = 0; + } $morehtml .= $nbemail; } catch (ConnectionFailedException $e) { $morehtml .= 'ConnectionFailedException '.$e->getMessage(); @@ -611,31 +621,31 @@ print ''; print ''; $arrayoftypes = array( - 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), - 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')), - 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')), - 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')), - 'replyto'=>array('label'=>'ReplyTo', 'data-placeholder'=>$langs->trans('SearchString')), - 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')), - 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')), + 'from' => array('label' => 'MailFrom', 'data-placeholder' => $langs->trans('SearchString')), + 'to' => array('label' => 'MailTo', 'data-placeholder' => $langs->trans('SearchString')), + 'cc' => array('label' => 'Cc', 'data-placeholder' => $langs->trans('SearchString')), + 'bcc' => array('label' => 'Bcc', 'data-placeholder' => $langs->trans('SearchString')), + 'replyto' => array('label' => 'ReplyTo', 'data-placeholder' => $langs->trans('SearchString')), + 'subject' => array('label' => 'Subject', 'data-placeholder' => $langs->trans('SearchString')), + 'body' => array('label' => 'Body', 'data-placeholder' => $langs->trans('SearchString')), // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2 //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value //'X1'=>'---', - 'X2'=>'---', - 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1), - 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1), - 'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1), - 'answered'=>array('label'=>'Answered', 'data-noparam'=>1), - 'smaller'=>array('label'=>$langs->trans("Size").' ('.$langs->trans("SmallerThan").")", 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'larger'=>array('label'=>$langs->trans("Size").' ('.$langs->trans("LargerThan").")", 'data-placeholder'=>$langs->trans('NumberOfBytes')), - 'X3'=>'---', - 'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1), - 'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1), - 'withtrackingidinmsgid'=>array('label'=>'WithDolTrackingIDInMsgId', 'data-noparam'=>1), - 'withouttrackingidinmsgid'=>array('label'=>'WithoutDolTrackingIDInMsgId', 'data-noparam'=>1), - 'X4'=>'---', - 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), - 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) + 'X2' => '---', + 'seen' => array('label' => 'AlreadyRead', 'data-noparam' => 1), + 'unseen' => array('label' => 'NotRead', 'data-noparam' => 1), + 'unanswered' => array('label' => 'Unanswered', 'data-noparam' => 1), + 'answered' => array('label' => 'Answered', 'data-noparam' => 1), + 'smaller' => array('label' => $langs->trans("Size").' ('.$langs->trans("SmallerThan").")", 'data-placeholder' => $langs->trans('NumberOfBytes')), + 'larger' => array('label' => $langs->trans("Size").' ('.$langs->trans("LargerThan").")", 'data-placeholder' => $langs->trans('NumberOfBytes')), + 'X3' => '---', + 'withtrackingid' => array('label' => 'WithDolTrackingID', 'data-noparam' => 1), + 'withouttrackingid' => array('label' => 'WithoutDolTrackingID', 'data-noparam' => 1), + 'withtrackingidinmsgid' => array('label' => 'WithDolTrackingIDInMsgId', 'data-noparam' => 1), + 'withouttrackingidinmsgid' => array('label' => 'WithoutDolTrackingIDInMsgId', 'data-noparam' => 1), + 'X4' => '---', + 'isnotanswer' => array('label' => 'IsNotAnAnswer', 'data-noparam' => 1), + 'isanswer' => array('label' => 'IsAnAnswer', 'data-noparam' => 1) ); print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1, '', 2); diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 774cb17336460..2c9084fa89c34 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2011 Herve Prot + * Copyright (C) 2024 MDW * * 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 @@ -107,6 +108,7 @@ } $db->commit(); +'@phan-var-force DolibarrModules[] $modules'; $head = security_prepare_head(); diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 349a0ead6100c..ee4d525609e3a 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -67,6 +67,8 @@ ); $arrayfields = dol_sort_array($arrayfields, 'position'); +'@phan-var-force array,position:int}> $arrayfields'; + $param = ''; $info_admin = ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f7e4da009f944..35e268885b8c8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3680,7 +3680,7 @@ public function getTooltipContentArray($params) $langs->load('project'); if (empty($this->project)) { $res = $this->fetch_project(); - if ($res > 0) { + if ($res > 0 && $this->project instanceof Project) { $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d2ee2bb3079e2..eee47cd32a791 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3764,7 +3764,7 @@ public function getTooltipContentArray($params) $langs->load('project'); if (empty($this->project)) { $res = $this->fetch_project(); - if ($res > 0) { + if ($res > 0 && $this->project instanceof Project) { $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); } } diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index ea6f8d6c4a1f1..fa1a5bea7c7e2 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2011 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Marcos García + * Copyright (C) 2024 MDW * * 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 @@ -34,12 +35,12 @@ $langs->load("bills"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); +'@phan-var-force array $linkedObjectBlock'; $total = 0; $ilink = 0; foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass = 'oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { $trclass .= ' liste_sub_total'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c3e5001b2afb0..2f5fe9a8aea0e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2092,7 +2092,7 @@ public function getTooltipContentArray($params) $datas['refcustomer'] = '
'.$langs->trans('RefCustomer').': '. $this->ref_customer; if (!$nofetch) { $langs->load('project'); - if (empty($this->project)) { + if (empty($this->project) && $this->project instanceof Project) { $res = $this->fetch_project(); if ($res > 0) { $datas['project'] = '
'.$langs->trans('Project').': '.$this->project->getNomUrl(1, '', 0, 1); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index fde50455f74e6..cfc9045aae15a 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -993,7 +993,7 @@ function defaultvalues_prepare_head() /** * Return list of session * - * @return array Array list of sessions + * @return array Array list of sessions */ function listOfSessions() { @@ -1102,7 +1102,7 @@ function purgeSessions($mysessionid) * @param string $value Name of module to activate * @param int $withdeps Activate/Disable also all dependencies * @param int $noconfverification Remove verification of $conf variable for module - * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); + * @return array{nbmodules?:int,errors:string[],nbperms?:int} array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); */ function activateModule($value, $withdeps = 1, $noconfverification = 0) { @@ -1112,7 +1112,7 @@ function activateModule($value, $withdeps = 1, $noconfverification = 0) // Check parameters if (empty($value)) { - $ret['errors'][] = 'ErrorBadParameter'; + $ret['errors'] = array('ErrorBadParameter'); return $ret; } @@ -1553,7 +1553,7 @@ function activateModulesRequiredByCountry($country_code) /** * Search external modules to complete the list of contact element * - * @param array $elementList elementList + * @param array $elementList elementList * @return int 1 */ function complete_elementList_with_modules(&$elementList) @@ -1656,14 +1656,14 @@ function complete_elementList_with_modules(&$elementList) /** * Show array with constants to edit * - * @param array $tableau Array of constants array('key'=>array('type'=>type, 'label'=>label) - * where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ... - * @param int $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (deprecated), 2=No form nor button at all, 3=No form nor button at all and each field has a unique name (form is output by caller, recommended) + * @param array $tableau Array of constants array('key'=>array('type'=>type, 'label'=>label) + * where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ... + * @param int<2,3> $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (deprecated), 2=No form nor button at all, 3=No form nor button at all and each field has a unique name (form is output by caller, recommended) (typed as int<2,3> to highlight the deprecated values) * @param string $helptext Tooltip help to use for the column name of values * @param string $text Text to use for the column name of values * @return void */ -function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Value') +function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Value') { global $db, $langs, $conf, $user; global $_Avery_Labels; @@ -1866,8 +1866,8 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu /** * Show array with constants to edit * - * @param array $modules Array of all modules - * @return string HTML string with warning + * @param DolibarrModules[] $modules Array of all modules + * @return string HTML string with warning */ function showModulesExludedForExternal($modules) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dc417d38a7e97..a6af4069ab3a4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8318,12 +8318,12 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false) * Return array of possible common substitutions. This includes several families like: 'system', 'mycompany', 'object', 'objectamount', 'date', 'user' * * @param Translate $outputlangs Output language - * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), - * 2=Values are trunc and html sanitized (to use for help tooltip) - * @param array|null $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) - * @param Object|null $object Object for keys on object - * @param array|null $include Array of family keys we want to include. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) - * @return array Array of substitutions + * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), + * 2=Values are trunc and html sanitized (to use for help tooltip) + * @param string[]|null $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) + * @param ?CommonObject $object Object for keys on object + * @param string[]|null $include Array of family keys we want to include. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) + * @return array Array of substitutions * @see setSubstitFromObject() */ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null, $include = null) @@ -9145,11 +9145,11 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null, $con * Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array. * In this case, method completesubstitutionarray provided by module is called. * - * @param array $substitutionarray Array substitution old value => new value value - * @param Translate $outputlangs Output language - * @param Object $object Source object - * @param mixed $parameters Add more parameters (useful to pass product lines) - * @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray) + * @param array $substitutionarray Array substitution old value => new value value + * @param Translate $outputlangs Output language + * @param CommonObject $object Source object + * @param mixed $parameters Add more parameters (useful to pass product lines) + * @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray) * @return void * @see make_substitutions() */ @@ -9331,11 +9331,11 @@ function setEventMessage($mesgs, $style = 'mesgs', $noduplicate = 0) * Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events. * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. * - * @param string|null $mesg Message string - * @param array|null $mesgs Message array - * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') - * @param string $messagekey A key to be used to allow the feature "Never show this message again" - * @param int $noduplicate 1 means we do not add the message if already present in session stack + * @param string|null $mesg Message string + * @param string[]|null $mesgs Message array + * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') + * @param string $messagekey A key to be used to allow the feature "Never show this message again" + * @param int $noduplicate 1 means we do not add the message if already present in session stack * @return void * @see dol_htmloutput_events() */ @@ -9475,10 +9475,10 @@ function get_htmloutput_mesg($mesgstring = '', $mesgarray = [], $style = 'ok', $ /** * Get formatted error messages to output (Used to show messages on html output). * - * @param string $mesgstring Error message - * @param array $mesgarray Error messages array - * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) - * @return string Return html output + * @param string $mesgstring Error message + * @param string[] $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return string Return html output * * @see dol_print_error() * @see dol_htmloutput_mesg() @@ -9561,9 +9561,9 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o /** * Print formatted error messages to output (Used to show messages on html output). * - * @param string $mesgstring Error message - * @param array $mesgarray Error messages array - * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @param string $mesgstring Error message + * @param string[] $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) * @return void * * @see dol_print_error() @@ -9579,14 +9579,14 @@ function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe * or descending output and uses optionally natural case insensitive sorting (which * can be optionally case sensitive as well). * - * @param array $array Array to sort (array of array('key1'=>val1,'key2'=>val2,'key3'...) or array of objects) - * @param string $index Key in array to use for sorting criteria - * @param string $order Sort order ('asc' or 'desc') - * @param int $natsort If values are strings (I said value not type): 0=Use alphabetical order, 1=use "natural" sort (natsort) - * If values are numeric (I said value not type): 0=Use numeric order (even if type is string) so use a "natural" sort, 1=use "natural" sort too (same than 0), -1=Force alphabetical order - * @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive - * @param int $keepindex If 0 and index key of array to sort is a numeric, than index will be rewrote. If 1 or index key is not numeric, key for index is kept after sorting. - * @return array Sorted array + * @param array $array Array to sort (array of array('key1'=>val1,'key2'=>val2,'key3'...) or array of objects) + * @param string $index Key in array to use for sorting criteria + * @param string $order Sort order ('asc' or 'desc') + * @param int $natsort If values are strings (I said value not type): 0=Use alphabetical order, 1=use "natural" sort (natsort) + * If values are numeric (I said value not type): 0=Use numeric order (even if type is string) so use a "natural" sort, 1=use "natural" sort too (same than 0), -1=Force alphabetical order + * @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive + * @param int $keepindex If 0 and index key of array to sort is a numeric, then index will be rewritten. If 1 or index key is not numeric, key for index is kept after sorting. + * @return array Sorted array */ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0) { @@ -9639,11 +9639,11 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen /** - * Check if a string is in UTF8. Seems similar to utf8_valid() but in pure PHP. + * Check if a string is in UTF8. Seems similar to utf8_valid() but in pure PHP. * - * @param string $str String to check - * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special non utf8 char or Binary) - * @see utf8_valid() + * @param string $str String to check + * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special non utf8 char or Binary) + * @see utf8_valid() */ function utf8_check($str) { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 9d81692900887..cf57e63b9c5ed 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García + * Copyright (C) 2024 MDW * * 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 @@ -30,6 +31,8 @@ // $object = Object fetched; // $sendto // $withmaindocfilemail +'@phan-var-force CommonObject $objecttmp'; + if (!empty($sall) || !empty($search_all)) { $search_all = empty($sall) ? $search_all : $sall; @@ -65,12 +68,12 @@ // Test on $object (should be useless, we already check on $objecttmp just after) if (isset($object) && $categdef['obj_table'] == $object->table_element) { if (!array_key_exists($categdef['code'], $categ_types)) { - $categ_types[$categdef['code']] = array('code'=>$categdef['code'], 'label'=>$langs->trans($categdef['obj_class'])); + $categ_types[$categdef['code']] = array('code' => $categdef['code'], 'label' => $langs->trans($categdef['obj_class'])); } } if (isset($objecttmp) && $categdef['obj_table'] == $objecttmp->table_element) { if (!array_key_exists($categdef['code'], $categ_types)) { - $categ_types[$categdef['code']] = array('code'=>$categdef['code'], 'label'=>$langs->trans($categdef['obj_class'])); + $categ_types[$categdef['code']] = array('code' => $categdef['code'], 'label' => $langs->trans($categdef['obj_class'])); } } } @@ -345,12 +348,12 @@ $outputShowOutputFields = '
'; foreach ($extrafields_list as $extraKey => $extraLabel) { - $outputShowOutputFields.= ''; + $outputShowOutputFields .= ''; } - $outputShowOutputFields.= ''; - $outputShowOutputFields.= '
'; + $outputShowOutputFields .= ''; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index fe1f734eb7077..9458436e488e0 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1567,7 +1567,16 @@ public function doCollectOneCollector($mode = 0) //$criteria = [['ALL']]; //$Query = $client->getFolders()[0]->messages()->where($criteria); $f = $client->getFolders(false, $sourcedir); - $Query = $f[0]->messages()->where($criteria); + if ($f->total() >= 1) { + $folder = $f[0]; + if ($folder instanceof Webklex\PHPIMAP\Folder) { + $Query = $folder->messages()->where($criteria); + } else { + return -1; + } + } else { + return -1; + } } catch (InvalidWhereQueryCriteriaException $e) { $this->error = $e->getMessage(); $this->errors[] = $this->error; @@ -1807,6 +1816,8 @@ public function doCollectOneCollector($mode = 0) } else { $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments } + '@phan-var-force Webklex\PHPIMAP\Attachment[] $attachments'; + //print $plainmsg; //var_dump($plainmsg); exit; diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php index 3e628a7caaa2c..befbbef16b2d7 100644 --- a/htdocs/emailcollector/lib/emailcollector.lib.php +++ b/htdocs/emailcollector/lib/emailcollector.lib.php @@ -113,7 +113,7 @@ function getDParameters($part) * * @param integer $jk Number of email * @param object $mbox object connection imap - * @return array type, filename, pos + * @return array type, filename, pos */ function getAttachments($jk, $mbox) { diff --git a/htdocs/eventorganization/core/actions_massactions_mail.inc.php b/htdocs/eventorganization/core/actions_massactions_mail.inc.php index ce565d2a6b992..237412795679a 100644 --- a/htdocs/eventorganization/core/actions_massactions_mail.inc.php +++ b/htdocs/eventorganization/core/actions_massactions_mail.inc.php @@ -4,6 +4,7 @@ * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Ferran Marcet * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -91,6 +92,7 @@ } } } + '@phan-var-force CommonObject $objecttmp'; // Check mandatory parameters if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) { diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index b97a7ea8c308f..a98b5f1c1578e 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -730,7 +730,7 @@ public function getStatusDispatch() if (!empty($this->origin) && $this->origin_id > 0 && ($this->origin == 'order_supplier' || $this->origin == 'commandeFournisseur')) { if (empty($this->origin_object)) { $this->fetch_origin(); - if (empty($this->origin_object->lines)) { + if ($this->origin_object instanceof CommonObject && empty($this->origin_object->lines)) { $res = $this->origin_object->fetch_lines(); if ($this->origin_object instanceof CommandeFournisseur) { $this->commandeFournisseur = $this->origin_object; // deprecated diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 78f0b4e6e429e..2bbbb39519feb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -337,7 +337,7 @@ class User extends CommonObject public $lastsearch_values; // To store last saved search criteria for user /** - * @var array Store the entire hierarchy tree of users + * @var array|array Array of User (filled from fetchAll) or Array with hierarchy of user information (filled with get_full_tree() */ public $users = array(); public $parentof; // To store an array of all parents for all ids. @@ -3706,7 +3706,7 @@ private function loadParentOf() * * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param string $filter SQL filter on users. This parameter must not come from user input. - * @return array|int Array of users $this->users. Note: $this->parentof is also set. + * @return int<-1,-1>|array Array of user information (also: $this->users). Note: $this->parentof is also set. */ public function get_full_tree($deleteafterid = 0, $filter = '') { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index d6372cfb6a60f..6fda137218077 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -6,6 +6,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2024 MDW * * 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 @@ -92,7 +93,7 @@ * Actions */ -$parameters = array('socid'=>$socid); +$parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -193,6 +194,8 @@ $db->commit(); +'@phan-var-force DolibarrModules[] $modules'; + // Read permissions of edited user $permsuser = array(); @@ -323,7 +326,7 @@ print info_admin(showModulesExludedForExternal($modules))."\n"; } -$parameters = array('permsgroupbyentity'=>$permsgroupbyentity); +$parameters = array('permsgroupbyentity' => $permsgroupbyentity); $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');