diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8a7856b541..9dee7fae19 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7205,16 +7205,6 @@ parameters: count: 1 path: tests/PhpSpreadsheetTests/Reader/Xlsx/AutoFilterTest.php - - - message: "#^Function PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\getTitleText\\(\\) has no return typehint specified\\.$#" - count: 1 - path: tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php - - - - message: "#^Function PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\getTitleText\\(\\) has parameter \\$title with no typehint specified\\.$#" - count: 1 - path: tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php - - message: "#^Cannot call method setMinimumConditionalFormatValueObject\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\ConditionalFormatting\\\\ConditionalDataBar\\|null\\.$#" count: 1 @@ -7245,11 +7235,6 @@ parameters: count: 1 path: tests/PhpSpreadsheetTests/Reader/Xlsx/ConditionalFormattingDataBarXlsxTest.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\XlsxTest\\:\\:testStripsWhiteSpaceFromStyleString\\(\\) has parameter \\$string with no typehint specified\\.$#" - count: 1 - path: tests/PhpSpreadsheetTests/Reader/XlsxTest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheetTests\\\\Reader\\\\Xml\\\\XmlTest\\:\\:testInvalidSimpleXML\\(\\) has parameter \\$filename with no typehint specified\\.$#" count: 1 diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php index 5e1711390d..f9fa54ab43 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartsTitleTest.php @@ -1,23 +1,24 @@ getCaption()) { - return null; - } + private static function getTitleText(?Title $title): ?string + { + if (null === $title || empty($title->getCaption())) { + return null; + } - return implode("\n", array_map(function ($rt) { - return $rt->getPlainText(); - }, $title->getCaption())); -} + return implode("\n", array_map(function ($rt) { + return $rt->getPlainText(); + }, $title->getCaption())); // @phpstan-ignore-line + } -class ChartsTitleTest extends TestCase -{ public function testChartTitles(): void { $filename = 'tests/data/Reader/XLSX/excelChartsTest.xlsx'; @@ -31,34 +32,34 @@ public function testChartTitles(): void // No title or axis labels $chart1 = $charts[0]; - $title = getTitleText($chart1->getTitle()); + $title = self::getTitleText($chart1->getTitle()); self::assertEmpty($title); - self::assertEmpty(getTitleText($chart1->getXAxisLabel())); - self::assertEmpty(getTitleText($chart1->getYAxisLabel())); + self::assertEmpty(self::getTitleText($chart1->getXAxisLabel())); + self::assertEmpty(self::getTitleText($chart1->getYAxisLabel())); // Title, no axis labels $chart2 = $charts[1]; - self::assertEquals('Chart with Title and no Axis Labels', getTitleText($chart2->getTitle())); - self::assertEmpty(getTitleText($chart2->getXAxisLabel())); - self::assertEmpty(getTitleText($chart2->getYAxisLabel())); + self::assertEquals('Chart with Title and no Axis Labels', self::getTitleText($chart2->getTitle())); + self::assertEmpty(self::getTitleText($chart2->getXAxisLabel())); + self::assertEmpty(self::getTitleText($chart2->getYAxisLabel())); // No title, only horizontal axis label $chart3 = $charts[2]; - self::assertEmpty(getTitleText($chart3->getTitle())); - self::assertEquals('Horizontal Axis Title Only', getTitleText($chart3->getXAxisLabel())); - self::assertEmpty(getTitleText($chart3->getYAxisLabel())); + self::assertEmpty(self::getTitleText($chart3->getTitle())); + self::assertEquals('Horizontal Axis Title Only', self::getTitleText($chart3->getXAxisLabel())); + self::assertEmpty(self::getTitleText($chart3->getYAxisLabel())); // No title, only vertical axis label $chart4 = $charts[3]; - self::assertEmpty(getTitleText($chart4->getTitle())); - self::assertEquals('Vertical Axis Title Only', getTitleText($chart4->getYAxisLabel())); - self::assertEmpty(getTitleText($chart4->getXAxisLabel())); + self::assertEmpty(self::getTitleText($chart4->getTitle())); + self::assertEquals('Vertical Axis Title Only', self::getTitleText($chart4->getYAxisLabel())); + self::assertEmpty(self::getTitleText($chart4->getXAxisLabel())); // Title and both axis labels $chart5 = $charts[4]; - self::assertEquals('Complete Annotations', getTitleText($chart5->getTitle())); - self::assertEquals('Horizontal Axis Title', getTitleText($chart5->getXAxisLabel())); - self::assertEquals('Vertical Axis Title', getTitleText($chart5->getYAxisLabel())); + self::assertEquals('Complete Annotations', self::getTitleText($chart5->getTitle())); + self::assertEquals('Horizontal Axis Title', self::getTitleText($chart5->getXAxisLabel())); + self::assertEquals('Vertical Axis Title', self::getTitleText($chart5->getYAxisLabel())); } } diff --git a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/CondNumFmtTest.php similarity index 96% rename from tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php rename to tests/PhpSpreadsheetTests/Reader/Xlsx/CondNumFmtTest.php index c7474c6ac3..350baa76b8 100644 --- a/tests/PhpSpreadsheetTests/Reader/CondNumFmtTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/CondNumFmtTest.php @@ -1,6 +1,6 @@