Phpstan Baseline < 4000 Lines Part 2 Html (#3037)
Continue to reduce the size of Phpstan Baseline by fixing problems reported for Writer/Html.
This commit is contained in:
parent
9eb5e7e976
commit
4f8aa806bc
|
|
@ -3155,316 +3155,6 @@ parameters:
|
|||
count: 2
|
||||
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Call to function array_key_exists\\(\\) with int and array\\{none\\: 'none', dashDot\\: '1px dashed', dashDotDot\\: '1px dotted', dashed\\: '1px dashed', dotted\\: '1px dotted', double\\: '3px double', hair\\: '1px solid', medium\\: '2px solid', \\.\\.\\.\\} will always evaluate to false\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'mime' on array\\|false\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 0 on array\\|false\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 1 on array\\|false\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getSubscript\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getSuperscript\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:calculateSpansOmitRows\\(\\) has parameter \\$candidateSpannedRow with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:calculateSpansOmitRows\\(\\) has parameter \\$sheet with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:calculateSpansOmitRows\\(\\) has parameter \\$sheetIndex with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateHTMLFooter\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateMeta\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateMeta\\(\\) has parameter \\$desc with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateMeta\\(\\) has parameter \\$val with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$cellAddress with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$columnNumber with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellCss\\(\\) has parameter \\$row with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellData\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellData\\(\\) has parameter \\$cell with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellData\\(\\) has parameter \\$cellType with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellData\\(\\) has parameter \\$cssClass with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellDataValue\\(\\) has parameter \\$cell with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellDataValue\\(\\) has parameter \\$cellData with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellDataValueRich\\(\\) has parameter \\$cell with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowCellDataValueRich\\(\\) has parameter \\$cellData with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowIncludeCharts\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowIncludeCharts\\(\\) has parameter \\$coordinate with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowSpans\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowSpans\\(\\) has parameter \\$colSpan with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowSpans\\(\\) has parameter \\$html with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowSpans\\(\\) has parameter \\$rowSpan with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$cellData with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$cellType with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$colNum with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$colSpan with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$coordinate with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$cssClass with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$html with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$row with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$rowSpan with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateRowWriteCell\\(\\) has parameter \\$sheetIndex with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetPrep\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetStarts\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetStarts\\(\\) has parameter \\$rowMin with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetStarts\\(\\) has parameter \\$sheet with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetTags\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetTags\\(\\) has parameter \\$row with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetTags\\(\\) has parameter \\$tbodyStart with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetTags\\(\\) has parameter \\$theadEnd with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateSheetTags\\(\\) has parameter \\$theadStart with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableFooter\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableTag\\(\\) has parameter \\$html with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableTag\\(\\) has parameter \\$id with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableTag\\(\\) has parameter \\$sheetIndex with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableTagInline\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:generateTableTagInline\\(\\) has parameter \\$id with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$borderStyle of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:mapBorderStyle\\(\\) expects int, string given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$font of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:createCSSStyleFont\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font, PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$hAlign of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:mapHAlign\\(\\) expects string, string\\|null given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$vAlign of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Html\\:\\:mapVAlign\\(\\) expects string, string\\|null given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int\\<0, max\\>\\|false given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$use_include_path of function fopen expects bool, int given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Html.php
|
||||
|
||||
-
|
||||
message: "#^Negated boolean expression is always false\\.$#"
|
||||
count: 1
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ parameters:
|
|||
processTimeout: 300.0
|
||||
checkMissingIterableValueType: false
|
||||
ignoreErrors:
|
||||
- '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy) expects (GdImage|resource), GdImage\|resource given\.$~'
|
||||
- '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy|imagepng) expects (GdImage|resource), GdImage\|resource given\.$~'
|
||||
- '~^Parameter \#2 \$src_im(age)? of function imagecopy expects (GdImage|resource), GdImage\|resource given\.$~'
|
||||
# Accept a bit anything for assert methods
|
||||
- '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~'
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ class Html extends BaseWriter
|
|||
/**
|
||||
* Map border style.
|
||||
*
|
||||
* @param int $borderStyle Sheet index
|
||||
* @param int|string $borderStyle Sheet index
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -354,7 +354,7 @@ class Html extends BaseWriter
|
|||
return $this;
|
||||
}
|
||||
|
||||
private static function generateMeta($val, $desc)
|
||||
private static function generateMeta(?string $val, string $desc): string
|
||||
{
|
||||
return $val
|
||||
? (' <meta name="' . $desc . '" content="' . htmlspecialchars($val, Settings::htmlEntityFlags()) . '" />' . PHP_EOL)
|
||||
|
|
@ -398,7 +398,7 @@ class Html extends BaseWriter
|
|||
return $html;
|
||||
}
|
||||
|
||||
private function generateSheetPrep()
|
||||
private function generateSheetPrep(): array
|
||||
{
|
||||
// Ensure that Spans have been calculated?
|
||||
$this->calculateSpans();
|
||||
|
|
@ -413,7 +413,7 @@ class Html extends BaseWriter
|
|||
return $sheets;
|
||||
}
|
||||
|
||||
private function generateSheetStarts($sheet, $rowMin)
|
||||
private function generateSheetStarts(Worksheet $sheet, int $rowMin): array
|
||||
{
|
||||
// calculate start of <tbody>, <thead>
|
||||
$tbodyStart = $rowMin;
|
||||
|
|
@ -432,7 +432,7 @@ class Html extends BaseWriter
|
|||
return [$theadStart, $theadEnd, $tbodyStart];
|
||||
}
|
||||
|
||||
private function generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart)
|
||||
private function generateSheetTags(int $row, int $theadStart, int $theadEnd, int $tbodyStart): array
|
||||
{
|
||||
// <thead> ?
|
||||
$startTag = ($row == $theadStart) ? (' <thead>' . PHP_EOL) : '';
|
||||
|
|
@ -682,7 +682,7 @@ class Html extends BaseWriter
|
|||
if ($this->embedImages || substr($imageData, 0, 6) === 'zip://') {
|
||||
$picture = @file_get_contents($filename);
|
||||
if ($picture !== false) {
|
||||
$imageDetails = getimagesize($filename);
|
||||
$imageDetails = getimagesize($filename) ?: [];
|
||||
// base64 encode the binary data
|
||||
$base64 = base64_encode($picture);
|
||||
$imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
|
||||
|
|
@ -697,12 +697,10 @@ class Html extends BaseWriter
|
|||
$imageResource = $drawing->getImageResource();
|
||||
if ($imageResource) {
|
||||
ob_start(); // Let's start output buffering.
|
||||
// @phpstan-ignore-next-line
|
||||
imagepng($imageResource); // This will normally output the image, but because of ob_start(), it won't.
|
||||
$contents = ob_get_contents(); // Instead, output above is saved to $contents
|
||||
$contents = (string) ob_get_contents(); // Instead, output above is saved to $contents
|
||||
ob_end_clean(); // End the output buffer.
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
$dataUri = 'data:image/png;base64,' . base64_encode($contents);
|
||||
|
||||
// Because of the nature of tables, width is more important than height.
|
||||
|
|
@ -738,21 +736,18 @@ class Html extends BaseWriter
|
|||
}
|
||||
|
||||
$html .= PHP_EOL;
|
||||
$imageDetails = getimagesize($chartFileName);
|
||||
$imageDetails = getimagesize($chartFileName) ?: [];
|
||||
$filedesc = $chart->getTitle();
|
||||
$filedesc = $filedesc ? $filedesc->getCaptionText() : '';
|
||||
$filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) : 'Embedded chart';
|
||||
if ($fp = fopen($chartFileName, 'rb', 0)) {
|
||||
$picture = fread($fp, filesize($chartFileName));
|
||||
fclose($fp);
|
||||
/** @phpstan-ignore-next-line */
|
||||
$picture = file_get_contents($chartFileName);
|
||||
if ($picture !== false) {
|
||||
$base64 = base64_encode($picture);
|
||||
$imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
|
||||
|
||||
$html .= '<img style="position: absolute; z-index: 1; left: ' . $chartCoordinates['xOffset'] . 'px; top: ' . $chartCoordinates['yOffset'] . 'px; width: ' . $imageDetails[0] . 'px; height: ' . $imageDetails[1] . 'px;" src="' . $imageData . '" alt="' . $filedesc . '" />' . PHP_EOL;
|
||||
|
||||
unlink($chartFileName);
|
||||
}
|
||||
unlink($chartFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -993,8 +988,8 @@ class Html extends BaseWriter
|
|||
$css = [];
|
||||
|
||||
// Create CSS
|
||||
$css['vertical-align'] = $this->mapVAlign($alignment->getVertical());
|
||||
$textAlign = $this->mapHAlign($alignment->getHorizontal());
|
||||
$css['vertical-align'] = $this->mapVAlign($alignment->getVertical() ?? '');
|
||||
$textAlign = $this->mapHAlign($alignment->getHorizontal() ?? '');
|
||||
if ($textAlign) {
|
||||
$css['text-align'] = $textAlign;
|
||||
if (in_array($textAlign, ['left', 'right'])) {
|
||||
|
|
@ -1070,10 +1065,8 @@ class Html extends BaseWriter
|
|||
* Create CSS style.
|
||||
*
|
||||
* @param Border $border Border
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createCSSStyleBorder(Border $border)
|
||||
private function createCSSStyleBorder(Border $border): string
|
||||
{
|
||||
// Create CSS - add !important to non-none border styles for merged cells
|
||||
$borderStyle = $this->mapBorderStyle($border->getBorderStyle());
|
||||
|
|
@ -1095,7 +1088,8 @@ class Html extends BaseWriter
|
|||
|
||||
// Create CSS
|
||||
if ($fill->getFillType() !== Fill::FILL_NONE) {
|
||||
$value = '#' . $fill->getStartColor()->getRGB();
|
||||
$value = $fill->getFillType() == Fill::FILL_NONE ?
|
||||
'white' : '#' . $fill->getStartColor()->getRGB();
|
||||
$css['background-color'] = $value;
|
||||
}
|
||||
|
||||
|
|
@ -1105,7 +1099,7 @@ class Html extends BaseWriter
|
|||
/**
|
||||
* Generate HTML footer.
|
||||
*/
|
||||
public function generateHTMLFooter()
|
||||
public function generateHTMLFooter(): string
|
||||
{
|
||||
// Construct HTML
|
||||
$html = '';
|
||||
|
|
@ -1115,7 +1109,7 @@ class Html extends BaseWriter
|
|||
return $html;
|
||||
}
|
||||
|
||||
private function generateTableTagInline(Worksheet $worksheet, $id)
|
||||
private function generateTableTagInline(Worksheet $worksheet, string $id): string
|
||||
{
|
||||
$style = isset($this->cssStyles['table']) ?
|
||||
$this->assembleCSS($this->cssStyles['table']) : '';
|
||||
|
|
@ -1135,7 +1129,7 @@ class Html extends BaseWriter
|
|||
return $html;
|
||||
}
|
||||
|
||||
private function generateTableTag(Worksheet $worksheet, $id, &$html, $sheetIndex): void
|
||||
private function generateTableTag(Worksheet $worksheet, string $id, string &$html, int $sheetIndex): void
|
||||
{
|
||||
if (!$this->useInlineCss) {
|
||||
$gridlines = $worksheet->getShowGridlines() ? ' gridlines' : '';
|
||||
|
|
@ -1188,7 +1182,7 @@ class Html extends BaseWriter
|
|||
/**
|
||||
* Generate table footer.
|
||||
*/
|
||||
private function generateTableFooter()
|
||||
private function generateTableFooter(): string
|
||||
{
|
||||
return ' </tbody></table>' . PHP_EOL . '</div>' . PHP_EOL;
|
||||
}
|
||||
|
|
@ -1234,7 +1228,7 @@ class Html extends BaseWriter
|
|||
return $html;
|
||||
}
|
||||
|
||||
private function generateRowCellCss(Worksheet $worksheet, $cellAddress, $row, $columnNumber)
|
||||
private function generateRowCellCss(Worksheet $worksheet, string $cellAddress, int $row, int $columnNumber): array
|
||||
{
|
||||
$cell = ($cellAddress > '') ? $worksheet->getCellCollection()->get($cellAddress) : '';
|
||||
$coordinate = Coordinate::stringFromColumnIndex($columnNumber + 1) . ($row + 1);
|
||||
|
|
@ -1260,22 +1254,24 @@ class Html extends BaseWriter
|
|||
return [$cell, $cssClass, $coordinate];
|
||||
}
|
||||
|
||||
private function generateRowCellDataValueRich($cell, &$cellData): void
|
||||
private function generateRowCellDataValueRich(Cell $cell, string &$cellData): void
|
||||
{
|
||||
// Loop through rich text elements
|
||||
$elements = $cell->getValue()->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
// Rich text start?
|
||||
if ($element instanceof Run) {
|
||||
$cellData .= '<span style="' . $this->assembleCSS($this->createCSSStyleFont($element->getFont())) . '">';
|
||||
|
||||
$cellEnd = '';
|
||||
if ($element->getFont()->getSuperscript()) {
|
||||
$cellData .= '<sup>';
|
||||
$cellEnd = '</sup>';
|
||||
} elseif ($element->getFont()->getSubscript()) {
|
||||
$cellData .= '<sub>';
|
||||
$cellEnd = '</sub>';
|
||||
if ($element->getFont() !== null) {
|
||||
$cellData .= '<span style="' . $this->assembleCSS($this->createCSSStyleFont($element->getFont())) . '">';
|
||||
|
||||
if ($element->getFont()->getSuperscript()) {
|
||||
$cellData .= '<sup>';
|
||||
$cellEnd = '</sup>';
|
||||
} elseif ($element->getFont()->getSubscript()) {
|
||||
$cellData .= '<sub>';
|
||||
$cellEnd = '</sub>';
|
||||
}
|
||||
}
|
||||
|
||||
// Convert UTF8 data to PCDATA
|
||||
|
|
@ -1293,7 +1289,7 @@ class Html extends BaseWriter
|
|||
}
|
||||
}
|
||||
|
||||
private function generateRowCellDataValue(Worksheet $worksheet, $cell, &$cellData): void
|
||||
private function generateRowCellDataValue(Worksheet $worksheet, Cell $cell, ?string &$cellData): void
|
||||
{
|
||||
if ($cell->getValue() instanceof RichText) {
|
||||
$this->generateRowCellDataValueRich($cell, $cellData);
|
||||
|
|
@ -1319,7 +1315,11 @@ class Html extends BaseWriter
|
|||
}
|
||||
}
|
||||
|
||||
private function generateRowCellData(Worksheet $worksheet, $cell, &$cssClass, $cellType)
|
||||
/**
|
||||
* @param null|Cell|string $cell
|
||||
* @param array|string $cssClass
|
||||
*/
|
||||
private function generateRowCellData(Worksheet $worksheet, $cell, &$cssClass, string $cellType): string
|
||||
{
|
||||
$cellData = ' ';
|
||||
if ($cell instanceof Cell) {
|
||||
|
|
@ -1339,10 +1339,10 @@ class Html extends BaseWriter
|
|||
$cellData = nl2br($cellData);
|
||||
|
||||
// Extend CSS class?
|
||||
if (!$this->useInlineCss) {
|
||||
if (!$this->useInlineCss && is_string($cssClass)) {
|
||||
$cssClass .= ' style' . $cell->getXfIndex();
|
||||
$cssClass .= ' ' . $cell->getDataType();
|
||||
} else {
|
||||
} elseif (is_array($cssClass)) {
|
||||
if ($cellType == 'th') {
|
||||
if (isset($this->cssStyles['th.style' . $cell->getXfIndex()])) {
|
||||
$cssClass = array_merge($cssClass, $this->cssStyles['th.style' . $cell->getXfIndex()]);
|
||||
|
|
@ -1372,12 +1372,12 @@ class Html extends BaseWriter
|
|||
return $cellData;
|
||||
}
|
||||
|
||||
private function generateRowIncludeCharts(Worksheet $worksheet, $coordinate)
|
||||
private function generateRowIncludeCharts(Worksheet $worksheet, string $coordinate): string
|
||||
{
|
||||
return $this->includeCharts ? $this->writeChartInCell($worksheet, $coordinate) : '';
|
||||
}
|
||||
|
||||
private function generateRowSpans($html, $rowSpan, $colSpan)
|
||||
private function generateRowSpans(string $html, int $rowSpan, int $colSpan): string
|
||||
{
|
||||
$html .= ($colSpan > 1) ? (' colspan="' . $colSpan . '"') : '';
|
||||
$html .= ($rowSpan > 1) ? (' rowspan="' . $rowSpan . '"') : '';
|
||||
|
|
@ -1385,7 +1385,10 @@ class Html extends BaseWriter
|
|||
return $html;
|
||||
}
|
||||
|
||||
private function generateRowWriteCell(&$html, Worksheet $worksheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $row): void
|
||||
/**
|
||||
* @param array|string $cssClass
|
||||
*/
|
||||
private function generateRowWriteCell(string &$html, Worksheet $worksheet, string $coordinate, string $cellType, string $cellData, int $colSpan, int $rowSpan, $cssClass, int $colNum, int $sheetIndex, int $row): void
|
||||
{
|
||||
// Image?
|
||||
$htmlx = $this->writeImageInCell($worksheet, $coordinate);
|
||||
|
|
@ -1393,7 +1396,7 @@ class Html extends BaseWriter
|
|||
$htmlx .= $this->generateRowIncludeCharts($worksheet, $coordinate);
|
||||
// Column start
|
||||
$html .= ' <' . $cellType;
|
||||
if (!$this->useInlineCss && !$this->isPdf) {
|
||||
if (!$this->useInlineCss && !$this->isPdf && is_string($cssClass)) {
|
||||
$html .= ' class="' . $cssClass . '"';
|
||||
if ($htmlx) {
|
||||
$html .= " style='position: relative;'";
|
||||
|
|
@ -1403,9 +1406,11 @@ class Html extends BaseWriter
|
|||
// We must explicitly write the width of the <td> element because TCPDF
|
||||
// does not recognize e.g. <col style="width:42pt">
|
||||
if ($this->useInlineCss) {
|
||||
$xcssClass = $cssClass;
|
||||
$xcssClass = is_array($cssClass) ? $cssClass : [];
|
||||
} else {
|
||||
$html .= ' class="' . $cssClass . '"';
|
||||
if (is_string($cssClass)) {
|
||||
$html .= ' class="' . $cssClass . '"';
|
||||
}
|
||||
$xcssClass = [];
|
||||
}
|
||||
$width = 0;
|
||||
|
|
@ -1416,8 +1421,7 @@ class Html extends BaseWriter
|
|||
$width += $this->columnWidths[$sheetIndex][$i];
|
||||
}
|
||||
}
|
||||
$xcssClass['width'] = $width . 'pt';
|
||||
|
||||
$xcssClass['width'] = (string) $width . 'pt';
|
||||
// We must also explicitly write the height of the <td> element because TCPDF
|
||||
// does not recognize e.g. <tr style="height:50pt">
|
||||
if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $row]['height'])) {
|
||||
|
|
@ -1736,7 +1740,7 @@ class Html extends BaseWriter
|
|||
$this->spansAreCalculated = true;
|
||||
}
|
||||
|
||||
private function calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRow): void
|
||||
private function calculateSpansOmitRows(Worksheet $sheet, int $sheetIndex, array $candidateSpannedRow): void
|
||||
{
|
||||
// Identify which rows should be omitted in HTML. These are the rows where all the cells
|
||||
// participate in a merge and the where base cells are somewhere above.
|
||||
|
|
|
|||
Loading…
Reference in New Issue