phpcs fixes, although I thought I'd successfully added the pre-commit hook to pick those up before the commit, guess the problem is running from Windoze, so I'll have to address that

This commit is contained in:
MarkBaker 2020-07-05 17:05:44 +02:00
parent 3997dcc3af
commit e89196f65b
7 changed files with 41 additions and 35 deletions

View File

@ -453,18 +453,23 @@ class Gnumeric extends BaseReader
case 'left': case 'left':
case 'right': case 'right':
$this->sheetMargin($key, $marginSize); $this->sheetMargin($key, $marginSize);
break; break;
case 'top': case 'top':
$this->sheetMargin($key, $marginSet['header'] ?? 0); $this->sheetMargin($key, $marginSet['header'] ?? 0);
break; break;
case 'bottom': case 'bottom':
$this->sheetMargin($key, $marginSet['footer'] ?? 0); $this->sheetMargin($key, $marginSet['footer'] ?? 0);
break; break;
case 'header': case 'header':
$this->sheetMargin($key, ($marginSet['top'] ?? 0) - $marginSize); $this->sheetMargin($key, ($marginSet['top'] ?? 0) - $marginSize);
break; break;
case 'footer': case 'footer':
$this->sheetMargin($key, ($marginSet['bottom'] ?? 0) - $marginSize); $this->sheetMargin($key, ($marginSet['bottom'] ?? 0) - $marginSize);
break; break;
} }
} }

View File

