Qual: Fix phan notices (#31193)

# Qual: Fix phan notices

Fix phan notices in several classes that have UnknownObjectMethod calls and classes
that had notices in relation with these classes
This commit is contained in:
MDW
2024-09-30 10:05:24 +02:00
committed by GitHub
parent 1754ee61d5
commit 8236aed22f
42 changed files with 618 additions and 221 deletions

View File

@@ -37,6 +37,9 @@ class Interfaces
*/
public $db;
/**
* @var string
*/
public $dir; // Directory with all core and external triggers files
/**
@@ -184,6 +187,7 @@ class Interfaces
}
$objMod = new $modName($this->db);
'@phan-var-force DolibarrTriggers $objMod';
if ($objMod) {
$dblevelbefore = $this->db->transaction_opened;
@@ -194,6 +198,7 @@ class Interfaces
$result = $objMod->runTrigger($action, $object, $user, $langs, $conf);
} elseif (method_exists($objMod, 'run_trigger')) { // Deprecated method
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING);
// @phan-suppress-next-line PhanUndeclaredMethod
$result = $objMod->run_trigger($action, $object, $user, $langs, $conf);
} else {
dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR);
@@ -248,8 +253,8 @@ class Interfaces
* Return list of triggers. Function used by admin page htdoc/admin/triggers.
* List is sorted by trigger filename so by priority to run.
*
* @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only.
* @return array Array list of triggers
* @param ?array<int,string> $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only.
* @return array<array{picto:string,file:string,fullpath:string,relpath:string,iscoreorexternal?:'internal'|'external',version?:string,status?:string,module?:string,info:string}> Array list of triggers
*/
public function getTriggersList($forcedirtriggers = null)
{
@@ -334,6 +339,7 @@ class Interfaces
try {
$objMod = new $modName($db);
'@phan-var-force DolibarrTriggers $objMod';
if (is_subclass_of($objMod, 'DolibarrTriggers')) {
// Define disabledbyname and disabledbymodule
@@ -395,7 +401,7 @@ class Interfaces
$triggers[$j]['status'] = img_picto('Error: Trigger '.$modName.' does not extends DolibarrTriggers', 'warning');
//print 'Error: Trigger '.$modName.' does not extends DolibarrTriggers<br>';
$text = 'Error: Trigger '.$modName.' does not extends DolibarrTriggers';
$text = 'Error: Trigger '.$modName.' does not extend DolibarrTriggers';
}
} catch (Exception $e) {
print $e->getMessage();