Qual: phan: Add more global definitions (#28745)

* Qual: phan: Add more global definitions

# Qual: phan: Add more global definitions

Add some more typing information for globals

* Qual: phan: ignore local conf file which may contain exceptions

* Qual: phan: add a few more global typings
This commit is contained in:
MDW 2024-03-11 12:55:44 +01:00 committed by GitHub
parent e25fb6f39b
commit 9c00a465c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 3 deletions

View file

@ -228,14 +228,58 @@ 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',
'dateSelector' => 'int<0,1>',
'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' => 'string',
'mysoc' => '\Societe',
'nblines' => '\int',
'obj' => '\CommonObject', // Deprecated
'object_rights' => 'int|stdClass',
'objectoffield' => '\CommonObject',
'senderissupplier' => 'int<0,1,2>',
'user' => '\User',
'website' => '\WebSite',
'websitepage' => '\WebSitePage',
'websitepagefile' => 'string',
// 'object' => '\CommonObject', // Deprecated, not enabled because conflicts with $object assignments
],
// Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`.
@ -284,6 +328,7 @@ return [
.'|htdocs/includes/restler/.*' // @phpstan-ignore-line
// Included as stub (did not seem properly analysed by phan without it)
.'|htdocs/includes/stripe/.*' // @phpstan-ignore-line
.'|htdocs/conf/conf.php' // @phpstan-ignore-line
// .'|htdocs/[^h].*/.*' // For testing @phpstan-ignore-line
.')@', // @phpstan-ignore-line
@ -297,7 +342,7 @@ return [
// Alternately, you can pass in the full path to a PHP file
// with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php')
'ParamMatchRegexPlugin' => [
'/^GETPOST$/' => [1, $sanitizeRegex],
'/^GETPOST$/' => [1, $sanitizeRegex, 'GetPostUnknownSanitizeType'],
'/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'],
// Note: trick to have different key for same regex:
'/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"],

View file

@ -206,6 +206,26 @@ return [
'mysoc' => '\Societe',
'nblines' => '\int',
'user' => '\User',
'dolibarr_main_data_root' => 'string',
'dolibarr_main_authentication' => 'string',
'dolibarr_main_demo' => 'string',
'menumanager' => 'string',
'errormsg' => 'string',
'form' => '\Form',
'object_rights' => 'int|stdClass',
'disableedit' => 'int<0,1>',
'disablemove' => 'int<0,1>',
'disableremove' => 'int<0,1>',
// Found in dol_eval
'website' => '\WebSite',
'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`.
@ -254,6 +274,7 @@ return [
.'|htdocs/includes/restler/.*' // @phpstan-ignore-line
// Included as stub (did not seem properly analysed by phan without it)
.'|htdocs/includes/stripe/.*' // @phpstan-ignore-line
.'|htdocs/conf/conf.php' // @phpstan-ignore-line
.')@', // @phpstan-ignore-line
// A list of plugin files to execute.
@ -266,11 +287,11 @@ return [
// Alternately, you can pass in the full path to a PHP file
// with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php')
'ParamMatchRegexPlugin' => [
'/^GETPOST$/' => [1, $sanitizeRegex],
'/^GETPOST$/' => [1, $sanitizeRegex, 'GetPostUnknownSanitizeType'],
'/^isModEnabled$/' => [0, $moduleNameRegex, 'UnknownModuleName'],
// Note: trick to have different key for same regex:
'/^isModEnable[d]$/' => [0, $deprecatedModuleNameRegex, "DeprecatedModuleName"],
'/^sanitizeVal$/' => [1, $sanitizeRegex],
'/^sanitizeVal$/' => [1, $sanitizeRegex,"UnknownSanitizeType"],
],
'plugins' => [
__DIR__.'/plugins/NoVarDumpPlugin.php',

View file

@ -103,6 +103,7 @@ return [
.'|htdocs/includes/restler/.*' // @phpstan-ignore-line
// Included as stub (did not seem properly analysed by phan without it)
.'|htdocs/includes/stripe/.*' // @phpstan-ignore-line
.'|htdocs/conf/conf.php' // @phpstan-ignore-line
//.'|htdocs/[^c][^o][^r][^e][^/].*' // For testing @phpstan-ignore-line
//.'|htdocs/[^h].*' // For testing on restricted set @phpstan-ignore-line
.')@', // @phpstan-ignore-line