Qual: Fix Phan notices in CommonObject (#29354)

* Fix PhanPluginSimplifyExpressionBool in commonobject

* Fix commonobject for phan notices

* Allow null for $usedolidb argument

* Allow null for $outputlangs argument of \dol_format_address()

* Fix multiple phan notices

* Ignore PhanTypeArraySuspiciousNullable

* Fix PhanTypeMismatchArgumentProbablyReal

* Update baseline

* Improve typings

* Update type specification getCountry/withCode

* Fix CommonObject Phan notices & update baseline

* Fix phan notices

* Correct typing for showInputField to be the same as parent class

* Fix PhanPluginSimplifyExpressionBool in commonobject

* Fix commonobject for phan notices

* Allow null for $usedolidb argument

* Allow null for $outputlangs argument of \dol_format_address()

* Fix multiple phan notices

* Ignore PhanTypeArraySuspiciousNullable

* Fix PhanTypeMismatchArgumentProbablyReal

* Update baseline

* Improve typings

* Update type specification getCountry/withCode

* Fix CommonObject Phan notices & update baseline

* Fix phan notices

* fixup! Correct typing for showInputField to be the same as parent class
This commit is contained in:
MDW 2024-05-02 19:33:51 +02:00 committed by GitHub
parent 94c69c08ba
commit 2115980560
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 238 additions and 195 deletions

View File

@ -9,9 +9,9 @@
*/
return [
// # Issue statistics:
// PhanPluginUnknownPropertyType : 2250+ occurrences
// PhanTypePossiblyInvalidDimOffset : 1550+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1450+ occurrences
// PhanPluginUnknownPropertyType : 2240+ occurrences
// PhanTypePossiblyInvalidDimOffset : 1540+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 1440+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 1400+ occurrences
// PhanPluginUnknownObjectMethodCall : 1040+ occurrences
// PhanUndeclaredProperty : 840+ occurrences
@ -41,7 +41,6 @@ return [
// PhanRedefinedClassReference : 20+ occurrences
// PhanTypeComparisonFromArray : 15+ occurrences
// PhanTypeExpectedObjectPropAccessButGotNull : 15+ occurrences
// PhanTypeMismatchDimFetchNullable : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanPluginBothLiteralsBinaryOp : 10+ occurrences
// PhanPluginConstantVariableBool : 10+ occurrences
@ -49,14 +48,15 @@ return [
// PhanPluginDuplicateExpressionBinaryOp : 10+ occurrences
// PhanPluginSuspiciousParamPosition : 10+ occurrences
// PhanRedefineClass : 10+ occurrences
// PhanTypeMismatchDimFetchNullable : 10+ occurrences
// PhanEmptyFQSENInClasslike : 5 occurrences
// PhanInvalidFQSENInClasslike : 4 occurrences
// PhanParamTooMany : 4 occurrences
// PhanTypeConversionFromArray : 3 occurrences
// PhanNoopStringLiteral : 2 occurrences
// PhanTypeComparisonToArray : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
// PhanAccessPropertyStaticAsNonStatic : 1 occurrence
// PhanNoopStringLiteral : 1 occurrence
// PhanPluginWhitespaceTrailing : 1 occurrence
// PhanTypeArraySuspiciousNull : 1 occurrence
// PhanTypeMismatchReturn : 1 occurrence
@ -517,7 +517,7 @@ return [
'htdocs/core/class/commonhookactions.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType'],
'htdocs/core/class/commonincoterm.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredProperty'],
'htdocs/core/class/commoninvoice.class.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypePossiblyInvalidDimOffset'],
'htdocs/core/class/commonobject.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownObjectMethodCall', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredProperty'],
'htdocs/core/class/commonobject.class.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredProperty'],
'htdocs/core/class/commonobjectline.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/class/commonorder.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType'],
'htdocs/core/class/commonpeople.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
@ -543,6 +543,7 @@ return [
'htdocs/core/class/fiscalyear.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/class/google.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/class/hookmanager.class.php' => ['PhanTypeInvalidDimOffset', 'PhanUndeclaredProperty'],
'htdocs/core/class/html.form.class.php' => ['PhanTypeArraySuspiciousNullable'],
'htdocs/core/class/html.formaccounting.class.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/class/html.formadmin.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
'htdocs/core/class/html.formbarcode.class.php' => ['PhanPluginUnknownArrayMethodParamType'],
@ -1362,7 +1363,6 @@ return [
'htdocs/takepos/ajax/ajax.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeObjectUnsetDeclaredProperty', 'PhanUndeclaredProperty'],
'htdocs/takepos/floors.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/takepos/freezone.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/takepos/genimg/index.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/takepos/index.php' => ['PhanTypeInvalidDimOffset', 'PhanTypePossiblyInvalidDimOffset'],
'htdocs/takepos/invoice.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPluginEmptyStatementIf', 'PhanPluginSuspiciousParamPosition', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypePossiblyInvalidDimOffset', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/takepos/pay.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentProbablyReal'],

File diff suppressed because it is too large Load Diff

View File

@ -601,18 +601,18 @@ function getCountry($searchkey, $withcode = '', $dbtouse = null, $outputlangs =
* Return state translated from an id. Return value is always utf8 encoded and without entities.
*
* @param int $id id of state (province/departement)
* @param string $withcode '0'=Return label,
* '1'=Return string code + label,
* '2'=Return code,
* 'all'=return array('id'=>,'code'=>,'label'=>)
* @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
* @param int $withregion '0'=Ignores region,
* @param '0'|'1'|'2'|'all' $withcode '0'=Return label,
* '1'=Return string code + label,
* '2'=Return code,
* 'all'=return array('id'=>,'code'=>,'label'=>)
* @param ?DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
* @param int<0,1> $withregion '0'=Ignores region,
* '1'=Add region name/code/id as needed to output,
* @param Translate $outputlangs Langs object for output translation, not fully implemented yet
* @param int $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
* @return string|array String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region')
* @param int<0,1> $entconv 0=Return value without entities and not converted to output charset, 1=Ready for html output
* @return string|array{id:int,code:string,label:string}|array{id:int,code:string,label:string,region_code:string,region:string} String with state code or state name or Array('id','code','label')/Array('id','code','label','region_code','region')
*/
function getState($id, $withcode = '', $dbtouse = null, $withregion = 0, $outputlangs = null, $entconv = 1)
function getState($id, $withcode = '0', $dbtouse = null, $withregion = 0, $outputlangs = null, $entconv = 1)
{
global $db, $langs;

View File

@ -2914,7 +2914,7 @@ function dol_bc($var, $moreclass = '')
* @param Object $object A company or contact object
* @param int $withcountry 1=Add country into address string
* @param string $sep Separator to use to separate info when building string
* @param Translate $outputlangs Object lang that contains language for text translation.
* @param ?Translate $outputlangs Object lang that contains language for text translation.
* @param int $mode 0=Standard output, 1=Remove address
* @param string $extralangcode User extralanguage $langcode as values for address, town
* @return string Formatted string

View File

@ -843,7 +843,7 @@ class Position extends CommonObject
* Return HTML string to put an input field into a page
* Code very similar with showInputField of extra fields
*
* @param array $val Array of properties for field to show
* @param ?array{type:string,label:string,enabled:int|string,position:int,notnull?:int,visible:int,noteditable?:int,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int,css?:string,csslist?:string,help?:string,showoncombobox?:int,disabled?:int,arrayofkeyval?:array<int,string>,comment?:string} $val Array of properties for field to show
* @param string $key Key of attribute
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
* @param string $moreparam To add more parameters on html input tag