Skip to content

Commit 9e4ff92

Browse files
authored
Namespacing Part 3 - Charts (#2852)
* Namespacing Part 3 - Charts Charts still need some work, but they are now in good enough shape that the code that reads them can handle namespacing properly. Rather than a set of static routines, Reader/Xlsx/Chart needs to be changed to a regular object, with the relevant namespaces passed in the constructor. I am still looking for a test spreadsheet with non-standard namespacing for a full-blown test, but, in the meantime, the existing tests and samples will suffice. When I find a test case, I will certainly add it. The resulting code is actually simpler than it had been because of the elimination of the need for a NamespacesMeta variable in all the function signatures. Because of that, enough errors disappeared from Phpstan that I decided to just finish that job - its baseline file now dips below 5,000 lines. * Update Change Log Need to document many chart changes.
1 parent 13e1b9a commit 9e4ff92

File tree

5 files changed

+98
-201
lines changed

5 files changed

+98
-201
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org).
99

1010
### Added
1111

12-
- Add point size option for scatter charts
12+
- Add point size option for scatter charts [Issue #2298](https://github.com/PHPOffice/PhpSpreadsheet/issues/2298) [PR #2801](https://github.com/PHPOffice/PhpSpreadsheet/pull/2801)
1313
- Basic support for Xlsx reading/writing Chart Sheets [PR #2830](https://github.com/PHPOffice/PhpSpreadsheet/pull/2830)
1414

1515
Note that a ChartSheet is still only written as a normal Worksheet containing a single chart, not as an actual ChartSheet.
1616

1717
- Added Worksheet visibility in Ods Reader [PR #2851](https://github.com/PHPOffice/PhpSpreadsheet/pull/2851) and Gnumeric Reader [PR #2853](https://github.com/PHPOffice/PhpSpreadsheet/pull/2853)
1818
- Added Worksheet visibility in Ods Writer [PR #2850](https://github.com/PHPOffice/PhpSpreadsheet/pull/2850)
19+
- Allow Csv Reader to treat string as contents of file [Issue #1285](https://github.com/PHPOffice/PhpSpreadsheet/issues/1285) [PR #2792](https://github.com/PHPOffice/PhpSpreadsheet/pull/2792)
20+
- Allow Csv Reader to store null string rather than leave cell empty [Issue #2840](https://github.com/PHPOffice/PhpSpreadsheet/issues/2840) [PR #2842](https://github.com/PHPOffice/PhpSpreadsheet/pull/2842)
1921

2022
### Changed
2123

@@ -36,6 +38,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3638
- Xls Reader resolving absolute named ranges to relative ranges [Issue #2826](https://github.com/PHPOffice/PhpSpreadsheet/issues/2826) [PR #2827](https://github.com/PHPOffice/PhpSpreadsheet/pull/2827)
3739
- Null value handling in the Excel Math/Trig PRODUCT() function [Issue #2833](https://github.com/PHPOffice/PhpSpreadsheet/issues/2833) [PR #2834](https://github.com/PHPOffice/PhpSpreadsheet/pull/2834)
3840
- Invalid Print Area defined in Xlsx corrupts internal storage of print area [Issue #2848](https://github.com/PHPOffice/PhpSpreadsheet/issues/2848) [PR #2849](https://github.com/PHPOffice/PhpSpreadsheet/pull/2849)
41+
- Time interval formatting [Issue #2768](https://github.com/PHPOffice/PhpSpreadsheet/issues/2768) [PR #2772](https://github.com/PHPOffice/PhpSpreadsheet/pull/2772)
42+
- Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](https://github.com/PHPOffice/PhpSpreadsheet/pull/2788)
43+
- Html Reader converting cell containing 0 to null string [Issue #2810](https://github.com/PHPOffice/PhpSpreadsheet/issues/2810) [PR #2813](https://github.com/PHPOffice/PhpSpreadsheet/pull/2813)
44+
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852)
3945

4046
## 1.23.0 - 2022-04-24
4147

phpstan-baseline.neon

-130
Original file line numberDiff line numberDiff line change
@@ -2515,136 +2515,6 @@ parameters:
25152515
count: 1
25162516
path: src/PhpSpreadsheet/Reader/Xlsx/BaseParserClass.php
25172517

2518-
-
2519-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeries\\(\\) has no return type specified\\.$#"
2520-
count: 1
2521-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2522-
2523-
-
2524-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeries\\(\\) has parameter \\$chartDetail with no type specified\\.$#"
2525-
count: 1
2526-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2527-
2528-
-
2529-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeries\\(\\) has parameter \\$namespacesChartMeta with no type specified\\.$#"
2530-
count: 1
2531-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2532-
2533-
-
2534-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeries\\(\\) has parameter \\$plotType with no type specified\\.$#"
2535-
count: 1
2536-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2537-
2538-
-
2539-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValueSet\\(\\) has no return type specified\\.$#"
2540-
count: 1
2541-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2542-
2543-
-
2544-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValueSet\\(\\) has parameter \\$namespacesChartMeta with no type specified\\.$#"
2545-
count: 1
2546-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2547-
2548-
-
2549-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValueSet\\(\\) has parameter \\$seriesDetail with no type specified\\.$#"
2550-
count: 1
2551-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2552-
2553-
-
2554-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValues\\(\\) has no return type specified\\.$#"
2555-
count: 1
2556-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2557-
2558-
-
2559-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValues\\(\\) has parameter \\$dataType with no type specified\\.$#"
2560-
count: 1
2561-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2562-
2563-
-
2564-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValues\\(\\) has parameter \\$seriesValueSet with no type specified\\.$#"
2565-
count: 1
2566-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2567-
2568-
-
2569-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValuesMultiLevel\\(\\) has no return type specified\\.$#"
2570-
count: 1
2571-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2572-
2573-
-
2574-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValuesMultiLevel\\(\\) has parameter \\$dataType with no type specified\\.$#"
2575-
count: 1
2576-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2577-
2578-
-
2579-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartDataSeriesValuesMultiLevel\\(\\) has parameter \\$seriesValueSet with no type specified\\.$#"
2580-
count: 1
2581-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2582-
2583-
-
2584-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartLayoutDetails\\(\\) has no return type specified\\.$#"
2585-
count: 1
2586-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2587-
2588-
-
2589-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartLayoutDetails\\(\\) has parameter \\$chartDetail with no type specified\\.$#"
2590-
count: 1
2591-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2592-
2593-
-
2594-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartLayoutDetails\\(\\) has parameter \\$namespacesChartMeta with no type specified\\.$#"
2595-
count: 1
2596-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2597-
2598-
-
2599-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:chartTitle\\(\\) has no return type specified\\.$#"
2600-
count: 1
2601-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2602-
2603-
-
2604-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:parseRichText\\(\\) has no return type specified\\.$#"
2605-
count: 1
2606-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2607-
2608-
-
2609-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:readChartAttributes\\(\\) has no return type specified\\.$#"
2610-
count: 1
2611-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2612-
2613-
-
2614-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\Chart\\:\\:readChartAttributes\\(\\) has parameter \\$chartDetail with no type specified\\.$#"
2615-
count: 1
2616-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2617-
2618-
-
2619-
message: "#^Parameter \\#1 \\$position of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend constructor expects string, bool\\|float\\|int\\|string\\|null given\\.$#"
2620-
count: 1
2621-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2622-
2623-
-
2624-
message: "#^Parameter \\#3 \\$overlay of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend constructor expects bool, bool\\|float\\|int\\|string\\|null given\\.$#"
2625-
count: 1
2626-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2627-
2628-
-
2629-
message: "#^Parameter \\#3 \\$plotOrder of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeries constructor expects array\\<int\\>, array\\<int\\|string, bool\\|float\\|int\\|string\\|null\\> given\\.$#"
2630-
count: 1
2631-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2632-
2633-
-
2634-
message: "#^Parameter \\#4 \\$pointCount of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues constructor expects int, null given\\.$#"
2635-
count: 4
2636-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2637-
2638-
-
2639-
message: "#^Parameter \\#6 \\$displayBlanksAs of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart constructor expects string, bool\\|float\\|int\\|string\\|null given\\.$#"
2640-
count: 1
2641-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2642-
2643-
-
2644-
message: "#^Parameter \\#7 \\$plotDirection of class PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeries constructor expects string\\|null, bool\\|float\\|int\\|string\\|null given\\.$#"
2645-
count: 1
2646-
path: src/PhpSpreadsheet/Reader/Xlsx/Chart.php
2647-
26482518
-
26492519
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\\\ColumnAndRowAttributes\\:\\:isFilteredColumn\\(\\) has no return type specified\\.$#"
26502520
count: 1

src/PhpSpreadsheet/Reader/Xlsx.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
16451645
if ($this->includeCharts) {
16461646
$chartEntryRef = ltrim((string) $contentType['PartName'], '/');
16471647
$chartElements = $this->loadZip($chartEntryRef);
1648-
$objChart = Chart::readChart($chartElements, basename($chartEntryRef, '.xml'));
1648+
$chartReader = new Chart();
1649+
$objChart = $chartReader->readChart($chartElements, basename($chartEntryRef, '.xml'));
16491650
if (isset($charts[$chartEntryRef])) {
16501651
$chartPositionRef = $charts[$chartEntryRef]['sheet'] . '!' . $charts[$chartEntryRef]['id'];
16511652
if (isset($chartDetails[$chartPositionRef])) {

0 commit comments

Comments
 (0)