Attempt to satisfy php-cs-fixer

This commit is contained in:
Alexander Hofstede 2019-12-20 23:33:28 +01:00
parent bb83904083
commit ffec80422b
6 changed files with 32 additions and 30 deletions

View File

@ -1,9 +1,7 @@
<?php <?php
namespace Box\Spout\Writer\Common\Manager; namespace Box\Spout\Writer\Common\Manager;
trait ManagesCellSize trait ManagesCellSize
{ {
/** @var float|null The default column width to use */ /** @var float|null The default column width to use */

View File

@ -116,8 +116,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
/** /**
* Creates a new sheet in the workbook. The current sheet remains unchanged. * Creates a new sheet in the workbook. The current sheet remains unchanged.
* *
* @return Worksheet The created sheet
* @throws IOException * @throws IOException
* @return Worksheet The created sheet
*/ */
private function addNewSheet() private function addNewSheet()
{ {
@ -171,8 +171,8 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* The writing will resume where it stopped (i.e. data won't be truncated). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The "external" sheet to set as current * @param Sheet $sheet The "external" sheet to set as current
* @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook * @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @return void
*/ */
public function setCurrentSheet(Sheet $sheet) public function setCurrentSheet(Sheet $sheet)
{ {
@ -220,9 +220,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* *
* @param Row $row The row to be added * @param Row $row The row to be added
* *
* @return void
* @throws IOException If trying to create a new sheet and unable to open the sheet for writing * @throws IOException If trying to create a new sheet and unable to open the sheet for writing
* @throws \Box\Spout\Common\Exception\InvalidArgumentException * @throws \Box\Spout\Common\Exception\InvalidArgumentException
* @return void
*/ */
public function addRowToCurrentWorksheet(Row $row) public function addRowToCurrentWorksheet(Row $row)
{ {
@ -260,9 +260,9 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface
* @param Worksheet $worksheet Worksheet to write the row to * @param Worksheet $worksheet Worksheet to write the row to
* @param Row $row The row to be added * @param Row $row The row to be added
* *
* @return void
* @throws IOException * @throws IOException
* @throws \Box\Spout\Common\Exception\InvalidArgumentException * @throws \Box\Spout\Common\Exception\InvalidArgumentException
* @return void
*/ */
private function addRowToWorksheet(Worksheet $worksheet, Row $row) private function addRowToWorksheet(Worksheet $worksheet, Row $row)
{ {

View File

@ -190,7 +190,7 @@ EOD;
} }
// Sort column widths since ODS cares about order // Sort column widths since ODS cares about order
usort($this->columnWidths, function($a, $b) { usort($this->columnWidths, function ($a, $b) {
if ($a[0] == $b[0]) { if ($a[0] == $b[0]) {
return 0; return 0;
} }
@ -329,9 +329,12 @@ EOD;
private function transformCellAlignment($cellAlignment) private function transformCellAlignment($cellAlignment)
{ {
switch ($cellAlignment) { switch ($cellAlignment) {
case CellAlignment::LEFT: return 'start'; case CellAlignment::LEFT:
case CellAlignment::RIGHT: return 'end'; return 'start';
default: return $cellAlignment; case CellAlignment::RIGHT:
return 'end';
default:
return $cellAlignment;
} }
} }
@ -398,7 +401,7 @@ EOD;
return \sprintf(' fo:background-color="#%s" ', $style->getBackgroundColor()); return \sprintf(' fo:background-color="#%s" ', $style->getBackgroundColor());
} }
public function getTableColumnStylesXMLContent(): string public function getTableColumnStylesXMLContent() : string
{ {
if (empty($this->columnWidths)) { if (empty($this->columnWidths)) {
return ''; return '';
@ -415,7 +418,7 @@ EOD;
return $content; return $content;
} }
public function getStyledTableColumnXMLContent(int $maxNumColumns): string public function getStyledTableColumnXMLContent(int $maxNumColumns) : string
{ {
if (empty($this->columnWidths)) { if (empty($this->columnWidths)) {
return ''; return '';

View File

@ -50,14 +50,15 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
* This must be set before opening the writer. * 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 * @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 * @throws WriterAlreadyOpenedException If the writer was already opened
* @return WriterMultiSheetsAbstract
*/ */
public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically) public function setShouldCreateNewSheetsAutomatically($shouldCreateNewSheetsAutomatically)
{ {
$this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.'); $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; 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. * 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 IOException
* @throws WriterNotOpenedException If the writer has not been opened yet * @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet The created sheet
*/ */
public function addNewSheetAndMakeItCurrent() public function addNewSheetAndMakeItCurrent()
{ {
@ -112,8 +113,8 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract
/** /**
* Returns the current sheet * Returns the current sheet
* *
* @return Sheet The current sheet
* @throws WriterNotOpenedException If the writer has not been opened yet * @throws WriterNotOpenedException If the writer has not been opened yet
* @return Sheet The current sheet
*/ */
public function getCurrentSheet() 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). * The writing will resume where it stopped (i.e. data won't be truncated).
* *
* @param Sheet $sheet The sheet to set as current * @param Sheet $sheet The sheet to set as current
* @return void
* @throws SheetNotFoundException If the given sheet does not exist in the workbook * @throws SheetNotFoundException If the given sheet does not exist in the workbook
* @throws WriterNotOpenedException If the writer has not been opened yet * @throws WriterNotOpenedException If the writer has not been opened yet
* @return void
*/ */
public function setCurrentSheet($sheet) 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. * 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 * @throws WriterNotOpenedException If the workbook is not created yet
* @return void
*/ */
protected function throwIfWorkbookIsNotAvailable() protected function throwIfWorkbookIsNotAvailable()
{ {

View File

@ -128,8 +128,8 @@ EOD;
* Checks if the sheet has been sucessfully created. Throws an exception if not. * 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 * @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 * @throws IOException If the sheet data file cannot be opened for writing
* @return void
*/ */
private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer) private function throwIfSheetFilePointerIsNotAvailable($sheetFilePointer)
{ {
@ -155,9 +155,9 @@ EOD;
* *
* @param Worksheet $worksheet The worksheet to add the row to * @param Worksheet $worksheet The worksheet to add the row to
* @param Row $row The row to be written * @param Row $row The row to be written
* @return void
* @throws InvalidArgumentException If a cell value's type is not supported * @throws InvalidArgumentException If a cell value's type is not supported
* @throws IOException If the data cannot be written * @throws IOException If the data cannot be written
* @return void
*/ */
private function addNonEmptyRow(Worksheet $worksheet, Row $row) private function addNonEmptyRow(Worksheet $worksheet, Row $row)
{ {
@ -197,8 +197,8 @@ EOD;
* @param int $rowIndexOneBased * @param int $rowIndexOneBased
* @param int $columnIndexZeroBased * @param int $columnIndexZeroBased
* *
* @return string
* @throws InvalidArgumentException If the given value cannot be processed * @throws InvalidArgumentException If the given value cannot be processed
* @return string
*/ */
private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndexOneBased, $columnIndexZeroBased) private function applyStyleAndGetCellXML(Cell $cell, Style $rowStyle, $rowIndexOneBased, $columnIndexZeroBased)
{ {
@ -220,8 +220,8 @@ EOD;
* @param Cell $cell * @param Cell $cell
* @param int $styleId * @param int $styleId
* *
* @return string
* @throws InvalidArgumentException If the given value cannot be processed * @throws InvalidArgumentException If the given value cannot be processed
* @return string
*/ */
private function getCellXML($rowIndexOneBased, $columnIndexZeroBased, Cell $cell, $styleId) 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 * Returns the XML fragment for a cell containing a non empty string
* *
* @param string $cellValue The cell value * @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 * @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) private function getCellXMLFragmentForNonEmptyString($cellValue)
{ {

View File

@ -93,7 +93,7 @@ class SheetTest extends TestCase
$this->assertContains(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); $this->assertContains(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"');
} }
function testThrowsIfWorkbookIsNotInitialized() public function testThrowsIfWorkbookIsNotInitialized()
{ {
$this->expectException(WriterNotOpenedException::class); $this->expectException(WriterNotOpenedException::class);
$writer = WriterEntityFactory::createODSWriter(); $writer = WriterEntityFactory::createODSWriter();