Skip to content

Commit b7fa470

Browse files
authored
Scrutinizer Changes (#3060)
* Scrutinizer Changes Scrutinizer appears to be working again. But the PRs that have used it have neither added new issues nor fixed existing ones. This PR should fix some exisiting; let's see what Scrutinizer does with it. * Address Some False Positives In Reader/Xlsx/Chart.
1 parent 90422bf commit b7fa470

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/PhpSpreadsheet/Reader/Xlsx/Chart.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PhpOffice\PhpSpreadsheet\Chart\Properties as ChartProperties;
1515
use PhpOffice\PhpSpreadsheet\Chart\Title;
1616
use PhpOffice\PhpSpreadsheet\Chart\TrendLine;
17+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
1718
use PhpOffice\PhpSpreadsheet\RichText\RichText;
1819
use PhpOffice\PhpSpreadsheet\Style\Font;
1920
use SimpleXMLElement;
@@ -94,7 +95,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
9495
break;
9596
case 'chart':
9697
foreach ($chartElement as $chartDetailsKey => $chartDetails) {
97-
$chartDetailsC = $chartDetails->children($this->cNamespace);
98+
$chartDetails = Xlsx::testSimpleXml($chartDetails);
9899
switch ($chartDetailsKey) {
99100
case 'autoTitleDeleted':
100101
/** @var bool */
@@ -113,17 +114,17 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
113114
$plotSeries = $plotAttributes = [];
114115
$catAxRead = false;
115116
$plotNoFill = false;
116-
/** @var SimpleXMLElement $chartDetail */
117117
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
118+
$chartDetail = Xlsx::testSimpleXml($chartDetail);
118119
switch ($chartDetailKey) {
119120
case 'spPr':
120121
$possibleNoFill = $chartDetails->spPr->children($this->aNamespace);
121122
if (isset($possibleNoFill->noFill)) {
122123
$plotNoFill = true;
123124
}
124125
if (isset($possibleNoFill->gradFill->gsLst)) {
125-
/** @var SimpleXMLElement $gradient */
126126
foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) {
127+
$gradient = Xlsx::testSimpleXml($gradient);
127128
/** @var float */
128129
$pos = self::getAttribute($gradient, 'pos', 'float');
129130
$gradientArray[] = [
@@ -348,6 +349,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName)
348349
$legendLayout = null;
349350
$legendOverlay = false;
350351
foreach ($chartDetails as $chartDetailKey => $chartDetail) {
352+
$chartDetail = Xlsx::testSimpleXml($chartDetail);
351353
switch ($chartDetailKey) {
352354
case 'legendPos':
353355
$legendPos = self::getAttribute($chartDetail, 'val', 'string');
@@ -399,11 +401,13 @@ private function chartTitle(SimpleXMLElement $titleDetails): Title
399401
$caption = [];
400402
$titleLayout = null;
401403
foreach ($titleDetails as $titleDetailKey => $chartDetail) {
404+
$chartDetail = Xlsx::testSimpleXml($chartDetail);
402405
switch ($titleDetailKey) {
403406
case 'tx':
404407
if (isset($chartDetail->rich)) {
405408
$titleDetails = $chartDetail->rich->children($this->aNamespace);
406409
foreach ($titleDetails as $titleKey => $titleDetail) {
410+
$titleDetail = Xlsx::testSimpleXml($titleDetail);
407411
switch ($titleKey) {
408412
case 'p':
409413
$titleDetailPart = $titleDetail->children($this->aNamespace);
@@ -440,6 +444,7 @@ private function chartLayoutDetails(SimpleXMLElement $chartDetail): ?Layout
440444
}
441445
$layout = [];
442446
foreach ($details as $detailKey => $detail) {
447+
$detail = Xlsx::testSimpleXml($detail);
443448
$layout[$detailKey] = self::getAttribute($detail, 'val', 'string');
444449
}
445450

@@ -472,8 +477,8 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType
472477
$lineStyle = null;
473478
$labelLayout = null;
474479
$trendLines = [];
475-
/** @var SimpleXMLElement $seriesDetail */
476480
foreach ($seriesDetails as $seriesKey => $seriesDetail) {
481+
$seriesDetail = Xlsx::testSimpleXml($seriesDetail);
477482
switch ($seriesKey) {
478483
case 'idx':
479484
$seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer');
@@ -786,6 +791,7 @@ private function chartDataSeriesValues(SimpleXMLElement $seriesValueSet, string
786791
$pointCount = 0;
787792

788793
foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
794+
$seriesValue = Xlsx::testSimpleXml($seriesValue);
789795
switch ($seriesValueIdx) {
790796
case 'ptCount':
791797
$pointCount = self::getAttribute($seriesValue, 'val', 'integer');
@@ -858,7 +864,6 @@ private function chartDataSeriesValuesMultiLevel(SimpleXMLElement $seriesValueSe
858864
private function parseRichText(SimpleXMLElement $titleDetailPart): RichText
859865
{
860866
$value = new RichText();
861-
$objText = null;
862867
$defaultFontSize = null;
863868
$defaultBold = null;
864869
$defaultItalic = null;

src/PhpSpreadsheet/Writer/Html.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,9 +1461,6 @@ private function generateRow(Worksheet $worksheet, array $values, $row, $cellTyp
14611461
foreach ($values as $cellAddress) {
14621462
[$cell, $cssClass, $coordinate] = $this->generateRowCellCss($worksheet, $cellAddress, $row, $colNum);
14631463

1464-
$colSpan = 1;
1465-
$rowSpan = 1;
1466-
14671464
// Cell Data
14681465
$cellData = $this->generateRowCellData($worksheet, $cell, $cssClass, $cellType);
14691466

tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilter2Test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function testReadDynamic(): void
9393
self::assertCount(1, $columns);
9494
$column = $columns['A'] ?? null;
9595
self::assertNotNull($column);
96+
/** @scrutinizer ignore-call */
9697
$ruleset = $column->getRules();
9798
self::assertCount(1, $ruleset);
9899
$rule = $ruleset[0];

0 commit comments

Comments
 (0)