From ffec80422b5da0a26121e009ba32bfd67abaca10 Mon Sep 17 00:00:00 2001 From: Alexander Hofstede Date: Fri, 20 Dec 2019 23:33:28 +0100 Subject: [PATCH] Attempt to satisfy php-cs-fixer --- .../Writer/Common/Manager/ManagesCellSize.php | 2 -- .../Manager/WorkbookManagerAbstract.php | 8 +++---- .../Writer/ODS/Manager/Style/StyleManager.php | 15 ++++++++----- .../Writer/WriterMultiSheetsAbstract.php | 13 ++++++----- .../Writer/XLSX/Manager/WorksheetManager.php | 22 +++++++++---------- tests/Spout/Writer/ODS/SheetTest.php | 2 +- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/Spout/Writer/Common/Manager/ManagesCellSize.php b/src/Spout/Writer/Common/Manager/ManagesCellSize.php index 60de4cf..00ac8c1 100644 --- a/src/Spout/Writer/Common/Manager/ManagesCellSize.php +++ b/src/Spout/Writer/Common/Manager/ManagesCellSize.php @@ -1,9 +1,7 @@ columnWidths, function($a, $b) { + usort($this->columnWidths, function ($a, $b) { if ($a[0] == $b[0]) { return 0; } @@ -329,9 +329,12 @@ EOD; private function transformCellAlignment($cellAlignment) { switch ($cellAlignment) { - case CellAlignment::LEFT: return 'start'; - case CellAlignment::RIGHT: return 'end'; - default: return $cellAlignment; + case CellAlignment::LEFT: + return 'start'; + case CellAlignment::RIGHT: + return 'end'; + default: + return $cellAlignment; } } @@ -398,7 +401,7 @@ EOD; return \sprintf(' fo:background-color="#%s" ', $style->getBackgroundColor()); } - public function getTableColumnStylesXMLContent(): string + public function getTableColumnStylesXMLContent() : string { if (empty($this->columnWidths)) { return ''; @@ -415,7 +418,7 @@ EOD; return $content; } - public function getStyledTableColumnXMLContent(int $maxNumColumns): string + public function getStyledTableColumnXMLContent(int $maxNumColumns) : string { if (empty($this->columnWidths)) { return ''; diff --git a/src/Spout/Writer/WriterMultiSheetsAbstract.php b/src/Spout/Writer/WriterMultiSheetsAbstract.php index 0bf3bf6..77d58d8 100644 --- a/src/Spout/Writer/WriterMultiSheetsAbstract.php +++ b/src/Spout/Writer/WriterMultiSheetsAbstract.php @@ -50,14 +50,15 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract * This must be set before opening the writer. * * @param bool $shouldCreateNewSheetsAutomatically Whether new sheets should be automatically created when the max rows limit per sheet is reached - * @return WriterMultiSheetsAbstract * @throws WriterAlreadyOpenedException If the writer was already opened + * @return WriterMultiSheetsAbstract */ public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically) { $this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.'); - $this->optionsManager->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, $shouldCreateNewSheetsAutomatically); + $this->optionsManager->setOption(Options::SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY, + $shouldCreateNewSheetsAutomatically); return $this; } @@ -97,9 +98,9 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract /** * Creates a new sheet and make it the current sheet. The data will now be written to this sheet. * - * @return Sheet The created sheet * @throws IOException * @throws WriterNotOpenedException If the writer has not been opened yet + * @return Sheet The created sheet */ public function addNewSheetAndMakeItCurrent() { @@ -112,8 +113,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract /** * Returns the current sheet * - * @return Sheet The current sheet * @throws WriterNotOpenedException If the writer has not been opened yet + * @return Sheet The current sheet */ public function getCurrentSheet() { @@ -127,9 +128,9 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract * The writing will resume where it stopped (i.e. data won't be truncated). * * @param Sheet $sheet The sheet to set as current - * @return void * @throws SheetNotFoundException If the given sheet does not exist in the workbook * @throws WriterNotOpenedException If the writer has not been opened yet + * @return void */ public function setCurrentSheet($sheet) { @@ -183,8 +184,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract /** * Checks if the workbook has been created. Throws an exception if not created yet. * - * @return void * @throws WriterNotOpenedException If the workbook is not created yet + * @return void */ protected function throwIfWorkbookIsNotAvailable() { diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php index f85a051..1d19f47 100644 --- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php @@ -128,8 +128,8 @@ EOD; * Checks if the sheet has been sucessfully created. Throws an exception if not. * * @param bool|resource $sheetFilePointer Pointer to the sheet data file or FALSE if unable to open the file - * @return void * @throws IOException If the sheet data file cannot be opened for writing + * @return void */ private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer) { @@ -155,9 +155,9 @@ EOD; * * @param Worksheet $worksheet The worksheet to add the row to * @param Row $row The row to be written - * @return void * @throws InvalidArgumentException If a cell value's type is not supported * @throws IOException If the data cannot be written + * @return void */ private function addNonEmptyRow(Worksheet $worksheet, Row $row) { @@ -192,13 +192,13 @@ EOD; * Applies styles to the given style, merging the cell's style with its row's style * Then builds and returns xml for the cell. * - * @param Cell $cell + * @param Cell $cell * @param Style $rowStyle - * @param int $rowIndexOneBased - * @param int $columnIndexZeroBased + * @param int $rowIndexOneBased + * @param int $columnIndexZeroBased * - * @return string * @throws InvalidArgumentException If the given value cannot be processed + * @return string */ private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndexOneBased, $columnIndexZeroBased) { @@ -215,13 +215,13 @@ EOD; /** * Builds and returns xml for a single cell. * - * @param int $rowIndexOneBased - * @param int $columnIndexZeroBased + * @param int $rowIndexOneBased + * @param int $columnIndexZeroBased * @param Cell $cell - * @param int $styleId + * @param int $styleId * - * @return string * @throws InvalidArgumentException If the given value cannot be processed + * @return string */ private function getCellXML($rowIndexOneBased, $columnIndexZeroBased, Cell $cell, $styleId) { @@ -257,8 +257,8 @@ EOD; * Returns the XML fragment for a cell containing a non empty string * * @param string $cellValue The cell value - * @return string The XML fragment representing the cell * @throws InvalidArgumentException If the string exceeds the maximum number of characters allowed per cell + * @return string The XML fragment representing the cell */ private function getCellXMLFragmentForNonEmptyString($cellValue) { diff --git a/tests/Spout/Writer/ODS/SheetTest.php b/tests/Spout/Writer/ODS/SheetTest.php index fac513a..a8e0c8b 100644 --- a/tests/Spout/Writer/ODS/SheetTest.php +++ b/tests/Spout/Writer/ODS/SheetTest.php @@ -93,7 +93,7 @@ class SheetTest extends TestCase $this->assertContains(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); } - function testThrowsIfWorkbookIsNotInitialized() + public function testThrowsIfWorkbookIsNotInitialized() { $this->expectException(WriterNotOpenedException::class); $writer = WriterEntityFactory::createODSWriter();