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:
parent
7e3807309d
commit
b5f70de61d
|
|
@ -2590,21 +2590,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: src/PhpSpreadsheet/Worksheet/PageSetup.php
|
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\\.$#"
|
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\SheetView\\:\\:\\$sheetViewTypes has no type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,10 @@ $dataSeriesValues = [
|
||||||
// marker details
|
// marker details
|
||||||
$dataSeriesValues[0]
|
$dataSeriesValues[0]
|
||||||
->getMarkerFillColor()
|
->getMarkerFillColor()
|
||||||
->setColorProperties('0070C0', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
|
->setColorProperties('0070C0', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
|
||||||
$dataSeriesValues[0]
|
$dataSeriesValues[0]
|
||||||
->getMarkerBorderColor()
|
->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
|
// line details - dashed, smooth line (Bezier) with arrows, 40% transparent
|
||||||
$dataSeriesValues[0]
|
$dataSeriesValues[0]
|
||||||
|
|
@ -129,18 +129,18 @@ $dataSeriesValues[1] // square marker border color
|
||||||
->setColorProperties('accent6', 3, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
|
->setColorProperties('accent6', 3, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
|
||||||
$dataSeriesValues[1] // square marker fill color
|
$dataSeriesValues[1] // square marker fill color
|
||||||
->getMarkerFillColor()
|
->getMarkerFillColor()
|
||||||
->setColorProperties('0FFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
|
->setColorProperties('0FFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
|
||||||
$dataSeriesValues[1]
|
$dataSeriesValues[1]
|
||||||
->setScatterLines(true)
|
->setScatterLines(true)
|
||||||
->setSmoothLine(false)
|
->setSmoothLine(false)
|
||||||
->setLineColorProperties('FF0000', 80, ChartColor::EXCEL_COLOR_TYPE_ARGB);
|
->setLineColorProperties('FF0000', 80, ChartColor::EXCEL_COLOR_TYPE_RGB);
|
||||||
$dataSeriesValues[1]->setLineWidth(2.0);
|
$dataSeriesValues[1]->setLineWidth(2.0);
|
||||||
|
|
||||||
// series 3 - metric3, markers, no line
|
// series 3 - metric3, markers, no line
|
||||||
$dataSeriesValues[2] // triangle? fill
|
$dataSeriesValues[2] // triangle? fill
|
||||||
//->setPointMarker('triangle') // let Excel choose shape, which is predicted to be a triangle
|
//->setPointMarker('triangle') // let Excel choose shape, which is predicted to be a triangle
|
||||||
->getMarkerFillColor()
|
->getMarkerFillColor()
|
||||||
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
|
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
|
||||||
$dataSeriesValues[2] // triangle border
|
$dataSeriesValues[2] // triangle border
|
||||||
->getMarkerBorderColor()
|
->getMarkerBorderColor()
|
||||||
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
|
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
|
||||||
|
|
@ -239,7 +239,7 @@ $dataSeriesValues[0]
|
||||||
->setScatterlines(false); // disable connecting lines
|
->setScatterlines(false); // disable connecting lines
|
||||||
$dataSeriesValues[0]
|
$dataSeriesValues[0]
|
||||||
->getMarkerFillColor()
|
->getMarkerFillColor()
|
||||||
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_ARGB);
|
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
|
||||||
$dataSeriesValues[0]
|
$dataSeriesValues[0]
|
||||||
->getMarkerBorderColor()
|
->getMarkerBorderColor()
|
||||||
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
|
->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
|
// Set the position of the chart in the chart sheet below the first chart
|
||||||
$chart->setTopLeftPosition('A13');
|
$chart->setTopLeftPosition('A13');
|
||||||
$chart->setBottomRightPosition('P25');
|
$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
|
// Add the chart to the worksheet $chartSheet
|
||||||
$chartSheet->addChart($chart);
|
$chartSheet->addChart($chart);
|
||||||
|
|
@ -350,8 +350,8 @@ function dateRange(int $nrows, Spreadsheet $wrkbk): array
|
||||||
$startDate = DateTime::createFromFormat('Y-m-d', $startDateStr); // php date obj
|
$startDate = DateTime::createFromFormat('Y-m-d', $startDateStr); // php date obj
|
||||||
|
|
||||||
// get date of first day of the quarter of the start date
|
// get date of first day of the quarter of the start date
|
||||||
$startMonth = $startDate->format('n'); // suppress leading zero
|
$startMonth = (int) $startDate->format('n'); // suppress leading zero
|
||||||
$startYr = $startDate->format('Y');
|
$startYr = (int) $startDate->format('Y');
|
||||||
$qtr = intdiv($startMonth, 3) + (($startMonth % 3 > 0) ? 1 : 0);
|
$qtr = intdiv($startMonth, 3) + (($startMonth % 3 > 0) ? 1 : 0);
|
||||||
$qtrStartMonth = sprintf('%02d', 1 + (($qtr - 1) * 3));
|
$qtrStartMonth = sprintf('%02d', 1 + (($qtr - 1) * 3));
|
||||||
$qtrStartStr = "$startYr-$qtrStartMonth-01";
|
$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
|
// end the xaxis at the end of the quarter of the last date
|
||||||
$lastDateStr = $dataSheet->getCellByColumnAndRow(2, $nrows + 1)->getValue();
|
$lastDateStr = $dataSheet->getCellByColumnAndRow(2, $nrows + 1)->getValue();
|
||||||
$lastDate = DateTime::createFromFormat('Y-m-d', $lastDateStr);
|
$lastDate = DateTime::createFromFormat('Y-m-d', $lastDateStr);
|
||||||
$lastMonth = $lastDate->format('n');
|
$lastMonth = (int) $lastDate->format('n');
|
||||||
$lastYr = $lastDate->format('Y');
|
$lastYr = (int) $lastDate->format('Y');
|
||||||
$qtr = intdiv($lastMonth, 3) + (($lastMonth % 3 > 0) ? 1 : 0);
|
$qtr = intdiv($lastMonth, 3) + (($lastMonth % 3 > 0) ? 1 : 0);
|
||||||
$qtrEndMonth = 3 + (($qtr - 1) * 3);
|
$qtrEndMonth = 3 + (($qtr - 1) * 3);
|
||||||
$lastDOM = cal_days_in_month(CAL_GREGORIAN, $qtrEndMonth, $lastYr);
|
$lastDOM = cal_days_in_month(CAL_GREGORIAN, $qtrEndMonth, $lastYr);
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ class Axis extends Properties
|
||||||
* @param ?int $alpha
|
* @param ?int $alpha
|
||||||
* @param ?string $AlphaType
|
* @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);
|
$this->fillColor->setColorProperties($color, $alpha, $AlphaType);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -774,9 +774,11 @@ class Chart
|
||||||
return $this->roundedCorners;
|
return $this->roundedCorners;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRoundedCorners(bool $roundedCorners): self
|
public function setRoundedCorners(?bool $roundedCorners): self
|
||||||
{
|
{
|
||||||
|
if ($roundedCorners !== null) {
|
||||||
$this->roundedCorners = $roundedCorners;
|
$this->roundedCorners = $roundedCorners;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,22 +306,25 @@ class Xlsx extends BaseReader
|
||||||
return (bool) $c->v;
|
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 $value
|
||||||
* @param mixed $calculatedValue
|
* @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();
|
$attr = $c->f->attributes();
|
||||||
$cellDataType = 'f';
|
$cellDataType = 'f';
|
||||||
$value = "={$c->f}";
|
$value = "={$c->f}";
|
||||||
|
|
|
||||||
|
|
@ -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);
|
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
|
||||||
$customFilters = $filterColumn->customFilters;
|
$customFilters = $filterColumn->customFilters;
|
||||||
// Custom filters can an AND or an OR join;
|
// 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);
|
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
|
||||||
// We should only ever have one dynamic filter
|
// We should only ever have one dynamic filter
|
||||||
foreach ($filterColumn->dynamicFilter as $filterRule) {
|
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);
|
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
|
||||||
// We should only ever have one top10 filter
|
// We should only ever have one top10 filter
|
||||||
foreach ($filterColumn->top10 as $filterRule) {
|
foreach ($filterColumn->top10 as $filterRule) {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use PhpOffice\PhpSpreadsheet\Chart\GridLines;
|
||||||
use PhpOffice\PhpSpreadsheet\Chart\Layout;
|
use PhpOffice\PhpSpreadsheet\Chart\Layout;
|
||||||
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
use PhpOffice\PhpSpreadsheet\Chart\Legend;
|
||||||
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
|
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\Title;
|
||||||
use PhpOffice\PhpSpreadsheet\Chart\TrendLine;
|
use PhpOffice\PhpSpreadsheet\Chart\TrendLine;
|
||||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||||
|
|
@ -113,6 +113,7 @@ class Chart
|
||||||
$plotSeries = $plotAttributes = [];
|
$plotSeries = $plotAttributes = [];
|
||||||
$catAxRead = false;
|
$catAxRead = false;
|
||||||
$plotNoFill = false;
|
$plotNoFill = false;
|
||||||
|
/** @var SimpleXMLElement $chartDetail */
|
||||||
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
|
||||||
switch ($chartDetailKey) {
|
switch ($chartDetailKey) {
|
||||||
case 'spPr':
|
case 'spPr':
|
||||||
|
|
@ -121,17 +122,18 @@ class Chart
|
||||||
$plotNoFill = true;
|
$plotNoFill = true;
|
||||||
}
|
}
|
||||||
if (isset($possibleNoFill->gradFill->gsLst)) {
|
if (isset($possibleNoFill->gradFill->gsLst)) {
|
||||||
|
/** @var SimpleXMLElement $gradient */
|
||||||
foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) {
|
foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) {
|
||||||
/** @var float */
|
/** @var float */
|
||||||
$pos = self::getAttribute($gradient, 'pos', 'float');
|
$pos = self::getAttribute($gradient, 'pos', 'float');
|
||||||
$gradientArray[] = [
|
$gradientArray[] = [
|
||||||
$pos / Properties::PERCENTAGE_MULTIPLIER,
|
$pos / ChartProperties::PERCENTAGE_MULTIPLIER,
|
||||||
new ChartColor($this->readColor($gradient)),
|
new ChartColor($this->readColor($gradient)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($possibleNoFill->gradFill->lin)) {
|
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;
|
break;
|
||||||
|
|
@ -464,12 +466,13 @@ class Chart
|
||||||
$pointSize = null;
|
$pointSize = null;
|
||||||
$noFill = false;
|
$noFill = false;
|
||||||
$bubble3D = false;
|
$bubble3D = false;
|
||||||
$dPtColors = [];
|
$dptColors = [];
|
||||||
$markerFillColor = null;
|
$markerFillColor = null;
|
||||||
$markerBorderColor = null;
|
$markerBorderColor = null;
|
||||||
$lineStyle = null;
|
$lineStyle = null;
|
||||||
$labelLayout = null;
|
$labelLayout = null;
|
||||||
$trendLines = [];
|
$trendLines = [];
|
||||||
|
/** @var SimpleXMLElement $seriesDetail */
|
||||||
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
|
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
|
||||||
switch ($seriesKey) {
|
switch ($seriesKey) {
|
||||||
case 'idx':
|
case 'idx':
|
||||||
|
|
@ -487,7 +490,6 @@ class Chart
|
||||||
break;
|
break;
|
||||||
case 'spPr':
|
case 'spPr':
|
||||||
$children = $seriesDetail->children($this->aNamespace);
|
$children = $seriesDetail->children($this->aNamespace);
|
||||||
$ln = $children->ln;
|
|
||||||
if (isset($children->ln)) {
|
if (isset($children->ln)) {
|
||||||
$ln = $children->ln;
|
$ln = $children->ln;
|
||||||
if (is_countable($ln->noFill) && count($ln->noFill) === 1) {
|
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)) {
|
if (!isset($chartObject, $chartDetail->spPr)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1169,7 +1171,7 @@ class Chart
|
||||||
$sppr = $chartDetail->spPr->children($this->aNamespace);
|
$sppr = $chartDetail->spPr->children($this->aNamespace);
|
||||||
|
|
||||||
if (isset($sppr->effectLst->glow)) {
|
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) {
|
if ($axisGlowSize != 0.0) {
|
||||||
$colorArray = $this->readColor($sppr->effectLst->glow);
|
$colorArray = $this->readColor($sppr->effectLst->glow);
|
||||||
$chartObject->setGlowProperties($axisGlowSize, $colorArray['value'], $colorArray['alpha'], $colorArray['type']);
|
$chartObject->setGlowProperties($axisGlowSize, $colorArray['value'], $colorArray['alpha'], $colorArray['type']);
|
||||||
|
|
@ -1180,7 +1182,7 @@ class Chart
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$softEdgeSize = self::getAttribute($sppr->effectLst->softEdge, 'rad', 'string');
|
$softEdgeSize = self::getAttribute($sppr->effectLst->softEdge, 'rad', 'string');
|
||||||
if (is_numeric($softEdgeSize)) {
|
if (is_numeric($softEdgeSize)) {
|
||||||
$chartObject->setSoftEdges((float) Properties::xmlToPoints($softEdgeSize));
|
$chartObject->setSoftEdges((float) ChartProperties::xmlToPoints($softEdgeSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1195,20 +1197,20 @@ class Chart
|
||||||
if ($type !== '') {
|
if ($type !== '') {
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$blur = self::getAttribute($sppr->effectLst->$type, 'blurRad', '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 */
|
/** @var string */
|
||||||
$dist = self::getAttribute($sppr->effectLst->$type, 'dist', '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 */
|
/** @var string */
|
||||||
$direction = self::getAttribute($sppr->effectLst->$type, 'dir', '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');
|
$algn = self::getAttribute($sppr->effectLst->$type, 'algn', 'string');
|
||||||
$rot = self::getAttribute($sppr->effectLst->$type, 'rotWithShape', 'string');
|
$rot = self::getAttribute($sppr->effectLst->$type, 'rotWithShape', 'string');
|
||||||
$size = [];
|
$size = [];
|
||||||
foreach (['sx', 'sy'] as $sizeType) {
|
foreach (['sx', 'sy'] as $sizeType) {
|
||||||
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
|
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
|
||||||
if (is_numeric($sizeValue)) {
|
if (is_numeric($sizeValue)) {
|
||||||
$size[$sizeType] = Properties::xmlToTenthOfPercent((string) $sizeValue);
|
$size[$sizeType] = ChartProperties::xmlToTenthOfPercent((string) $sizeValue);
|
||||||
} else {
|
} else {
|
||||||
$size[$sizeType] = null;
|
$size[$sizeType] = null;
|
||||||
}
|
}
|
||||||
|
|
@ -1216,7 +1218,7 @@ class Chart
|
||||||
foreach (['kx', 'ky'] as $sizeType) {
|
foreach (['kx', 'ky'] as $sizeType) {
|
||||||
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
|
$sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string');
|
||||||
if (is_numeric($sizeValue)) {
|
if (is_numeric($sizeValue)) {
|
||||||
$size[$sizeType] = Properties::xmlToAngle((string) $sizeValue);
|
$size[$sizeType] = ChartProperties::xmlToAngle((string) $sizeValue);
|
||||||
} else {
|
} else {
|
||||||
$size[$sizeType] = null;
|
$size[$sizeType] = null;
|
||||||
}
|
}
|
||||||
|
|
@ -1273,7 +1275,7 @@ class Chart
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function readLineStyle(SimpleXMLElement $chartDetail, ?Properties $chartObject): void
|
private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $chartObject): void
|
||||||
{
|
{
|
||||||
if (!isset($chartObject, $chartDetail->spPr)) {
|
if (!isset($chartObject, $chartDetail->spPr)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1287,7 +1289,7 @@ class Chart
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$lineWidthTemp = self::getAttribute($sppr->ln, 'w', 'string');
|
$lineWidthTemp = self::getAttribute($sppr->ln, 'w', 'string');
|
||||||
if (is_numeric($lineWidthTemp)) {
|
if (is_numeric($lineWidthTemp)) {
|
||||||
$lineWidth = Properties::xmlToPoints($lineWidthTemp);
|
$lineWidth = ChartProperties::xmlToPoints($lineWidthTemp);
|
||||||
}
|
}
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$compoundType = self::getAttribute($sppr->ln, 'cmpd', 'string');
|
$compoundType = self::getAttribute($sppr->ln, 'cmpd', 'string');
|
||||||
|
|
@ -1296,15 +1298,13 @@ class Chart
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$capType = self::getAttribute($sppr->ln, 'cap', 'string');
|
$capType = self::getAttribute($sppr->ln, 'cap', 'string');
|
||||||
if (isset($sppr->ln->miter)) {
|
if (isset($sppr->ln->miter)) {
|
||||||
$joinType = Properties::LINE_STYLE_JOIN_MITER;
|
$joinType = ChartProperties::LINE_STYLE_JOIN_MITER;
|
||||||
} elseif (isset($sppr->ln->bevel)) {
|
} elseif (isset($sppr->ln->bevel)) {
|
||||||
$joinType = Properties::LINE_STYLE_JOIN_BEVEL;
|
$joinType = ChartProperties::LINE_STYLE_JOIN_BEVEL;
|
||||||
} else {
|
} else {
|
||||||
$joinType = '';
|
$joinType = '';
|
||||||
}
|
}
|
||||||
$headArrowType = '';
|
|
||||||
$headArrowSize = '';
|
$headArrowSize = '';
|
||||||
$endArrowType = '';
|
|
||||||
$endArrowSize = '';
|
$endArrowSize = '';
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$headArrowType = self::getAttribute($sppr->ln->headEnd, 'type', 'string');
|
$headArrowType = self::getAttribute($sppr->ln->headEnd, 'type', 'string');
|
||||||
|
|
@ -1403,7 +1403,7 @@ class Chart
|
||||||
/** @var string */
|
/** @var string */
|
||||||
$textRotation = self::getAttribute($children->bodyPr, 'rot', 'string');
|
$textRotation = self::getAttribute($children->bodyPr, 'rot', 'string');
|
||||||
if (is_numeric($textRotation)) {
|
if (is_numeric($textRotation)) {
|
||||||
$whichAxis->setAxisOption('textRotation', (string) Properties::xmlToAngle($textRotation));
|
$whichAxis->setAxisOption('textRotation', (string) ChartProperties::xmlToAngle($textRotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -259,10 +259,11 @@ class PageSetup
|
||||||
/**
|
/**
|
||||||
* First page number.
|
* First page number.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var ?int
|
||||||
*/
|
*/
|
||||||
private $firstPageNumber;
|
private $firstPageNumber;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
private $pageOrder = self::PAGEORDER_DOWN_THEN_OVER;
|
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,
|
// 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
|
// 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;
|
$this->scale = $scale;
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$this->fitToPage = false;
|
$this->fitToPage = false;
|
||||||
|
|
@ -845,7 +846,7 @@ class PageSetup
|
||||||
/**
|
/**
|
||||||
* Get first page number.
|
* Get first page number.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return ?int
|
||||||
*/
|
*/
|
||||||
public function getFirstPageNumber()
|
public function getFirstPageNumber()
|
||||||
{
|
{
|
||||||
|
|
@ -855,7 +856,7 @@ class PageSetup
|
||||||
/**
|
/**
|
||||||
* Set first page number.
|
* Set first page number.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param ?int $value
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1359,7 +1359,7 @@ class Worksheet implements IComparable
|
||||||
|
|
||||||
if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
|
if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
|
||||||
// then there is a row dimension with explicit style, assign it to the cell
|
// 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) {
|
} elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
|
||||||
// then there is a column dimension, assign it to the cell
|
// then there is a column dimension, assign it to the cell
|
||||||
$cell->setXfIndex($columnDimension->getXfIndex());
|
$cell->setXfIndex($columnDimension->getXfIndex());
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
|
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
|
||||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
class Html extends BaseWriter
|
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) {
|
if ($cell->getValue() instanceof RichText) {
|
||||||
$this->generateRowCellDataValueRich($cell, $cellData);
|
$this->generateRowCellDataValueRich($cell, $cellData);
|
||||||
} else {
|
} else {
|
||||||
$origData = $this->preCalculateFormulas ? $cell->getCalculatedValue() : $cell->getValue();
|
$origData = $this->preCalculateFormulas ? $cell->getCalculatedValue() : $cell->getValue();
|
||||||
$formatCode = $worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode();
|
$formatCode = $worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode();
|
||||||
if ($formatCode !== null) {
|
|
||||||
$cellData = NumberFormat::toFormattedString(
|
$cellData = NumberFormat::toFormattedString(
|
||||||
$origData,
|
$origData ?? '',
|
||||||
$formatCode,
|
$formatCode ?? NumberFormat::FORMAT_GENERAL,
|
||||||
[$this, 'formatColor']
|
[$this, 'formatColor']
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if ($cellData === $origData) {
|
if ($cellData === $origData) {
|
||||||
$cellData = htmlspecialchars($cellData ?? '', Settings::htmlEntityFlags());
|
$cellData = htmlspecialchars($cellData, Settings::htmlEntityFlags());
|
||||||
}
|
}
|
||||||
if ($worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperscript()) {
|
if ($worksheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperscript()) {
|
||||||
$cellData = '<sup>' . $cellData . '</sup>';
|
$cellData = '<sup>' . $cellData . '</sup>';
|
||||||
|
|
@ -1477,8 +1477,8 @@ class Html extends BaseWriter
|
||||||
&& $this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum]);
|
&& $this->isSpannedCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum]);
|
||||||
|
|
||||||
// Colspan and Rowspan
|
// Colspan and Rowspan
|
||||||
$colspan = 1;
|
$colSpan = 1;
|
||||||
$rowspan = 1;
|
$rowSpan = 1;
|
||||||
if (isset($this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum])) {
|
if (isset($this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum])) {
|
||||||
$spans = $this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum];
|
$spans = $this->isBaseCell[$worksheet->getParent()->getIndex($worksheet)][$row + 1][$colNum];
|
||||||
$rowSpan = $spans['rowspan'];
|
$rowSpan = $spans['rowspan'];
|
||||||
|
|
@ -1791,7 +1791,8 @@ class Html extends BaseWriter
|
||||||
|
|
||||||
public function getOrientation(): ?string
|
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; ';
|
$bottom = StringHelper::FormatNumber($worksheet->getPageMargins()->getBottom()) . 'in; ';
|
||||||
$htmlPage .= 'margin-bottom: ' . $bottom;
|
$htmlPage .= 'margin-bottom: ' . $bottom;
|
||||||
$orientation = $this->getOrientation() ?? $worksheet->getPageSetup()->getOrientation();
|
$orientation = $this->getOrientation() ?? $worksheet->getPageSetup()->getOrientation();
|
||||||
if ($orientation === \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) {
|
if ($orientation === PageSetup::ORIENTATION_LANDSCAPE) {
|
||||||
$htmlPage .= 'size: landscape; ';
|
$htmlPage .= 'size: landscape; ';
|
||||||
} elseif ($orientation === \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT) {
|
} elseif ($orientation === PageSetup::ORIENTATION_PORTRAIT) {
|
||||||
$htmlPage .= 'size: portrait; ';
|
$htmlPage .= 'size: portrait; ';
|
||||||
}
|
}
|
||||||
$htmlPage .= '}' . PHP_EOL;
|
$htmlPage .= '}' . PHP_EOL;
|
||||||
|
|
|
||||||
|
|
@ -465,7 +465,7 @@ class Worksheet extends BIFFwriter
|
||||||
switch ($calctype) {
|
switch ($calctype) {
|
||||||
case 'integer':
|
case 'integer':
|
||||||
case 'double':
|
case 'double':
|
||||||
$this->writeNumber($row, $column, $calculatedValue, $xfIndex);
|
$this->writeNumber($row, $column, (float) $calculatedValue, $xfIndex);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
|
|
@ -473,7 +473,7 @@ class Worksheet extends BIFFwriter
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
$this->writeBoolErr($row, $column, $calculatedValue, 0, $xfIndex);
|
$this->writeBoolErr($row, $column, (int) $calculatedValue, 0, $xfIndex);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,7 @@ class Worksheet extends WriterPart
|
||||||
private static function writeTimePeriodCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
|
private static function writeTimePeriodCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
|
||||||
{
|
{
|
||||||
$txt = $conditional->getText();
|
$txt = $conditional->getText();
|
||||||
if ($txt !== null) {
|
if (!empty($txt)) {
|
||||||
$objWriter->writeAttribute('timePeriod', $txt);
|
$objWriter->writeAttribute('timePeriod', $txt);
|
||||||
if (empty($conditional->getConditions())) {
|
if (empty($conditional->getConditions())) {
|
||||||
if ($conditional->getOperatorType() == Conditional::TIMEPERIOD_TODAY) {
|
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
|
private static function writeTextCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
|
||||||
{
|
{
|
||||||
$txt = $conditional->getText();
|
$txt = $conditional->getText();
|
||||||
if ($txt !== null) {
|
if (!empty($txt)) {
|
||||||
$objWriter->writeAttribute('text', $txt);
|
$objWriter->writeAttribute('text', $txt);
|
||||||
if (empty($conditional->getConditions())) {
|
if (empty($conditional->getConditions())) {
|
||||||
if ($conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT) {
|
if ($conditional->getOperatorType() == Conditional::OPERATOR_CONTAINSTEXT) {
|
||||||
|
|
@ -1034,7 +1034,7 @@ class Worksheet extends WriterPart
|
||||||
} else {
|
} else {
|
||||||
$objWriter->writeAttribute('fitToWidth', '0');
|
$objWriter->writeAttribute('fitToWidth', '0');
|
||||||
}
|
}
|
||||||
if ($worksheet->getPageSetup()->getFirstPageNumber() !== null) {
|
if (!empty($worksheet->getPageSetup()->getFirstPageNumber())) {
|
||||||
$objWriter->writeAttribute('firstPageNumber', (string) $worksheet->getPageSetup()->getFirstPageNumber());
|
$objWriter->writeAttribute('firstPageNumber', (string) $worksheet->getPageSetup()->getFirstPageNumber());
|
||||||
$objWriter->writeAttribute('useFirstPageNumber', '1');
|
$objWriter->writeAttribute('useFirstPageNumber', '1');
|
||||||
}
|
}
|
||||||
|
|
@ -1228,7 +1228,7 @@ class Worksheet extends WriterPart
|
||||||
StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue, Settings::htmlEntityFlags()))
|
StringHelper::controlCharacterPHP2OOXML(htmlspecialchars($cellValue, Settings::htmlEntityFlags()))
|
||||||
);
|
);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} elseif ($cellValue instanceof RichText) {
|
} else {
|
||||||
$objWriter->startElement('is');
|
$objWriter->startElement('is');
|
||||||
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $cellValue);
|
$this->getParentWriter()->getWriterPartstringtable()->writeRichText($objWriter, $cellValue);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ class AutoFilter2Test extends TestCase
|
||||||
self::assertCount(1, $columns);
|
self::assertCount(1, $columns);
|
||||||
$column = $columns['A'] ?? null;
|
$column = $columns['A'] ?? null;
|
||||||
self::assertNotNull($column);
|
self::assertNotNull($column);
|
||||||
|
/** @scrutinizer ignore-call */
|
||||||
$ruleset = $column->getRules();
|
$ruleset = $column->getRules();
|
||||||
self::assertCount(1, $ruleset);
|
self::assertCount(1, $ruleset);
|
||||||
$rule = $ruleset[0];
|
$rule = $ruleset[0];
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,6 @@ class RichTextTest extends TestCase
|
||||||
public function testTextElements(): void
|
public function testTextElements(): void
|
||||||
{
|
{
|
||||||
$element1 = new TextElement('A');
|
$element1 = new TextElement('A');
|
||||||
if ($element1->getFont() !== null) {
|
|
||||||
self::fail('Expected font to be null');
|
|
||||||
}
|
|
||||||
$element2 = new TextElement('B');
|
$element2 = new TextElement('B');
|
||||||
$element3 = new TextElement('C');
|
$element3 = new TextElement('C');
|
||||||
$richText = new RichText();
|
$richText = new RichText();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue