From aefde297dfa5eb8c837b5e1106bd2ff111668cd7 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 21:12:55 +0800 Subject: [PATCH] More cleanup PHPDoc according to PhpStorm --- samples/Basic/26_Utf8.php | 23 +++++++------------ .../Calculation/DateTimeExcel/Month.php | 5 ++-- .../Calculation/DateTimeExcel/TimeValue.php | 3 --- .../Statistical/Distributions/GammaBase.php | 3 +-- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/samples/Basic/26_Utf8.php b/samples/Basic/26_Utf8.php index 2eeca067b..a466b9f49 100644 --- a/samples/Basic/26_Utf8.php +++ b/samples/Basic/26_Utf8.php @@ -16,27 +16,20 @@ $spreadsheet->getActiveSheet()->setPrintGridlines(true); $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']); // Export to PDF (mpdf) -function mpdfCjkWriter(Mpdf $writer): void -{ - /** @var callable */ - $callback = 'mpdfCjk'; - $writer->setEditHtmlCallback($callback); -} +$mpdfCjkWriter = function (Mpdf $writer): void { + $mpdfCjk = function (string $html): string { + $html = str_replace("'Calibri'", "'Calibri',Sun-ExtA", $html); -function mpdfCjk(string $html): string -{ - $html = str_replace("'Calibri'", "'Calibri',Sun-ExtA", $html); + return str_replace("'Times New Roman'", "'Times New Roman',Sun-ExtA", $html); + }; - return str_replace("'Times New Roman'", "'Times New Roman',Sun-ExtA", $html); -} + $writer->setEditHtmlCallback($mpdfCjk); +}; $helper->log('Write to Mpdf'); IOFactory::registerWriter('Pdf', Mpdf::class); -/** @var callable */ -$callback = 'mpdfCjkWriter'; $filename = __FILE__; -//$filename = str_replace('.php', '.mdpf.php', __FILE__); -$helper->write($spreadsheet, $filename, ['Pdf'], false, $callback); +$helper->write($spreadsheet, $filename, ['Pdf'], false, $mpdfCjkWriter); // Remove first two rows with field headers before exporting to CSV $helper->log('Removing first two heading rows for CSV export'); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php index 9308acc58..f653c2fe4 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; +use DateTime; use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; use PhpOffice\PhpSpreadsheet\Calculation\Exception; @@ -28,12 +29,12 @@ class Month * a negative value yields a past date. * Or can be an array of adjustment values * - * @return array|mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, + * @return array|DateTime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function adjust(mixed $dateValue, array|string|bool|float|int $adjustmentMonths) + public static function adjust(mixed $dateValue, array|string|bool|float|int $adjustmentMonths): DateTime|float|int|string|array { if (is_array($dateValue) || is_array($adjustmentMonths)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index d1e9ceb6a..5a2f2461b 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -59,11 +59,8 @@ class TimeValue $PHPDateArray = Helpers::dateParse($timeValue); $retValue = ExcelError::VALUE(); if (Helpers::dateParseSucceeded($PHPDateArray)) { - /** @var int $hour */ $hour = $PHPDateArray['hour']; - /** @var int $minute */ $minute = $PHPDateArray['minute']; - /** @var int $second */ $second = $PHPDateArray['second']; // OpenOffice-specific code removed - it works just like Excel $excelDateValue = SharedDateHelper::formattedPHPToExcel(1900, 1, 1, $hour, $minute, $second) - 1; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php index 01901a60c..6ce99d8be 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php @@ -17,8 +17,7 @@ abstract class GammaBase private const MAX_ITERATIONS = 256; - /** @return float|string */ - protected static function calculateDistribution(float $value, float $a, float $b, bool $cumulative) + protected static function calculateDistribution(float $value, float $a, float $b, bool $cumulative): float { if ($cumulative) { return self::incompleteGamma($a, $value / $b) / self::gammaValue($a);