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 '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;
}
}

View File

@ -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) {

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,