@ -17,6 +17,7 @@ use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Style\Font;
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
use SimpleXMLElement; use SimpleXMLElement;
use stdClass;
/** /**
* Reader for SpreadsheetML, the XML schema for Microsoft Office Excel 2003. * Reader for SpreadsheetML, the XML schema for Microsoft Office Excel 2003.
@ -905,16 +906,16 @@ class Xml extends BaseReader
switch ($pageSetupKey) { switch ($pageSetupKey) {
case 'Layout': case 'Layout':
$printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT; $printDefaults->orientation = (string) strtolower($pageSetupAttributes->Orientation) ?: PageSetup::ORIENTATION_PORTRAIT;
$printDefaults->horizontalCentered = (bool)$pageSetupAttributes->CenterHorizontal ?: false; $printDefaults->horizontalCentered = (bool) $pageSetupAttributes->CenterHorizontal ?: false;
$printDefaults->verticalCentered = (bool)$pageSetupAttributes->CenterVertical ?: false; $printDefaults->verticalCentered = (bool) $pageSetupAttributes->CenterVertical ?: false;
break; break;
case 'Header': case 'Header':
$printDefaults->headerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; $printDefaults->headerMargin = (float) $pageSetupAttributes->Margin ?: 1.0;
break; break;
case 'Footer': case 'Footer':
$printDefaults->footerMargin = (float)$pageSetupAttributes->Margin ?: 1.0; $printDefaults->footerMargin = (float) $pageSetupAttributes->Margin ?: 1.0;
break; break;
case 'PageMargins': case 'PageMargins':
@ -932,7 +933,7 @@ class Xml extends BaseReader
return $printDefaults; 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)) { if (isset($xmlX->WorksheetOptions->Print)) {
foreach ($xmlX->WorksheetOptions->Print as $printData) { foreach ($xmlX->WorksheetOptions->Print as $printData) {

View File

@ -12,18 +12,18 @@ class PageSetupTest extends TestCase
private const MARGIN_PRECISION = 0.001; private const MARGIN_PRECISION = 0.001;
/** /**
* @var Spreadsheet $spreadsheet * @var Spreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
public function setup(): void protected function setup(): void
{ {
$filename = 'tests/data/Reader/Gnumeric/PageSetup.gnumeric'; $filename = 'tests/data/Reader/Gnumeric/PageSetup.gnumeric';
$reader = new Gnumeric(); $reader = new Gnumeric();
$this->spreadsheet = $reader->load($filename); $this->spreadsheet = $reader->load($filename);
} }
public function testPageSetup() public function testPageSetup(): void
{ {
$assertions = $this->pageSetupAssertions(); $assertions = $this->pageSetupAssertions();
@ -36,7 +36,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageSetup()->$testMethodName(); $actualResult = $worksheet->getPageSetup()->$testMethodName();
$this->assertSame( self::assertSame(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
"Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" "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(); $assertions = $this->pageMarginAssertions();
@ -58,7 +58,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageMargins()->$testMethodName(); $actualResult = $worksheet->getPageMargins()->$testMethodName();
$this->assertEqualsWithDelta( self::assertEqualsWithDelta(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
self::MARGIN_PRECISION, self::MARGIN_PRECISION,

View File

@ -14,18 +14,18 @@ class PageSetupTest extends TestCase
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
/** /**
* @var Spreadsheet $spreadsheet * @var Spreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
public function setup(): void protected function setup(): void
{ {
$filename = 'tests/data/Reader/Ods/PageSetup.ods'; $filename = 'tests/data/Reader/Ods/PageSetup.ods';
$reader = new Ods(); $reader = new Ods();
$this->spreadsheet = $reader->load($filename); $this->spreadsheet = $reader->load($filename);
} }
public function testPageSetup() public function testPageSetup(): void
{ {
$assertions = $this->pageSetupAssertions(); $assertions = $this->pageSetupAssertions();
@ -38,7 +38,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageSetup()->$testMethodName(); $actualResult = $worksheet->getPageSetup()->$testMethodName();
$this->assertSame( self::assertSame(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
"Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" "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(); $assertions = $this->pageMarginAssertions();
@ -60,7 +60,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageMargins()->$testMethodName(); $actualResult = $worksheet->getPageMargins()->$testMethodName();
$this->assertEqualsWithDelta( self::assertEqualsWithDelta(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
self::MARGIN_PRECISION, self::MARGIN_PRECISION,

View File

@ -14,18 +14,18 @@ class PageSetupTest extends TestCase
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
/** /**
* @var Spreadsheet $spreadsheet * @var Spreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
public function setup(): void protected function setup(): void
{ {
$filename = 'tests/data/Reader/XLS/PageSetup.xls'; $filename = 'tests/data/Reader/XLS/PageSetup.xls';
$reader = new Xls(); $reader = new Xls();
$this->spreadsheet = $reader->load($filename); $this->spreadsheet = $reader->load($filename);
} }
public function testPageSetup() public function testPageSetup(): void
{ {
$assertions = $this->pageSetupAssertions(); $assertions = $this->pageSetupAssertions();
@ -38,7 +38,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageSetup()->$testMethodName(); $actualResult = $worksheet->getPageSetup()->$testMethodName();
$this->assertSame( self::assertSame(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
"Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" "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(); $assertions = $this->pageMarginAssertions();
@ -60,7 +60,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageMargins()->$testMethodName(); $actualResult = $worksheet->getPageMargins()->$testMethodName();
$this->assertEqualsWithDelta( self::assertEqualsWithDelta(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
self::MARGIN_PRECISION, self::MARGIN_PRECISION,

View File

@ -14,18 +14,18 @@ class PageSetupTest extends TestCase
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
/** /**
* @var Spreadsheet $spreadsheet * @var Spreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
public function setup(): void protected function setup(): void
{ {
$filename = 'tests/data/Reader/XLSX/PageSetup.xlsx'; $filename = 'tests/data/Reader/XLSX/PageSetup.xlsx';
$reader = new Xlsx(); $reader = new Xlsx();
$this->spreadsheet = $reader->load($filename); $this->spreadsheet = $reader->load($filename);
} }
public function testPageSetup() public function testPageSetup(): void
{ {
$assertions = $this->pageSetupAssertions(); $assertions = $this->pageSetupAssertions();
@ -38,7 +38,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageSetup()->$testMethodName(); $actualResult = $worksheet->getPageSetup()->$testMethodName();
$this->assertSame( self::assertSame(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
"Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" "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(); $assertions = $this->pageMarginAssertions();
@ -60,7 +60,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageMargins()->$testMethodName(); $actualResult = $worksheet->getPageMargins()->$testMethodName();
$this->assertEqualsWithDelta( self::assertEqualsWithDelta(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
self::MARGIN_PRECISION, self::MARGIN_PRECISION,

View File

@ -13,18 +13,18 @@ class PageSetupTest extends TestCase
private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm private const MARGIN_UNIT_CONVERSION = 2.54; // Inches to cm
/** /**
* @var Spreadsheet $spreadsheet * @var Spreadsheet
*/ */
private $spreadsheet; private $spreadsheet;
public function setup(): void protected function setup(): void
{ {
$filename = 'tests/data/Reader/Xml/PageSetup.xml'; $filename = 'tests/data/Reader/Xml/PageSetup.xml';
$reader = new Xml(); $reader = new Xml();
$this->spreadsheet = $reader->load($filename); $this->spreadsheet = $reader->load($filename);
} }
public function testPageSetup() public function testPageSetup(): void
{ {
$assertions = $this->pageSetupAssertions(); $assertions = $this->pageSetupAssertions();
@ -37,7 +37,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageSetup()->$testMethodName(); $actualResult = $worksheet->getPageSetup()->$testMethodName();
$this->assertSame( self::assertSame(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
"Failed assertion for Worksheet '{$worksheet->getTitle()}' {$test}" "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(); $assertions = $this->pageMarginAssertions();
@ -59,7 +59,7 @@ class PageSetupTest extends TestCase
foreach ($sheetAssertions as $test => $expectedResult) { foreach ($sheetAssertions as $test => $expectedResult) {
$testMethodName = 'get' . ucfirst($test); $testMethodName = 'get' . ucfirst($test);
$actualResult = $worksheet->getPageMargins()->$testMethodName(); $actualResult = $worksheet->getPageMargins()->$testMethodName();
$this->assertEqualsWithDelta( self::assertEqualsWithDelta(
$expectedResult, $expectedResult,
$actualResult, $actualResult,
self::MARGIN_PRECISION, self::MARGIN_PRECISION,