Merge pull request #29040 from mdeweerd/fix/PhanNonClassMethodCall

Fix & Enable PhanNonClassMethodCall
This commit is contained in:
Laurent Destailleur 2024-03-24 16:56:35 +01:00 committed by GitHub
commit bd94ef3c80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 165 additions and 108 deletions

View file

@ -276,7 +276,7 @@ return [
'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 @@ return [
// 'PhanPluginInconsistentReturnMethod',
'PhanTypeExpectedObjectPropAccessButGotNull',
// 'PhanUndeclaredClassAttribute',
'PhanNonClassMethodCall',
// 'PhanNonClassMethodCall',
// 'PhanPluginNoAssert',
// 'PhanTypeMismatchReturnSuperType',
// 'PhanTypeMismatchArgumentSuperType',

View file

@ -199,34 +199,57 @@ return [
'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',
'extrafields' => '\ExtraFields',
'hookmanager' => '\HookManager',
'langs' => '\Translate',
'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',
'object_rights' => 'int|stdClass',
'disableedit' => 'int<0,1>',
'disablemove' => 'int<0,1>',
'disableremove' => 'int<0,1>',
// Found in dol_eval
'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',
'obj' => '\CommonObject', // Deprecated
'object_rights' => 'int|stdClass',
'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`.

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.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
@ -516,7 +517,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$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 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="oddeven nodrag nodrop">';
print '<td>';
$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);

View file

@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.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
@ -107,6 +108,7 @@ foreach ($modulesdir as $dir) {
}
$db->commit();
'@phan-var-force DolibarrModules[] $modules';
$head = security_prepare_head();

View file

@ -67,6 +67,8 @@ $arrayfields = array(
);
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked:int<0,1>,position:int}> $arrayfields';
$param = '';
$info_admin = '';

View file

@ -3680,7 +3680,7 @@ class Propal extends CommonObject
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
if ($res > 0 && $this->project instanceof Project) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}

View file

@ -3764,7 +3764,7 @@ class Commande extends CommonOrder
$langs->load('project');
if (empty($this->project)) {
$res = $this->fetch_project();
if ($res > 0) {
if ($res > 0 && $this->project instanceof Project) {
$datas['project'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.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
@ -34,12 +35,12 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock'];
$langs->load("bills");
$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1);
'@phan-var-force array<string,CommonObject> $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';

View file

@ -2092,7 +2092,7 @@ class Contrat extends CommonObject
$datas['refcustomer'] = '<br><b>'.$langs->trans('RefCustomer').':</b> '. $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'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);

View file

@ -993,7 +993,7 @@ function defaultvalues_prepare_head()
/**
* Return list of session
*
* @return array Array list of sessions
* @return array<string,array{login:string,age:int,creation:int,modification:int,raw:string}> 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<string,string> $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<string,array{type:string,label:string}> $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)
{

View file

@ -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<string,string> 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<string,string> $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<string|int,mixed> $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)
{

View file

@ -2,6 +2,7 @@
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.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
@ -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 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) {
// 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 @@ if ($massaction == 'edit_extrafields') {
$outputShowOutputFields = '<div class="extrafields-inputs">';
foreach ($extrafields_list as $extraKey => $extraLabel) {
$outputShowOutputFields.= '<div class="mass-action-extrafield" data-extrafield="'.$extraKey.'" style="display:none;" >';
$outputShowOutputFields.= '<br><span>'. $langs->trans('NewValue').'</span>';
$outputShowOutputFields.= $extrafields->showInputField($extraKey, '', '', $keysuffix, '', 0, $objecttmp->id, $objecttmp->table_element);
$outputShowOutputFields.= '</div>';
$outputShowOutputFields .= '<div class="mass-action-extrafield" data-extrafield="'.$extraKey.'" style="display:none;" >';
$outputShowOutputFields .= '<br><span>'. $langs->trans('NewValue').'</span>';
$outputShowOutputFields .= $extrafields->showInputField($extraKey, '', '', $keysuffix, '', 0, $objecttmp->id, $objecttmp->table_element);
$outputShowOutputFields .= '</div>';
}
$outputShowOutputFields.= '<script>
$outputShowOutputFields .= '<script>
jQuery(function($) {
$("#extrafield-key-to-update").on(\'change\',function(){
let selectedExtrtafield = $(this).val();
@ -361,7 +364,7 @@ if ($massaction == 'edit_extrafields') {
});
});
</script>';
$outputShowOutputFields.= '</div>';
$outputShowOutputFields .= '</div>';

View file

@ -1567,7 +1567,16 @@ class EmailCollector extends CommonObject
//$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 @@ class EmailCollector extends CommonObject
} 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;

View file

@ -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<array{type:string,filename:string,pos:int}> type, filename, pos
*/
function getAttachments($jk, $mbox)
{

View file

@ -4,6 +4,7 @@
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.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
@ -91,6 +92,7 @@ if (!$error && $massaction == 'confirm_presend_attendees') {
}
}
}
'@phan-var-force CommonObject $objecttmp';
// Check mandatory parameters
if (GETPOST('fromtype', 'alpha') === 'user' && empty($user->email)) {

View file

@ -730,7 +730,7 @@ class Reception extends CommonObject
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

View file

@ -337,7 +337,7 @@ class User extends CommonObject
public $lastsearch_values; // To store last saved search criteria for user
/**
* @var array<int,array{rowid:int,id:int,fk_user:int,fk_soc:int,firstname:string,lastname:string,login:string,statut:int,entity:string,email:string,gender:int,admin:string,photo:string,fullpath:string,fullname:string,level:int}> Store the entire hierarchy tree of users
* @var array<int,User>|array<int,array{rowid:int,id:int,fk_user:int,fk_soc:int,firstname:string,lastname:string,login:string,statut:int,entity:string,email:string,gender:int,admin:string,photo:string,fullpath:string,fullname:string,level:int}> 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 @@ class User extends CommonObject
*
* @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<int,array{rowid:int,id:int,fk_user:int,fk_soc:int,firstname:string,lastname:string,login:string,statut:int,entity:string,email:string,gender:int,admin:string,photo:string,fullpath:string,fullname:string,level:int}> Array of user information (also: $this->users). Note: $this->parentof is also set.
*/
public function get_full_tree($deleteafterid = 0, $filter = '')
{

View file

@ -6,6 +6,7 @@
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.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
@ -92,7 +93,7 @@ $hookmanager->initHooks(array('usercard', 'userperms', 'globalcard'));
* 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 @@ foreach ($modulesdir as $dir) {
$db->commit();
'@phan-var-force DolibarrModules[] $modules';
// Read permissions of edited user
$permsuser = array();
@ -323,7 +326,7 @@ if (!empty($object->socid)) {
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');