More Scrutinizer Catch Up (#3050)

* More Scrutinizer Catch Up

Continue the work of PR #3043 by attending to the 12 remaining 'new' issues.

* Php 8.1 Problem

One new null-instead-of-string problem.
This commit is contained in:
oleibman 2022-09-09 07:56:11 -07:00 committed by GitHub
parent 7e3807309d
commit b5f70de61d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 78 additions and 88 deletions

View File

@ -2590,21 +2590,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Worksheet/PageSetup.php
-
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\PageSetup\\:\\:setFirstPageNumber\\(\\) expects int, null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/PageSetup.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\PageSetup\\:\\:\\$pageOrder has no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/PageSetup.php
-
message: "#^Strict comparison using \\=\\=\\= between int\\<min, \\-1\\> and null will always evaluate to false\\.$#"
count: 1
path: src/PhpSpreadsheet/Worksheet/PageSetup.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\SheetView\\:\\:\\$sheetViewTypes has no type specified\\.$#"
count: 1

View File

@ -101,10 +101,10 @@ $dataSeriesValues = [
// marker details
$dataSeriesValues[0]
->getMarkerFillColor()
->setColorProperties('0070C0', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setColorProperties('0070C0', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
$dataSeriesValues[0]
->getMarkerBorderColor()
->setColorProperties('002060', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setColorProperties('002060', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
// line details - dashed, smooth line (Bezier) with arrows, 40% transparent
$dataSeriesValues[0]
@ -129,18 +129,18 @@ $dataSeriesValues[1] // square marker border color
->setColorProperties('accent6', 3, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
$dataSeriesValues[1] // square marker fill color
->getMarkerFillColor()
->setColorProperties('0FFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setColorProperties('0FFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
$dataSeriesValues[1]
->setScatterLines(true)
->setSmoothLine(false)
->setLineColorProperties('FF0000', 80, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setLineColorProperties('FF0000', 80, ChartColor::EXCEL_COLOR_TYPE_RGB);
$dataSeriesValues[1]->setLineWidth(2.0);
// series 3 - metric3, markers, no line
$dataSeriesValues[2] // triangle? fill
//->setPointMarker('triangle') // let Excel choose shape, which is predicted to be a triangle
->getMarkerFillColor()
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
$dataSeriesValues[2] // triangle border
->getMarkerBorderColor()
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
@ -239,7 +239,7 @@ $dataSeriesValues[0]
->setScatterlines(false); // disable connecting lines
$dataSeriesValues[0]
->getMarkerFillColor()
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
$dataSeriesValues[0]
->getMarkerBorderColor()
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
@ -326,7 +326,7 @@ $chart = new Chart(
// Set the position of the chart in the chart sheet below the first chart
$chart->setTopLeftPosition('A13');
$chart->setBottomRightPosition('P25');
$chart->setRoundedCorners('true'); // Rounded corners in Chart Outline
$chart->setRoundedCorners(true); // Rounded corners in Chart Outline
// Add the chart to the worksheet $chartSheet
$chartSheet->addChart($chart);
@ -350,8 +350,8 @@ function dateRange(int $nrows, Spreadsheet $wrkbk): array
$startDate = DateTime::createFromFormat('Y-m-d', $startDateStr); // php date obj
// get date of first day of the quarter of the start date
$startMonth = $startDate->format('n'); // suppress leading zero
$startYr = $startDate->format('Y');
$startMonth = (int) $startDate->format('n'); // suppress leading zero
$startYr = (int) $startDate->format('Y');
$qtr = intdiv($startMonth, 3) + (($startMonth % 3 > 0) ? 1 : 0);
$qtrStartMonth = sprintf('%02d', 1 + (($qtr - 1) * 3));
$qtrStartStr = "$startYr-$qtrStartMonth-01";
@ -360,8 +360,8 @@ function dateRange(int $nrows, Spreadsheet $wrkbk): array
// end the xaxis at the end of the quarter of the last date
$lastDateStr = $dataSheet->getCellByColumnAndRow(2, $nrows + 1)->getValue();
$lastDate = DateTime::createFromFormat('Y-m-d', $lastDateStr);
$lastMonth = $lastDate->format('n');
$lastYr = $lastDate->format('Y');
$lastMonth = (int) $lastDate->format('n');
$lastYr = (int) $lastDate->format('Y');
$qtr = intdiv($lastMonth, 3) + (($lastMonth % 3 > 0) ? 1 : 0);
$qtrEndMonth = 3 + (($qtr - 1) * 3);
$lastDOM = cal_days_in_month(CAL_GREGORIAN, $qtrEndMonth, $lastYr);

View File

@ -219,7 +219,7 @@ class Axis extends Properties
* @param ?int $alpha
* @param ?string $AlphaType
*/
public function setFillParameters($color, $alpha = null, $AlphaType = self::EXCEL_COLOR_TYPE_ARGB): void
public function setFillParameters($color, $alpha = null, $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void
{
$this->fillColor->setColorProperties($color, $alpha, $AlphaType);
}

View File

@ -774,9 +774,11 @@ class Chart
return $this->roundedCorners;
}
public function setRoundedCorners(bool $roundedCorners): self
public function setRoundedCorners(?bool $roundedCorners): self
{
$this->roundedCorners = $roundedCorners;
if ($roundedCorners !== null) {
$this->roundedCorners = $roundedCorners;
}
return $this;
}

View File

@ -306,22 +306,25 @@ class Xlsx extends BaseReader
return (bool) $c->v;
}
private static function castToError(SimpleXMLElement $c): ?string
private static function castToError(?SimpleXMLElement $c): ?string
{
return isset($c->v) ? (string) $c->v : null;
return isset($c, $c->v) ? (string) $c->v : null;
}
private static function castToString(SimpleXMLElement $c): ?string
private static function castToString(?SimpleXMLElement $c): ?string
{
return isset($c->v) ? (string) $c->v : null;
return isset($c, $c->v) ? (string) $c->v : null;
}
/**
* @param mixed $value
* @param mixed $calculatedValue
*/
private function castToFormula(SimpleXMLElement $c, string $r, string &$cellDataType, &$value, &$calculatedValue, array &$sharedFormulas, string $castBaseType): void
private function castToFormula(?SimpleXMLElement $c, string $r, string &$cellDataType, &$value, &$calculatedValue, array &$sharedFormulas, string $castBaseType): void
{
if ($c === null) {
return;
}
$attr = $c->f->attributes();
$cellDataType = 'f';
$value = "={$c->f}";

View File

@ -85,9 +85,9 @@ class AutoFilter
}
}
private function readCustomAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
private function readCustomAutoFilter(?SimpleXMLElement $filterColumn, Column $column): void
{
if ($filterColumn->customFilters) {
if (isset($filterColumn, $filterColumn->customFilters)) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
$customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join;
@ -104,9 +104,9 @@ class AutoFilter
}
}
private function readDynamicAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
private function readDynamicAutoFilter(?SimpleXMLElement $filterColumn, Column $column): void
{
if ($filterColumn->dynamicFilter) {
if (isset($filterColumn, $filterColumn->dynamicFilter)) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
// We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) {
@ -126,9 +126,9 @@ class AutoFilter
}
}
private function readTopTenAutoFilter(SimpleXMLElement $filterColumn, Column $column): void
private function readTopTenAutoFilter(?SimpleXMLElement $filterColumn, Column $column): void
{
if ($filterColumn->top10) {
if (isset($filterColumn, $filterColumn->top10)) {
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
// We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) {

View File

@ -11,7 +11,7 @@ use PhpOffice\PhpSpreadsheet\Chart\GridLines;
use PhpOffice\PhpSpreadsheet\Chart\Layout;
use PhpOffice\PhpSpreadsheet\Chart\Legend;
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
use PhpOffice\PhpSpreadsheet\Chart\Properties;
use PhpOffice\PhpSpreadsheet\Chart\Properties as ChartProperties;
use PhpOffice\PhpSpreadsheet\Chart\Title;
use PhpOffice\PhpSpreadsheet\Chart\TrendLine;
use PhpOffice\PhpSpreadsheet\RichText\RichText;
@ -113,6 +113,7 @@ class Chart
$plotSeries = $plotAttributes = [];
$catAxRead = false;
$plotNoFill = false;
/** @var SimpleXMLElement $chartDetail */
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) {
case 'spPr':
@ -121,17 +122,18 @@ class Chart
$plotNoFill = true;
}
if (isset($possibleNoFill->gradFill->gsLst)) {
/** @var SimpleXMLElement $gradient */
foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) {
/** @var float */
$pos = self::getAttribute($gradient, 'pos', 'float');
$gradientArray[] = [
$pos / Properties::PERCENTAGE_MULTIPLIER,
$pos / ChartProperties::PERCENTAGE_MULTIPLIER,
new ChartColor($this->readColor($gradient)),
];
}
}
if (isset($possibleNoFill->gradFill->lin)) {
$gradientLin = Properties::XmlToAngle((string) self::getAttribute($possibleNoFill->gradFill->lin, 'ang', 'string'));
$gradientLin = ChartProperties::XmlToAngle((string) self::getAttribute($possibleNoFill->gradFill->lin, 'ang', 'string'));
}
break;
@ -464,12 +466,13 @@ class Chart
$pointSize = null;
$noFill = false;
$bubble3D = false;
$dPtColors = [];
$dptColors = [];
$markerFillColor = null;
$markerBorderColor = null;
$lineStyle = null;
$labelLayout = null;
$trendLines = [];
/** @var SimpleXMLElement $seriesDetail */
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) {
case 'idx':
@ -487,7 +490,6 @@ class Chart
break;
case 'spPr':
$children = $seriesDetail->children($this->aNamespace);
$ln = $children->ln;
if (isset($children->ln)) {
$ln = $children->ln;
if (is_countable($ln->noFill) && count($ln->noFill) === 1) {
@ -1161,7 +1163,7 @@ class Chart
}
}
private function readEffects(SimpleXMLElement $chartDetail, ?Properties $chartObject): void
private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $chartObject): void
{
if (!isset($chartObject, $chartDetail->spPr)) {
return;
@ -1169,7 +1171,7 @@ class Chart
$sppr = $chartDetail->spPr->children($this->aNamespace);
if (isset($sppr->effectLst->glow)) {
$axisGlowSize = (float) self::getAttribute($sppr->effectLst->glow, 'rad', 'integer') / Properties::POINTS_WIDTH_MULTIPLIER;
$axisGlowSize = (float) self::getAttribute($sppr->effectLst->glow, 'rad', 'integer') / ChartProperties::POINTS_WIDTH_MULTIPLIER;
if ($axisGlowSize != 0.0) {
$colorArray = $this->readColor($sppr->effectLst->glow);
$chartObject->setGlowProperties($axisGlowSize, $colorArray['value'], $colorArray['alpha'], $colorArray['type']);
@ -1180,7 +1182,7 @@ class Chart
/** @var string */
$softEdgeSize = self::getAttribute($sppr->effectLst->softEdge, 'rad', 'string');
if (is_numeric($softEdgeSize)) {
$chartObject->setSoftEdges((float) Properties::xmlToPoints($softEdgeSize));
$chartObject->setSoftEdges((float) ChartProperties::xmlToPoints($softEdgeSize));
}
}
@ -1195,20 +1197,20 @@ class Chart
if ($type !== '') {
/** @var string */
$blur = self::getAttribute($sppr->effectLst->$type, 'blurRad', 'string');
$blur = is_numeric($blur) ? Properties::xmlToPoints($blur) : null;
$blur = is_numeric($blur) ? ChartProperties::xmlToPoints($blur) : null;
/** @var string */
$dist = self::getAttribute($sppr->effectLst->$type, 'dist', 'string');
$dist = is_numeric($dist) ? Properties::xmlToPoints($dist) : null;
$dist = is_numeric($dist) ? ChartProperties::xmlToPoints($dist) : null;
/** @var string */
$direction = self::getAttribute($sppr->effectLst->$type, 'dir', 'string');
$direction = is_numeric($direction) ? Properties::xmlToAngle($direction) : null;
$direction = is_numeric($direction) ? ChartProperties::xmlToAngle($direction) : null;
$algn = self::getAttribute($sppr->effectLst->$type, 'algn', 'string');
$rot = self::getAttribute($sppr->effectLst->$type, 'rotWithShape', 'string');
$size = [];
foreach (['sx', 'sy'] as $sizeType) {
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
if (is_numeric($sizeValue)) {
$size[$sizeType] = Properties::xmlToTenthOfPercent((string) $sizeValue);
$size[$sizeType] = ChartProperties::xmlToTenthOfPercent((string) $sizeValue);
} else {
$size[$sizeType] = null;
}
@ -1216,7 +1218,7 @@ class Chart
foreach (['kx', 'ky'] as $sizeType) {
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
if (is_numeric($sizeValue)) {
$size[$sizeType] = Properties::xmlToAngle((string) $sizeValue);
$size[$sizeType] = ChartProperties::xmlToAngle((string) $sizeValue);
} else {
$size[$sizeType] = null;
}
@ -1273,7 +1275,7 @@ class Chart
return $result;
}
private function readLineStyle(SimpleXMLElement $chartDetail, ?Properties $chartObject): void
private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $chartObject): void
{
if (!isset($chartObject, $chartDetail->spPr)) {
return;
@ -1287,7 +1289,7 @@ class Chart
/** @var string */
$lineWidthTemp = self::getAttribute($sppr->ln, 'w', 'string');
if (is_numeric($lineWidthTemp)) {
$lineWidth = Properties::xmlToPoints($lineWidthTemp);
$lineWidth = ChartProperties::xmlToPoints($lineWidthTemp);
}
/** @var string */
$compoundType = self::getAttribute($sppr->ln, 'cmpd', 'string');
@ -1296,15 +1298,13 @@ class Chart
/** @var string */
$capType = self::getAttribute($sppr->ln, 'cap', 'string');
if (isset($sppr->ln->miter)) {
$joinType = Properties::LINE_STYLE_JOIN_MITER;
$joinType = ChartProperties::LINE_STYLE_JOIN_MITER;
} elseif (isset($sppr->ln->bevel)) {
$joinType = Properties::LINE_STYLE_JOIN_BEVEL;
$joinType = ChartProperties::LINE_STYLE_JOIN_BEVEL;
} else {
$joinType = '';
}
$headArrowType = '';
$headArrowSize = '';
$endArrowType = '';
$endArrowSize = '';
/** @var string */
$headArrowType = self::getAttribute($sppr->ln->headEnd, 'type', 'string');
@ -1403,7 +1403,7 @@ class Chart
/** @var string */
$textRotation = self::getAttribute($children->bodyPr, 'rot', 'string');
if (is_numeric($textRotation)) {
$whichAxis->setAxisOption('textRotation', (string) Properties::xmlToAngle($textRotation));
$whichAxis->setAxisOption('textRotation', (string) ChartProperties::xmlToAngle($textRotation));
}
}
}

View File

@ -259,10 +259,11 @@ class PageSetup
/**
* First page number.
*
* @var int
* @var ?int
*/
private $firstPageNumber;
/** @var string */
private $pageOrder = self::PAGEORDER_DOWN_THEN_OVER;
/**
@ -375,7 +376,7 @@ class PageSetup
{
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 0, where 0 results in 100
if (($scale >= 0) || $scale === null) {
if ($scale === null || $scale >= 0) {
$this->scale = $scale;
if ($update) {
$this->fitToPage = false;
@ -845,7 +846,7 @@ class PageSetup
/**
* Get first page number.
*
* @return int
* @return ?int
*/
public function getFirstPageNumber()
{
@ -855,7 +856,7 @@ class PageSetup
/**
* Set first page number.
*
* @param int $value
* @param ?int $value
*
* @return $this
*/

View File

@ -1359,7 +1359,7 @@ class Worksheet implements IComparable
if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
// then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimension->getXfIndex());
$cell->setXfIndex(/** @scrutinizer ignore-type */ $rowDimension->getXfIndex());
} elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
// then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimension->getXfIndex());

View File

@ -24,6 +24,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Style\Style;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class Html extends BaseWriter
@ -1277,23 +1278,22 @@ class Html extends BaseWriter
}
}
private function generateRowCellDataValue(Worksheet $worksheet, Cell $cell, ?string &$cellData): void
private function generateRowCellDataValue(Worksheet $worksheet, Cell $cell, string &$cellData): void
{
if ($cell->getValue() instanceof RichText) {
$this->generateRowCellDataValueRich($cell, $cellData);
} else {
$origData = $this->preCalculateFormulas ? $cell->getCalculatedValue() : $cell->getValue();
$formatCode = $worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode();
if ($formatCode !== null) {
$cellData = NumberFormat::toFormattedString(
$origData,
$formatCode,
[$this, 'formatColor']
);
}
$cellData = NumberFormat::toFormattedString(
$origData ?? '',
$formatCode ?? NumberFormat::FORMAT_GENERAL,
[$this, 'formatColor']
);
if ($cellData === $origData) {
$cellData = htmlspecialchars($cellData ?? '', Settings::htmlEntityFlags());
$cellData = htmlspecialchars($cellData, Settings::htmlEntityFlags());
}
if ($worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperscript()) {
$cellData = '<sup>' . $cellData . '</sup>';
@ -1477,8 +1477,8 @@ class Html extends BaseWriter
&& $this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum]);
// Colspan and Rowspan
$colspan = 1;
$rowspan = 1;
$colSpan = 1;
$rowSpan = 1;
if (isset($this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum])) {
$spans = $this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum];
$rowSpan = $spans['rowspan'];
@ -1791,7 +1791,8 @@ class Html extends BaseWriter
public function getOrientation(): ?string
{
return null;
// Expect Pdf classes to override this method.
return $this->isPdf ? PageSetup::ORIENTATION_PORTRAIT : null;
}
/**
@ -1830,9 +1831,9 @@ class Html extends BaseWriter
$bottom = StringHelper::FormatNumber($worksheet->getPageMargins()->getBottom()) . 'in; ';
$htmlPage .= 'margin-bottom: ' . $bottom;
$orientation = $this->getOrientation() ?? $worksheet->getPageSetup()->getOrientation();
if ($orientation === \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) {
if ($orientation === PageSetup::ORIENTATION_LANDSCAPE) {
$htmlPage .= 'size: landscape; ';
} elseif ($orientation === \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT) {
} elseif ($orientation === PageSetup::ORIENTATION_PORTRAIT) {
$htmlPage .= 'size: portrait; ';
}
$htmlPage .= '}' . PHP_EOL;

View File

@ -465,7 +465,7 @@ class Worksheet extends BIFFwriter
switch ($calctype) {
case 'integer':
case 'double':
$this->writeNumber($row, $column, $calculatedValue, $xfIndex);
$this->writeNumber($row, $column, (float) $calculatedValue, $xfIndex);
break;
case 'string':
@ -473,7 +473,7 @@ class Worksheet extends BIFFwriter
break;
case 'boolean':
$this->writeBoolErr($row, $column, $calculatedValue, 0, $xfIndex);
$this->writeBoolErr($row, $column, (int) $calculatedValue, 0, $xfIndex);
break;
default:

View File

@ -503,7 +503,7 @@ class Worksheet extends WriterPart
private static function writeTimePeriodCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
{
$txt = $conditional->getText();
if ($txt !== null) {
if (!empty($txt)) {
$objWriter->writeAttribute('timePeriod', $txt);
if (empty($conditional->getConditions())) {
if ($conditional->getOperatorType() == Conditional::TIMEPERIOD_TODAY) {
@ -536,7 +536,7 @@ class Worksheet extends WriterPart
private static function writeTextCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
{
$txt = $conditional->getText();
if ($txt !== null) {
if (!empty($txt)) {
$objWriter->writeAttribute('text', $txt);
if (empty($conditional->getConditions())) {
if ($conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT) {
@ -1034,7 +1034,7 @@ class Worksheet extends WriterPart
} else {
$objWriter->writeAttribute('fitToWidth', '0');
}
if ($worksheet->getPageSetup()->getFirstPageNumber() !== null) {
if (!empty($worksheet->getPageSetup()->getFirstPageNumber())) {
$objWriter->writeAttribute('firstPageNumber', (string) $worksheet->getPageSetup()->getFirstPageNumber());
$objWriter->writeAttribute('useFirstPageNumber', '1');
}
@ -1228,7 +1228,7 @@ class Worksheet extends WriterPart
StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue, Settings::htmlEntityFlags()))
);
$objWriter->endElement();
} elseif ($cellValue instanceof RichText) {
} else {
$objWriter->startElement('is');
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $cellValue);
$objWriter->endElement();

View File

@ -70,6 +70,7 @@ class AutoFilter2Test extends TestCase
self::assertCount(1, $columns);
$column = $columns['A'] ?? null;
self::assertNotNull($column);
/** @scrutinizer ignore-call */
$ruleset = $column->getRules();
self::assertCount(1, $ruleset);
$rule = $ruleset[0];

View File

@ -28,9 +28,6 @@ class RichTextTest extends TestCase
public function testTextElements(): void
{
$element1 = new TextElement('A');
if ($element1->getFont() !== null) {
self::fail('Expected font to be null');
}
$element2 = new TextElement('B');
$element3 = new TextElement('C');
$richText = new RichText();