diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 2c1a24b4a94bd..f11b816d841a7 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -591,7 +591,7 @@ // 'PhanPluginPossiblyStaticProtectedMethod', 'PhanTypeMismatchReturn', // 'PhanPluginMoreSpecificActualReturnType', - 'PhanTypeMismatchReturnProbablyReal', + // 'PhanTypeMismatchReturnProbablyReal', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', // 'PhanPluginUnreachableCode', diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 153cb7d53ff0b..d91ce98999e29 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -406,8 +406,8 @@ public function update($user, $notrigger = 0) /** * Calculate amount remaining to pay by year * - * @param int $year Year - * @return int|float + * @param int $year Year + * @return int|float Returns -1 when error (Note: could be mistaken with an amount) */ public function solde($year = 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f39066e368e1c..6b534b516b3d4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8955,7 +8955,7 @@ function setListDependencies'.$type.'() { /** * Returns the rights used for this class * - * @return int|stdClass Object of permission for the module + * @return null|int|stdClass Object of permission for the module */ public function getRights() { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5b18aee94af92..3d9117894a222 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -57,7 +57,7 @@ function dol_basename($pathfile) * @param string $relativename For recursive purpose only. Must be "" at first call. * @param int $donotfollowsymlinks Do not follow symbolic links * @param int $nbsecondsold Only files older than $nbsecondsold - * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) + * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)> * @see dol_dir_list_in_database() */ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "", $donotfollowsymlinks = 0, $nbsecondsold = 0) @@ -2621,10 +2621,10 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = * * @param string $dir Directory to scan * @param string $regexfilter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function - * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function - * @param int $nohook Disable all hooks - * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only - * @return array Array with properties (full path, date, ...) of to most recent file + * @param string[] $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). This regex value must be escaped for '/', since this char is used for preg_match function + * @param int<0,1> $nohook Disable all hooks + * @param int<0,3> $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only + * @return null|array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string} null if none or Array with properties (full path, date, ...) of the most recent file */ function dol_most_recent_file($dir, $regexfilter = '', $excludefilter = array('(\.meta|_preview.*\.png)$', '^\.'), $nohook = 0, $mode = 0) { diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 7fd087024c362..db6e2158e1fec 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2019 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -167,7 +168,7 @@ public function getByEmail($email, $includecount = 0, $includeroles = 0) * @param int $includecount Count and return also number of elements the contact is used as a link for * @param int $includeroles Includes roles of the contact * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names - * @return array Array of contact objects + * @return Contact[] Array of contact objects * * @throws RestException */ @@ -273,6 +274,8 @@ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, * * @param array $request_data Request datas * @return int ID of contact + * + * @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation */ public function post($request_data = null) { @@ -311,7 +314,7 @@ public function post($request_data = null) * * @param int $id Id of contact to update * @param array $request_data Datas - * @return Object Updated object + * @return Object|false Updated object, false when issue toupdate */ public function put($id, $request_data = null) { @@ -389,6 +392,7 @@ public function delete($id) * @return int ID of user * * @url POST {id}/createUser + * @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation */ public function createUser($id, $request_data = null) { @@ -573,8 +577,8 @@ protected function _cleanObjectDatas($object) /** * Validate fields before create or update object * - * @param array|null $data Data to validate - * @return array + * @param string[]|null $data Data to validate + * @return string[] * @throws RestException */ private function _validate($data) diff --git a/test/phpunit/RestAPIContactTest.php b/test/phpunit/RestAPIContactTest.php index 4af37c718e078..dd4173ab6ffb7 100644 --- a/test/phpunit/RestAPIContactTest.php +++ b/test/phpunit/RestAPIContactTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * 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 @@ -229,7 +230,7 @@ public function testRestUpdateContact($objid) print_r($updateResponse); // Check if the updated fields match the changes you made - $this->assertTrue($updateResponse['firstname'] === $updateBody['firstname'], 'Update might have failed'); + $this->assertEquals($updateBody['firstname'], $updateResponse['firstname'], 'Update failed for request body: '.$updateRequestBody); // Deleting the Contact /*