From 27bd0b10a1662b35d7e7ed4a8a651f0a52e07958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 7 Dec 2024 08:50:39 +0100 Subject: [PATCH 1/3] fix phpstan --- build/phpstan/phpstan-baseline.neon | 24 ------------------------ htdocs/public/clicktodial/cidlookup.php | 6 +++++- htdocs/public/company/new.php | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 16a99021701..5472bc4f29f 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -28524,36 +28524,12 @@ parameters: count: 1 path: ../../htdocs/public/company/new.php - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 11 - path: ../../htdocs/public/company/new.php - - message: '#^Variable \$ext in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable count: 1 path: ../../htdocs/public/company/new.php - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 23 - path: ../../htdocs/public/company/new.php - - message: '#^Variable \$object might not be defined\.$#' identifier: variable.undefined diff --git a/htdocs/public/clicktodial/cidlookup.php b/htdocs/public/clicktodial/cidlookup.php index 3ec7024855d..feb1253e760 100644 --- a/htdocs/public/clicktodial/cidlookup.php +++ b/htdocs/public/clicktodial/cidlookup.php @@ -1,5 +1,6 @@ + * Copyright (C) 2024 Frédéric France * * 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 @@ -51,7 +52,10 @@ if (!defined('USESUFFIXINLOG')) { } include '../../main.inc.php'; - +/** + * @var Conf $conf + * @var DoliDB $db + */ $phone = GETPOST('phone'); $securitykey = GETPOST('securitykey'); diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index 7a3622d62b8..17fff91ff79 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -63,6 +63,13 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/public.lib.php'; + +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + */ // Init vars $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -219,13 +226,13 @@ if (empty($reshook) && $action == 'add') { // Test on permission not required he $societe->name = GETPOST('name', 'alphanohtml'); $societe->client = GETPOSTINT('client') ? GETPOSTINT('client') : $societe->client; - $societe->address = GETPOST('address', 'alphanohtml'); - $societe->country_id = GETPOSTINT('country_id'); - $societe->phone = GETPOST('phone', 'alpha'); - $societe->fax = GETPOST('fax', 'alpha'); - $societe->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); + $societe->address = GETPOST('address', 'alphanohtml'); + $societe->country_id = GETPOSTINT('country_id'); + $societe->phone = GETPOST('phone', 'alpha'); + $societe->fax = GETPOST('fax', 'alpha'); + $societe->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); $societe->client = 2 ; // our client is a prospect - $societe->code_client = '-1'; + $societe->code_client = '-1'; $societe->name_alias = GETPOST('name_alias', 'alphanohtml'); $societe->note_private = GETPOST('note_private', 'alphanohtml'); @@ -460,7 +467,7 @@ if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA')) { print ''; print ''; print ''; - print '' . img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"') . ''; + print '' . img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"') . ''; print ''; print ''; } From 69681e6450bd425c5b47b0c3269f7d936c3d9375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 7 Dec 2024 09:03:44 +0100 Subject: [PATCH 2/3] fix phpstan --- build/phpstan/phpstan-baseline.neon | 36 --------------------- htdocs/public/company/new.php | 29 ++++++++--------- htdocs/public/cron/cron_run_jobs_by_url.php | 9 ++++-- 3 files changed, 21 insertions(+), 53 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 5472bc4f29f..f66b38c48be 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -28512,42 +28512,6 @@ parameters: count: 1 path: ../../htdocs/public/company/new.php - - - message: '#^If condition is always true\.$#' - identifier: if.alwaysTrue - count: 1 - path: ../../htdocs/public/company/new.php - - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 1 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$ext in empty\(\) always exists and is always falsy\.$#' - identifier: empty.variable - count: 1 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$object might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$php_self might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/public/company/new.php - - - - message: '#^Variable \$user might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../htdocs/public/company/new.php - - message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index 17fff91ff79..f750ac88cea 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -8,7 +8,7 @@ * Copyright (C) 2018 Alexandre Spangaro * Copyright (C) 2021 Waël Almoman * Copyright (C) 2022 Udo Tamm - * Copyright (C) 2024 MDW + * 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 @@ -69,6 +69,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/public.lib.php'; * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs + * @var User $user */ // Init vars $backtopage = GETPOST('backtopage', 'alpha'); @@ -91,7 +92,7 @@ if (!getDolGlobalString('SOCIETE_ENABLE_PUBLIC')) { } -//permissions +// permissions $permissiontoadd = $user->hasRight('societe', 'creer'); @@ -139,16 +140,16 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ print '
'; // Output html code for logo - if ($urllogo) { - print '
'; - print '
'; - print ''; - print '
'; - if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { - print ''; - } - print '
'; + // if ($urllogo) { // test always true + print '
'; + print '
'; + print ''; + print '
'; + if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) { + print ''; } + print '
'; + // } if (getDolGlobalString('MEMBER_IMAGE_PUBLIC_REGISTRATION')) { print '
'; @@ -170,15 +171,13 @@ function llxFooterVierge() { global $conf, $langs; - $ext = ''; - print '
'; printCommonFooter('public'); if (!empty($conf->use_javascript_ajax)) { print "\n" . '' . "\n"; - print '' . "\n"; + print '' . "\n"; } print "\n"; @@ -436,7 +435,7 @@ if (isModEnabled('mailing') && getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRE print ''; } print '' . $form->editfieldkey($langs->trans('No_Email') . ' (' . $langs->trans('Contact') . ')', 'contact_no_email', '', $objectsoc, 0) . ''; - print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '') . '>' . $form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($objectsoc->no_email) ? 0 : 1)), 1, false, 1) . ''; + print 'browser->layout == 'phone') /* || !isModEnabled('mailing') */ ? ' colspan="3"' : '') . '>' . $form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($objectsoc->no_email) ? 0 : 1)), 1, false, 1) . ''; } print ''; diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php index 012c18b08f2..2c2bd2e7670 100644 --- a/htdocs/public/cron/cron_run_jobs_by_url.php +++ b/htdocs/public/cron/cron_run_jobs_by_url.php @@ -4,6 +4,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur * Copyright (C) 2017 Regis Houssin * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -69,8 +70,12 @@ require '../../main.inc.php'; // cron jobs library dol_include_once("/cron/class/cronjob.class.php"); - -global $langs, $conf; +/** + * @var Conf $conf + * @var DoliDB $db + * @var Translate $langs + */ +global $langs, $conf, $db; // Language Management $langs->loadLangs(array("admin", "cron", "dict")); From c1b213b39f5e6de7ef671d6440bc0d5bf40d7d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 7 Dec 2024 14:21:23 +0100 Subject: [PATCH 3/3] fix phpstan --- build/phpstan/phpstan-baseline.neon | 6 ------ htdocs/public/company/new.php | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index f66b38c48be..9b4bcbd707b 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -28506,12 +28506,6 @@ parameters: count: 1 path: ../../htdocs/public/clicktodial/cidlookup.php - - - message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/public/company/new.php - - message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/htdocs/public/company/new.php b/htdocs/public/company/new.php index f750ac88cea..f7942e267c5 100644 --- a/htdocs/public/company/new.php +++ b/htdocs/public/company/new.php @@ -46,9 +46,9 @@ if (!defined('NOBROWSERNOTIF')) { // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php // Because 2 entities can have the same ref $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_numeric($entity)) { - define("DOLENTITY", $entity); -} +// if (is_numeric($entity)) { // value is casted to int so always numeric +define("DOLENTITY", $entity); +// } // Load Dolibarr environment