Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix phpstan #32222

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18696,12 +18696,6 @@ parameters:
count: 4
path: ../../htdocs/eventorganization/conferenceorboothattendee_card.php

-
message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../htdocs/eventorganization/conferenceorboothattendee_card.php

-
message: '#^Variable \$text might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -18768,12 +18762,6 @@ parameters:
count: 1
path: ../../htdocs/eventorganization/core/actions_massactions_mail.inc.php

-
message: '#^Variable \$dolibarr_main_url_root might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/eventorganization/core/actions_massactions_mail.inc.php

-
message: '#^Variable \$from might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -21549,42 +21537,6 @@ parameters:
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
count: 2
path: ../../htdocs/holiday/card.php

-
message: '#^Parameter \#4 \$month of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 8
path: ../../htdocs/holiday/card.php

-
message: '#^Parameter \#5 \$day of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 8
path: ../../htdocs/holiday/card.php

-
message: '#^Parameter \#6 \$year of function dol_mktime expects int, array\<mixed\>\|string given\.$#'
identifier: argument.type
count: 8
path: ../../htdocs/holiday/card.php

-
message: '#^Variable \$canread might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/holiday/card.php

-
message: '#^Variable \$endhalfdaykey might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/holiday/card.php

-
message: '#^Variable \$starthalfdaykey might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/holiday/card.php

Expand Down Expand Up @@ -24426,12 +24378,6 @@ parameters:
count: 1
path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php

-
message: '#^Parameter \#3 \$tab_height of method pdf_standard_myobject\:\:_tableau\(\) expects int, float given\.$#'
identifier: argument.type
count: 6
path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php

-
message: '#^Property pdf_standard_myobject\:\:\$cols \(array\<string, array\{rank\: int, width\: float\|int, status\: bool, title\: array\{textkey\: string, label\: string, align\: string, padding\: array\{float, float, float, float\}\}, content\: array\{align\: string, padding\: array\{float, float, float, float\}\}\}\>\) does not accept non\-empty\-array\<string, array\{rank\: 0, width\: false, status\: true, title\: array\{textkey\: ''Designation'', align\: ''L'', padding\: array\{0\.5, 0\.5, 0\.5, 0\.5\}\}, content\: array\{align\: ''L'', padding\: array\{1, 0\.5, 1, 1\.5\}\}\}\|array\{rank\: int, width\: float\|int, status\: bool, title\: array\{textkey\: string, label\: string, align\: string, padding\: array\{float, float, float, float\}\}, content\: array\{align\: string, padding\: array\{float, float, float, float\}\}\}\>\.$#'
identifier: assign.propertyType
Expand Down Expand Up @@ -24492,12 +24438,6 @@ parameters:
count: 1
path: ../../htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php

-
message: '#^Variable \$object might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php

-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
Expand Down Expand Up @@ -27756,12 +27696,6 @@ parameters:
count: 1
path: ../../htdocs/projet/admin/project.php

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

-
message: '#^Call to function method_exists\(\) with Project and ''fetchComments'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand Down
6 changes: 4 additions & 2 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,10 @@ function GETPOSTFLOAT($paramname, $rounding = '')
* @param string $hourTime 'getpost' to include hour, minute, second values from the HTTP request,
* or 'XX:YY:ZZ' to set hour, minute, second respectively (for instance '23:59:59')
* or '' means '00:00:00' (default)
* @param string $gm Passed to dol_mktime
* @param int|string $gm Passed to dol_mktime
* @return int|string Date as a timestamp, '' or false if error
*
* @see dol_mktime()
*/
function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto')
{
Expand Down Expand Up @@ -3647,7 +3649,7 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
* @param int $month Month (1 to 12)
* @param int $day Day (1 to 31)
* @param int $year Year
* @param mixed $gm True or 1 or 'gmt'=Input information are GMT values
* @param bool|int|string $gm True or 1 or 'gmt'=Input information are GMT values
* False or 0 or 'tzserver' = local to server TZ
* 'auto'
* 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented.
Expand Down
32 changes: 17 additions & 15 deletions htdocs/holiday/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);

