diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 32105477..7c735a41 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -453,18 +453,23 @@ class Gnumeric extends BaseReader case 'left': case 'right': $this->sheetMargin($key, $marginSize); + break; case 'top': $this->sheetMargin($key, $marginSet['header'] ?? 0); + break; case 'bottom': $this->sheetMargin($key, $marginSet['footer'] ?? 0); + break; case 'header': $this->sheetMargin($key, ($marginSet['top'] ?? 0) - $marginSize); + break; case 'footer': $this->sheetMargin($key, ($marginSet['bottom'] ?? 0) - $marginSize); + break; } } diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index cefcd336..33712e96 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -17,6 +17,7 @@ use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use SimpleXMLElement; +use stdClass; /** * Reader for SpreadsheetML, the XML schema for Microsoft Office Excel 2003. @@ -905,16 +906,16 @@ class Xml extends BaseReader switch ($pageSetupKey) { case 'Layout': $printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT; - $printDefaults->horizontalCentered = (bool)$pageSetupAttributes->CenterHorizontal ?: false; - $printDefaults->verticalCentered = (bool)$pageSetupAttributes->CenterVertical ?: false; + $printDefaults->horizontalCentered = (bool) $pageSetupAttributes->CenterHorizontal ?: false; + $printDefaults->verticalCentered = (bool) $pageSetupAttributes->CenterVertical ?: false; break; case 'Header': - $printDefaults->headerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; + $printDefaults->headerMargin = (float) $pageSetupAttributes->Margin ?: 1.0; break; case 'Footer': - $printDefaults->footerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; + $printDefaults->footerMargin = (float) $pageSetupAttributes->Margin ?: 1.0; break; case 'PageMargins': @@ -932,7 +933,7 @@ class Xml extends BaseReader return $printDefaults; } - private function printSetup(SimpleXMLElement $xmlX, array $namespaces, \stdClass $printDefaults): \stdClass + private function printSetup(SimpleXMLElement $xmlX, array $namespaces, stdClass $printDefaults): stdClass { if (isset($xmlX->WorksheetOptions->Print)) { foreach ($xmlX->WorksheetOptions->Print as $printData) { diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php index 057dbf69..4eb9d5bd 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/PageSetupTest.php @@ -12,18 +12,18 @@ class PageSetupTest extends TestCase private const MARGIN_PRECISION = 0.001; /** - * @var Spreadsheet $spreadsheet + * @var Spreadsheet */ private $spreadsheet; - public function setup(): void + protected function setup(): void { $filename = 'tests/data/Reader/Gnumeric/PageSetup.gnumeric'; $reader = new Gnumeric(); $this->spreadsheet = $reader->load($filename); } - public function testPageSetup() + public function testPageSetup(): void { $assertions = $this->pageSetupAssertions(); @@ -36,7 +36,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageSetup()->$testMethodName(); - $this->assertSame( + self::assertSame( $expectedResult, $actualResult, "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" @@ -45,7 +45,7 @@ class PageSetupTest extends TestCase } } - public function testPageMargins() + public function testPageMargins(): void { $assertions = $this->pageMarginAssertions(); @@ -58,7 +58,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageMargins()->$testMethodName(); - $this->assertEqualsWithDelta( + self::assertEqualsWithDelta( $expectedResult, $actualResult, self::MARGIN_PRECISION, diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php index 74eaae8f..e17c5da4 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupTest.php @@ -14,18 +14,18 @@ class PageSetupTest extends TestCase private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm /** - * @var Spreadsheet $spreadsheet + * @var Spreadsheet */ private $spreadsheet; - public function setup(): void + protected function setup(): void { $filename = 'tests/data/Reader/Ods/PageSetup.ods'; $reader = new Ods(); $this->spreadsheet = $reader->load($filename); } - public function testPageSetup() + public function testPageSetup(): void { $assertions = $this->pageSetupAssertions(); @@ -38,7 +38,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageSetup()->$testMethodName(); - $this->assertSame( + self::assertSame( $expectedResult, $actualResult, "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" @@ -47,7 +47,7 @@ class PageSetupTest extends TestCase } } - public function testPageMargins() + public function testPageMargins(): void { $assertions = $this->pageMarginAssertions(); @@ -60,7 +60,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageMargins()->$testMethodName(); - $this->assertEqualsWithDelta( + self::assertEqualsWithDelta( $expectedResult, $actualResult, self::MARGIN_PRECISION, diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php index 2cfbbb3f..5947d1b5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xls/PageSetupTest.php @@ -14,18 +14,18 @@ class PageSetupTest extends TestCase private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm /** - * @var Spreadsheet $spreadsheet + * @var Spreadsheet */ private $spreadsheet; - public function setup(): void + protected function setup(): void { $filename = 'tests/data/Reader/XLS/PageSetup.xls'; $reader = new Xls(); $this->spreadsheet = $reader->load($filename); } - public function testPageSetup() + public function testPageSetup(): void { $assertions = $this->pageSetupAssertions(); @@ -38,7 +38,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageSetup()->$testMethodName(); - $this->assertSame( + self::assertSame( $expectedResult, $actualResult, "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" @@ -47,7 +47,7 @@ class PageSetupTest extends TestCase } } - public function testPageMargins() + public function testPageMargins(): void { $assertions = $this->pageMarginAssertions(); @@ -60,7 +60,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageMargins()->$testMethodName(); - $this->assertEqualsWithDelta( + self::assertEqualsWithDelta( $expectedResult, $actualResult, self::MARGIN_PRECISION, diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php index a5b287fe..cd1bd174 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/PageSetupTest.php @@ -14,18 +14,18 @@ class PageSetupTest extends TestCase private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm /** - * @var Spreadsheet $spreadsheet + * @var Spreadsheet */ private $spreadsheet; - public function setup(): void + protected function setup(): void { $filename = 'tests/data/Reader/XLSX/PageSetup.xlsx'; $reader = new Xlsx(); $this->spreadsheet = $reader->load($filename); } - public function testPageSetup() + public function testPageSetup(): void { $assertions = $this->pageSetupAssertions(); @@ -38,7 +38,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageSetup()->$testMethodName(); - $this->assertSame( + self::assertSame( $expectedResult, $actualResult, "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" @@ -47,7 +47,7 @@ class PageSetupTest extends TestCase } } - public function testPageMargins() + public function testPageMargins(): void { $assertions = $this->pageMarginAssertions(); @@ -60,7 +60,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageMargins()->$testMethodName(); - $this->assertEqualsWithDelta( + self::assertEqualsWithDelta( $expectedResult, $actualResult, self::MARGIN_PRECISION, diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php index 8b934be6..ab664720 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php @@ -13,18 +13,18 @@ class PageSetupTest extends TestCase private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm /** - * @var Spreadsheet $spreadsheet + * @var Spreadsheet */ private $spreadsheet; - public function setup(): void + protected function setup(): void { $filename = 'tests/data/Reader/Xml/PageSetup.xml'; $reader = new Xml(); $this->spreadsheet = $reader->load($filename); } - public function testPageSetup() + public function testPageSetup(): void { $assertions = $this->pageSetupAssertions(); @@ -37,7 +37,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageSetup()->$testMethodName(); - $this->assertSame( + self::assertSame( $expectedResult, $actualResult, "Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" @@ -46,7 +46,7 @@ class PageSetupTest extends TestCase } } - public function testPageMargins() + public function testPageMargins(): void { $assertions = $this->pageMarginAssertions(); @@ -59,7 +59,7 @@ class PageSetupTest extends TestCase foreach ($sheetAssertions as $test => $expectedResult) { $testMethodName = 'get' . ucfirst($test); $actualResult = $worksheet->getPageMargins()->$testMethodName(); - $this->assertEqualsWithDelta( + self::assertEqualsWithDelta( $expectedResult, $actualResult, self::MARGIN_PRECISION,