2
0
forked from Wavyzz/dolibarr

Merge pull request #28872 from mdeweerd/fix/PhanTypeMismatchReturnProbablyReal

Fix & enable PhanTypeMismatchReturnProbablyReal
This commit is contained in:
Laurent Destailleur
2024-03-15 15:24:31 +01:00
committed by GitHub
6 changed files with 19 additions and 14 deletions

View File

@@ -591,7 +591,7 @@ return [
// 'PhanPluginPossiblyStaticProtectedMethod',
'PhanTypeMismatchReturn',
// 'PhanPluginMoreSpecificActualReturnType',
'PhanTypeMismatchReturnProbablyReal',
// 'PhanTypeMismatchReturnProbablyReal',
'PhanPossiblyUndeclaredVariable',
'PhanTypeMismatchArgument',
// 'PhanPluginUnreachableCode',

View File

@@ -406,8 +406,8 @@ class ChargeSociales extends CommonObject
/**
* 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)
{

View File

@@ -8955,7 +8955,7 @@ abstract class CommonObject
/**
* 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()
{

View File

@@ -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{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string}> Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...)
* @return array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string}> 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)
{

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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 @@ class Contacts extends DolibarrApi
* @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 @@ class Contacts extends DolibarrApi
*
* @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 @@ class Contacts extends DolibarrApi
*
* @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 @@ class Contacts extends DolibarrApi
* @return int ID of user
*
* @url POST {id}/createUser
* @suppress PhanPluginUnknownArrayMethodParamType Luracast limitation
*/
public function createUser($id, $request_data = null)
{
@@ -573,8 +577,8 @@ class Contacts extends DolibarrApi
/**
* 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)

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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 @@ class RestAPIContactTest extends CommonClassTest
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
/*