Qual: More specific phpstan exceptions (#30967)

* Qual: 🛟 Fix typing

Qual: Fix typing

Fix some typing currently failing ci in develop.

* Fix typing for grabimages

* Qual: More specific phpstan exceptions

# Qual: More specific phpstan exceptions

Avoid ignoring new types of code errors
This commit is contained in:
MDW 2024-09-16 01:46:20 +02:00 committed by GitHub
parent 22ae541e3b
commit 320f0590d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 22 deletions

View file

@ -1325,7 +1325,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
* To get image from an external URL to download first, see getAllImages()
*
* @param string $htmlContent HTML content
* @param string $imageNumber The position of image. 1 by default = first image found
* @param int $imageNumber The position of image. 1 by default = first image found
* @return string URL of image or '' if not foud
*/
function getImageFromHtmlContent($htmlContent, $imageNumber = 1)
@ -1353,7 +1353,7 @@ function getImageFromHtmlContent($htmlContent, $imageNumber = 1)
if ($imageNumber > 0 && $imageNumber <= $images->length) {
// Récupère l'image correspondante (index - 1 car $imageNumber est 1-based)
$img = $images->item($imageNumber - 1);
if ($img) {
if ($img instanceof DOMElement) {
return $img->getAttribute('src');
}
}
@ -1372,9 +1372,9 @@ function getImageFromHtmlContent($htmlContent, $imageNumber = 1)
* @param string $urltograb URL to grab (example: https://www.nltechno.com/ or s://www.nltechno.com/dir1/ or https://www.nltechno.com/dir1/mapage1)
* @param string $tmp Content to parse
* @param string $action Var $action
* @param int $modifylinks 0=Do not modify content, 1=Replace links with a link to viewimage
* @param int $grabimages 0=Do not grab images, 1=Grab images
* @param string $grabimagesinto 'root' or 'subpage'
* @param int<0,1> $modifylinks 0=Do not modify content, 1=Replace links with a link to viewimage
* @param int<0,1> $grabimages 0=Do not grab images, 1=Grab images
* @param 'root'|'subpage' $grabimagesinto 'root' or 'subpage'
* @return void
*/
function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks = 0, $grabimages = 1, $grabimagesinto = 'subpage')

View file

@ -764,7 +764,7 @@ if ($action == 'addcontainer' && $usercanedit) {
if (GETPOSTISSET('fetchexternalurl')) { // Fetch from external url
$urltograb = GETPOST('externalurl', 'alpha');
$grabimages = GETPOST('grabimages', 'alpha');
$grabimages = GETPOSTINT('grabimages') ? 1 : 0;
$grabimagesinto = GETPOST('grabimagesinto', 'alpha');
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

View file

@ -66,13 +66,16 @@ parameters:
- '#expects \(callable#'
- '#expects bool\|string#'
- '#expects bool, int#'
- '#expects bool, string given.#'
- '#expects int\|string#'
- '#expects int\|null#'
- '# (dol_getdate|dol_concatdesc|vatrate) expects bool, string given.#'
- '# SMTPs::(getFrom|getErrorsTo|getReplyTo)\(\) expects bool, string given.#'
- '# (dolibarr_set_const|yn|getLocalTaxesFromRate) expects int\|string#'
- '#::(options)\(\) expects int\|string#'
- '# (print_barre_liste|getCurrentPeriodOfFiscalYear|dol_substr|get_next_value) expects int\|null#'
- '#color.* expects int, string#'
- '#imap.* expects int, string#'
- '#convert.* expects int, string#'
- '#\(\) expects int, string#'
- '# (Setup|Asset|Proposals|Orders|Invoices|FactureRec|BonPrelevement|Products|Thirdparties)::_fetch\S*\(\) expects int, string#'
- '#(getFullName|sendTicketMessageByEmail|addItemsFact|update_price|setPhoneNumber|recur|addDepreciationLine|addline|generate|buildRumNumber|update|update_label|getSelectConditionsPaiements|select_state|listBoxes|addLineRec|literalBarcodeType)\(\) expects int, string#'
- '#run_sql expects int, string#'
- '#on array{url: mixed} in empty\(\) does not exist.#'
- '#dol_copy expects string, int given#'
@ -80,25 +83,51 @@ parameters:
- '#EvalMath::trigger\(\) expects string, int given#'
- '#get_next_value expects string, int given#'
- '#pdf_writeLinkedObjects expects string, int given#'
- '# Diff::generatePartialDiff\(\) expects array#'
- '# EmailCollector::getpart\(\) expects string#'
- '#expects int, float#'
- '#expects int, array\|string given.#'
- '#::saveboxorder\(\) expects int, array#'
- '# (print_projecttasks(_array)?|dol_time_plus_duree|get_default_tva|get_default_npr) expects int, array#'
- '# (fetchObjectByElement|print_actions_filter|dol_mktime|dol_get_first_day|dol_get_last_day|dol_remove_file_process|displayUsersListWithPicto) expects int, array\|string given.#'
- '# (CSMSFile) constructor expects int, array\|string given.#'
- "# (img_picto) expects int<0, 1>, (false|'') given.#"
- '#expects float\|string#'
- '#expects float\|null#'
- '#expects float, string given.#'
- '#expects string\|null,#'
- '#expects string, \(float\|int\) given.#'
- '#expects string, (float(\|(int|array))(\<.*\>)?)+ given.#'
- '#expects string, (false|true|null|DateTime|float|array(<.*>)?) given.#'
- '# (envoi_mail|sendEmailTo) expects string, \(float\|int\) given.#'
- '#::printStdColumnContent\(\) expects string, float(\|(int|array)(\<.*\>)?)* given.#'
- '#::HTML2OpenIDServer\(\) expects string, array given.#'
- '# (dol_strlen|vatrate) expects string, float(\|(int|array)(\<.*\>)?)* given.#'
- '# dol_escape_htmltag expects string, float given.#'
- '#create_line\(\) expects string, float given.#'
- '# dol_stringtotime expects string, DateTime given.#'
- '# (load_fiche_titre|llxHeader|dol_add_file_process|setEventMessages) expects string, null given.#'
- '# (show_ldap_content|projectLinesa) expects string, true given.#'
- '# DolEditor constructor expects string, false given.#'
- '# dol_eval expects string, array given.#'
- '#expects string, bool\|mysqli_result\|resource given.#'
- '#expects array\{#'
- '#expects array<array\{#'
- '#expects array\|LDAP#'
- '#expects array<int#'
- '#expects array\|string#'
- '#expects array\|null#'
- '#expects array<string#'
- '#expects array, (null|string) given.#'
- '#( |::)((multi)?selectarray)\(\) expects array#'
- '# (reWriteAllMenus|check_authentication) expects array#'
- '# (dol_get_fiche_head) expects array<int#'
- '#::(_validateMyObject|select_company)\(\) expects array<string#'
- '# (dol_print_error|get_htmloutput_mesg|dolGetButtonTitle|dol_htmloutput_errors|dol_htmloutput_mesg) expects array<string#'
- '# getNav expects array#'
- '# getCommonSubstitutionArray expects array#'
- '# llxHeader expects array#'
- '# ajax_constantonoff expects array, null given.#'
- '# ldap_search expects array\|LDAP#'
- '# ajax_combobox expects array#'
- '# setlocale expects array#'
- '# setEventMessages expects array#'
- '# Context::setError\(\) expects array, string#'
- '# Form::formconfirm\(\) expects array#'
- '# FormWebPortal::selectForForms\(\) expects int, array#'
- '# Lettering::getBankLinesFromFkDocAndDocType\(\) expects array#'
- '# form_constantes expects array#'
- '# dolGetButtonAction expects array#'
- '# (Odf) constructor expects #'
- '# Stripe[^ ]+::all\(\) expects #'
- '#expects resource#'
- '#expects object#'
- '#expects FTP\\Connection#'