Skip to content

Commit

Permalink
Merge pull request #28872 from mdeweerd/fix/PhanTypeMismatchReturnPro…
Browse files Browse the repository at this point in the history
…bablyReal

Fix & enable PhanTypeMismatchReturnProbablyReal
  • Loading branch information
eldy authored Mar 15, 2024
2 parents 6042ea9 + e5cf547 commit b658bea
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dev/tools/phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
// 'PhanPluginPossiblyStaticProtectedMethod',
'PhanTypeMismatchReturn',
// 'PhanPluginMoreSpecificActualReturnType',
'PhanTypeMismatchReturnProbablyReal',
// 'PhanTypeMismatchReturnProbablyReal',
'PhanPossiblyUndeclaredVariable',
'PhanTypeMismatchArgument',
// 'PhanPluginUnreachableCode',
Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/sociales/class/chargesociales.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
10 changes: 5 additions & 5 deletions htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
12 changes: 8 additions & 4 deletions htdocs/societe/class/api_contacts.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <[email protected]>
* Copyright (C) 2019 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion test/phpunit/RestAPIContactTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <[email protected]>
* Copyright (C) 2023 Alexandre Janniaux <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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
Expand Down Expand Up @@ -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
/*
Expand Down

0 comments on commit b658bea

Please sign in to comment.