Qual: Fix notices in api_interventions, phpstan notice

This commit is contained in:
MDW 2025-01-29 01:03:16 +01:00
parent bea27b0be4
commit 991afe2b21
No known key found for this signature in database
2 changed files with 22 additions and 14 deletions

View File

@ -746,7 +746,7 @@ if ($action == 'create') {
} // else { $object->lines[$i]->fk_product_type; }
// TODO: $objp is not set here, so why test?
if (isset($objp) && is_object($objp)) {
if (isset($objp) && is_object($objp)) { // $objp always null @phpstan-ignore-line
// Try to enhance type detection using date_start and date_end for free lines when type
// was not saved.
if (!empty($objp->date_start)) {

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 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
@ -36,21 +36,21 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
class Interventions extends DolibarrApi
{
/**
* @var array Mandatory fields, checked when create and update object
* @var string[] Mandatory fields, checked when create and update object
*/
public static $FIELDS = array(
'socid',
'fk_project',
'description',
'socid',
'fk_project',
'description',
);
/**
* @var array Mandatory fields, checked when create and update object
* @var string[] Mandatory fields, checked when create and update object
*/
public static $FIELDSLINE = array(
'description',
'date',
'duree',
'description',
'date',
'duree',
);
/**
@ -108,6 +108,8 @@ class Interventions extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @return array Array of order objects
* @phan-return array<object>
* @phpstan-return array<object>
*
* @throws RestException
*/
@ -187,6 +189,8 @@ class Interventions extends DolibarrApi
* Create intervention object
*
* @param array $request_data Request data
* @phan-param ?array<string,string> $request_data
* @phpstan-param ?array<string,string> $request_data
* @return int ID of intervention
*/
public function post($request_data = null)
@ -252,6 +256,8 @@ class Interventions extends DolibarrApi
*
* @param int $id Id of intervention to update
* @param array $request_data Request data
* @phan-param ?array<string,string> $request_data
* @phpstan-param ?array<string,string> $request_data
*
* @url POST {id}/lines
*
@ -303,6 +309,8 @@ class Interventions extends DolibarrApi
*
* @param int $id Order ID
* @return array
* @phan-return array<string,array{code:int,message:string}>
* @phpstan-return array<string,array{code:int,message:string}>
*/
public function delete($id)
{
@ -412,8 +420,8 @@ class Interventions extends DolibarrApi
/**
* Validate fields before create or update object
*
* @param array $data Data to validate
* @return array
* @param ?array<null|int|float|string> $data Data to validate
* @return array<string,null|int|float|string>
*
* @throws RestException
*/
@ -451,8 +459,8 @@ class Interventions extends DolibarrApi
/**
* Validate fields before create or update object
*
* @param array $data Data to validate
* @return array
* @param array<string,null|int|float|string> $data Data to validate
* @return array<string,null|int|float|string> Return array with validated mandatory fields and their value
*
* @throws RestException
*/