Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix & Enable PhanNonClassMethodCall #29040

Merged
merged 24 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
34416d9
Qual: Enable PhanNonClassMethodCall
mdeweerd Mar 23, 2024
743b86a
Force list type to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
83b9535
PHPdoc for getDParameters return value
mdeweerd Mar 23, 2024
8609985
PHPdoc typing for several arrays
mdeweerd Mar 23, 2024
cbb8204
Extra checks to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
738c2d1
Extra checks to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
5c5ad32
Fix PhanNonClassMethodCall with extra test
mdeweerd Mar 23, 2024
6f0b454
Fix PhanNonClassMethodCall with extra test
mdeweerd Mar 23, 2024
c16a4f5
Fix PhanNonClassMethodCall with extra test
mdeweerd Mar 23, 2024
949ccf3
Force type to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
a1ae115
Set cache_codes global type
mdeweerd Mar 23, 2024
969b078
Add PHPdoc typing
mdeweerd Mar 23, 2024
1986888
Update PHPdoc for User::$users
mdeweerd Mar 23, 2024
b749c37
Force type to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
c86c5f6
Force type to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
bbc086c
Force type to fix PhanNonClassMethodCall
mdeweerd Mar 23, 2024
6ff0688
Force typing on var
mdeweerd Mar 24, 2024
71818bd
Extra test to fix PhanTypeInvalidPropertyName
mdeweerd Mar 23, 2024
0a925dd
Extra test to fix PhanTypeInvalidPropertyName
mdeweerd Mar 23, 2024
9c95335
Extra test to fix PhanTypeInvalidPropertyName
mdeweerd Mar 23, 2024
c43bb3d
Update config.php
eldy Mar 24, 2024
d78bafe
Update config_extended.php
eldy Mar 24, 2024
414c51d
Update config_extended.php
eldy Mar 24, 2024
8bcfefe
Update config_fixer.php
eldy Mar 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev/tools/phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -613,7 +613,7 @@
// 'PhanPluginInconsistentReturnMethod',
'PhanTypeExpectedObjectPropAccessButGotNull',
// 'PhanUndeclaredClassAttribute',
'PhanNonClassMethodCall',
// 'PhanNonClassMethodCall',
// 'PhanPluginNoAssert',
// 'PhanTypeMismatchReturnSuperType',
// 'PhanTypeMismatchArgumentSuperType',
Expand Down
55 changes: 39 additions & 16 deletions dev/tools/phan/config_extended.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
56 changes: 33 additions & 23 deletions htdocs/admin/emailcollector_card.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <[email protected]>
* Copyright (C) 2022 Charlene Benke <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -611,31 +621,31 @@
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);

Expand Down
2 changes: 2 additions & 0 deletions htdocs/admin/perms.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2013 Regis Houssin <[email protected]>
* Copyright (C) 2011 Herve Prot <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -107,6 +108,7 @@
}

$db->commit();
'@phan-var-force DolibarrModules[] $modules';

$head = security_prepare_head();

Expand Down
2 changes: 2 additions & 0 deletions htdocs/admin/system/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
);

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

$param = '';
$info_admin = '';

Expand Down
2 changes: 1 addition & 1 deletion htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = '<br><b>'.$langs->trans('Project').':</b> '.$this->project->getNomUrl(1, '', 0, 1);
}
}
Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright (C) 2010-2011 Regis Houssin <[email protected]>
* Copyright (C) 2013 Juanjo Menent <[email protected]>
* Copyright (C) 2014 Marcos García <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -34,12 +35,12 @@
$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';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contrat/class/contrat.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ public function getTooltipContentArray($params)
$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);
Expand Down
20 changes: 10 additions & 10 deletions htdocs/core/lib/admin.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
Loading
Loading