$canread = 0;
if (($id > 0) || $ref) {
$object->fetch($id, $ref);

// Check current user can read this leave request
$canread = 0;
if ($user->hasRight('holiday', 'readall')) {
$canread = 1;
}
Expand Down Expand Up @@ -169,10 +169,10 @@

$db->begin();

$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
$date_debut = GETPOSTDATE('date_debut_', '00:00:00');
$date_fin = GETPOSTDATE('date_fin_', '00:00:00');
$date_debut_gmt = GETPOSTDATE('date_debut_', '00:00:00', 1);
$date_fin_gmt = GETPOSTDATE('date_fin_', '00:00:00', 1);
$starthalfday = GETPOST('starthalfday');
$endhalfday = GETPOST('endhalfday');
$type = GETPOST('type');
Expand Down Expand Up @@ -325,10 +325,10 @@
}

if ($action == 'update' && !GETPOSTISSET('savevalidator')) { // Test on permission done later
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
$date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
$date_debut = GETPOSTDATE('date_debut_', '00:00:00');
$date_fin = GETPOSTDATE('date_fin_', '00:00:00');
$date_debut_gmt = GETPOSTDATE('date_debut_', '00:00:00', 1);
$date_fin_gmt = GETPOSTDATE('date_fin_', '00:00:00', 1);
$starthalfday = GETPOST('starthalfday');
$endhalfday = GETPOST('endhalfday');
$halfday = 0;
Expand Down Expand Up @@ -542,6 +542,9 @@
} elseif ($object->halfday == 0 || $object->halfday == 2) {
$starthalfdaykey = "Morning";
$endhalfdaykey = "Afternoon";
} else {
$starthalfdaykey = "";
$endhalfdaykey = "";
}

$link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id;
Expand Down Expand Up @@ -1154,7 +1157,7 @@
if (!GETPOST('date_debut_')) { // If visitor does not come from agenda
print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year'));
$tmpdate = GETPOSTDATE('date_debut_', '00:00:00');
print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1);
}
print ' &nbsp; &nbsp; ';
Expand All @@ -1171,7 +1174,7 @@
if (!GETPOST('date_fin_')) {
print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1);
} else {
$tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_fin_month'), GETPOSTINT('date_fin_day'), GETPOSTINT('date_fin_year'));
$tmpdate = GETPOSTDATE('date_fin_', '00:00:00');
print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1);
}
print ' &nbsp; &nbsp; ';
Expand Down Expand Up @@ -1349,7 +1352,7 @@
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
print '</td>';
print '<td>';
$tmpdate = dol_mktime(0, 0, 0, GETPOSTINT('date_debut_month'), GETPOSTINT('date_debut_day'), GETPOSTINT('date_debut_year'));
$tmpdate = GETPOSTDATE('date_debut_', '00:00:00');
print $form->selectDate($tmpdate ? $tmpdate : $object->date_debut, 'date_debut_');
print ' &nbsp; &nbsp; ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday') ? GETPOST('starthalfday') : $starthalfday));
Expand Down Expand Up @@ -1650,9 +1653,8 @@
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre

$includedocgeneration = 0;

// Documents
/* $includedocgeneration = 0;
if ($includedocgeneration) {
$objref = dol_sanitizeFileName($object->ref);
$relativepath = $objref.'/'.$objref.'.pdf';
Expand All @@ -1661,7 +1663,7 @@
$genallowed = ($user->hasRight('holiday', 'read') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'readall'); // If you can read, you can build the PDF to read content
$delallowed = ($user->hasRight('holiday', 'write') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'writeall_advance'); // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('holiday:Holiday', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
}
} */

// Show links to link elements
//$tmparray = $form->showLinkToObjectBlock($object, null, array('myobject'), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function __construct($db)
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;

dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));

Expand Down Expand Up @@ -854,8 +854,8 @@ public static function liste_modeles($db, $maxfilenamelength = 0)
* Show table for lines
*
* @param TCPDF|TCPDI $pdf Object PDF
* @param int $tab_top Top position of table
* @param int $tab_height Height of table (rectangle)
* @param float $tab_top Top position of table
* @param float $tab_height Height of table (rectangle)
* @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object
* @param int<-1,1> $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) ---Replace with your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -17,6 +18,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* @var CommonObject $object
* @var Translate $langs
* @var User $user
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
print "Error, template page can't be called as URL";
Expand Down
Loading