Skip to content

Commit

Permalink
Merge pull request #32320 from frederic34/contact_canvas_phpstan
Browse files Browse the repository at this point in the history
fix phan and phpstan
  • Loading branch information
eldy authored Dec 17, 2024
2 parents 10c2902 + 35d0f91 commit b17167d
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 215 deletions.
4 changes: 3 additions & 1 deletion build/phpstan/bootstrap_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}

// Defined some constants and load Dolibarr env to reduce PHPStan bootstrap that fails to load a lot of things.
$dolibarr_main_document_root = __DIR__ . '/../../htdocs';
define('DOL_DOCUMENT_ROOT', __DIR__ . '/../../htdocs');
define('DOL_DATA_ROOT', __DIR__ . '/../../documents');
define('DOL_URL_ROOT', '/');
Expand All @@ -42,6 +43,7 @@
* @var User $user
*/

global $conf, $db, $hookmanager, $langs, $mysoc, $user;
global $conf, $db, $hookmanager, $langs, $mysoc, $user;
global $dolibarr_main_document_root;

// include_once DOL_DOCUMENT_ROOT . '/../../htdocs/main.inc.php';
186 changes: 0 additions & 186 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1176,18 +1176,6 @@ parameters:
count: 2
path: ../../htdocs/admin/agenda.php

-
message: '#^Variable \$label might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/admin/agenda_other.php

-
message: '#^Variable \$label might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/admin/agenda_reminder.php

-
message: '#^Variable \$errorsaved in empty\(\) always exists and is always falsy\.$#'
identifier: empty.variable
Expand Down Expand Up @@ -1734,18 +1722,6 @@ parameters:
count: 1
path: ../../htdocs/admin/system/security.php

-
message: '#^Variable \$arrayofstreamtodisable might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/admin/system/security.php

-
message: '#^Variable \$conffile might not be defined\.$#'
identifier: variable.undefined
count: 4
path: ../../htdocs/admin/system/security.php

-
message: '#^Variable \$dolibarr_main_document_root might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -2562,42 +2538,12 @@ parameters:
count: 1
path: ../../htdocs/asset/tpl/depreciation_options_view.tpl.php

-
message: '#^Variable \$langs might not be defined\.$#'
identifier: variable.undefined
count: 7
path: ../../htdocs/asset/tpl/depreciation_options_view.tpl.php

-
message: '#^Variable \$parameters might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/asset/tpl/depreciation_options_view.tpl.php

-
message: '#^Unable to resolve the template type T in call to function dol_sort_array$#'
identifier: argument.templateType
count: 1
path: ../../htdocs/asset/tpl/depreciation_view.tpl.php

-
message: '#^Variable \$assetdepreciationoptions might not be defined\.$#'
identifier: variable.undefined
count: 7
path: ../../htdocs/asset/tpl/depreciation_view.tpl.php

-
message: '#^Variable \$db might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/asset/tpl/depreciation_view.tpl.php

-
message: '#^Variable \$langs might not be defined\.$#'
identifier: variable.undefined
count: 7
path: ../../htdocs/asset/tpl/depreciation_view.tpl.php

-
message: '#^Variable \$parameters might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -2850,72 +2796,12 @@ parameters:
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Cannot access property \$db on mixed\.$#'
identifier: property.nonObject
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$buyer might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$dateSelector might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$hookmanager might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$i might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$langs might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$line might not be defined\.$#'
identifier: variable.undefined
count: 20
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$seller might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^Variable \$var might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/bom/tpl/objectline_edit.tpl.php

-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
Expand All @@ -2928,12 +2814,6 @@ parameters:
count: 1
path: ../../htdocs/bom/tpl/objectline_view.tpl.php

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/bom/tpl/objectline_view.tpl.php

-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
Expand Down Expand Up @@ -7410,60 +7290,6 @@ parameters:
count: 1
path: ../../htdocs/contact/ajax/contact.php

-
message: '#^Cannot access property \$control on mixed\.$#'
identifier: property.nonObject
count: 24
path: ../../htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 24
path: ../../htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php

-
message: '#^Cannot access property \$control on mixed\.$#'
identifier: property.nonObject
count: 31
path: ../../htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 29
path: ../../htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php

-
message: '#^Cannot access property \$control on mixed\.$#'
identifier: property.nonObject
count: 34
path: ../../htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php

-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 32
path: ../../htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php

-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
Expand Down Expand Up @@ -13992,12 +13818,6 @@ parameters:
count: 2
path: ../../htdocs/core/modules/member/doc/pdf_standard_member.class.php

-
message: '#^Parameter \#1 \$substitutionarray of function complete_substitutions_array expects array\<string, string\>, array\<string, int\|string\> given\.$#'
identifier: argument.type
count: 1
path: ../../htdocs/core/modules/member/doc/pdf_standard_member.class.php

-
message: '#^Parameter \#6 \$epaisseur of method CommonStickerGenerator\:\:_Croix\(\) expects int, float given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -33090,12 +32910,6 @@ parameters:
count: 1
path: ../../htdocs/variants/list.php

-
message: '#^Variable \$rowid might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/variants/list.php

-
message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/agenda_other.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php

$param = GETPOST('param', 'alpha');
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/agenda_reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php

$param = GETPOST('param', 'alpha');
Expand Down
3 changes: 3 additions & 0 deletions htdocs/admin/system/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*
* @var string[] $arrayofstreamtodisable // $arrayofstreamtodisable is defined into filefunc.inc.php
* @var string $conffile // $conffile is defined into filefunc.inc.php
*/

// Load translation files required by the page
Expand Down
5 changes: 3 additions & 2 deletions htdocs/asset/tpl/depreciation_options_view.tpl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -30,6 +30,7 @@
* @var Form $form
* @var HookManager $hookmanager
* @var AssetDepreciationOptions $assetdepreciationoptions
* @var Translate $langs
*/
'
@phan-var-force ?Form $form
Expand Down
9 changes: 7 additions & 2 deletions htdocs/asset/tpl/depreciation_view.tpl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -27,8 +27,13 @@
*/

/**
* @var AssetDepreciationOptions $assetdepreciationoptions
* @var DoliDB $db
* @var Form $form
* @var HookManager $hookmanager
* @var Translate $langs
*
* @var string $action
*/

// Protection to avoid direct call of template
Expand Down
32 changes: 22 additions & 10 deletions htdocs/bom/tpl/objectline_edit.tpl.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2024 Vincent Maury <vmaury@timgroup.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Vincent Maury <vmaury@timgroup.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
Expand All @@ -34,7 +34,19 @@
*/

require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";

/**
* @var BOMLine $line
* @var CommonObject $this
* @var CommonObject $object
* @var HookManager $hookmanager
* @var Societe $buyer
* @var Societe $seller
* @var Translate $langs
*
* @var string $action
* @var int $i
* @var bool $var
*/

// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
Expand Down
1 change: 1 addition & 0 deletions htdocs/bom/tpl/objectline_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*
* @var int $i
* @var int $num
* @var string $action
*/
'
@phan-var-force CommonObjectLine $line
Expand Down
Loading

0 comments on commit b17167d

Please sign in to comment.