Fixed coding standard with return typehints

This commit is contained in:
aswinkumar863 2022-04-17 17:46:59 +05:30
parent ea3263650b
commit 44d63f027a
No known key found for this signature in database
GPG Key ID: 8A69BFA6AEF8FA3E
4 changed files with 46 additions and 134 deletions

View File

@ -73,20 +73,16 @@ class Table
/** /**
* Get Table name. * Get Table name.
*
* @return string
*/ */
public function getName() public function getName(): string
{ {
return $this->name; return $this->name;
} }
/** /**
* Set Table name. * Set Table name.
*
* @return $this
*/ */
public function setName(string $name) public function setName(string $name): self
{ {
$name = trim($name); $name = trim($name);
@ -117,20 +113,16 @@ class Table
/** /**
* Get show Header Row. * Get show Header Row.
*
* @return bool
*/ */
public function getShowHeaderRow() public function getShowHeaderRow(): bool
{ {
return $this->showHeaderRow; return $this->showHeaderRow;
} }
/** /**
* Set show Header Row. * Set show Header Row.
*
* @return $this
*/ */
public function setShowHeaderRow(bool $showHeaderRow) public function setShowHeaderRow(bool $showHeaderRow): self
{ {
$this->showHeaderRow = $showHeaderRow; $this->showHeaderRow = $showHeaderRow;
@ -139,20 +131,16 @@ class Table
/** /**
* Get show Totals Row. * Get show Totals Row.
*
* @return bool
*/ */
public function getShowTotalsRow() public function getShowTotalsRow(): bool
{ {
return $this->showTotalsRow; return $this->showTotalsRow;
} }
/** /**
* Set show Totals Row. * Set show Totals Row.
*
* @return $this
*/ */
public function setShowTotalsRow(bool $showTotalsRow) public function setShowTotalsRow(bool $showTotalsRow): self
{ {
$this->showTotalsRow = $showTotalsRow; $this->showTotalsRow = $showTotalsRow;
@ -161,18 +149,14 @@ class Table
/** /**
* Get Table Range. * Get Table Range.
*
* @return string
*/ */
public function getRange() public function getRange(): string
{ {
return $this->range; return $this->range;
} }
/** /**
* Set Table Cell Range. * Set Table Cell Range.
*
* @return $this
*/ */
public function setRange(string $range): self public function setRange(string $range): self
{ {
@ -210,8 +194,6 @@ class Table
/** /**
* Set Table Cell Range to max row. * Set Table Cell Range to max row.
*
* @return $this
*/ */
public function setRangeToMaxRow(): self public function setRangeToMaxRow(): self
{ {
@ -228,20 +210,16 @@ class Table
/** /**
* Get Table's Worksheet. * Get Table's Worksheet.
*
* @return null|Worksheet
*/ */
public function getWorksheet() public function getWorksheet(): ?Worksheet
{ {
return $this->workSheet; return $this->workSheet;
} }
/** /**
* Set Table's Worksheet. * Set Table's Worksheet.
*
* @return $this
*/ */
public function setWorksheet(?Worksheet $worksheet = null) public function setWorksheet(?Worksheet $worksheet = null): self
{ {
if ($this->name !== '' && $worksheet !== null) { if ($this->name !== '' && $worksheet !== null) {
$spreadsheet = $worksheet->getParent(); $spreadsheet = $worksheet->getParent();
@ -265,7 +243,7 @@ class Table
* *
* @return Table\Column[] * @return Table\Column[]
*/ */
public function getColumns() public function getColumns(): array
{ {
return $this->columns; return $this->columns;
} }
@ -277,7 +255,7 @@ class Table
* *
* @return int The column offset within the table range * @return int The column offset within the table range
*/ */
public function isColumnInRange($column) public function isColumnInRange(string $column): int
{ {
if (empty($this->range)) { if (empty($this->range)) {
throw new PhpSpreadsheetException('No table range is defined.'); throw new PhpSpreadsheetException('No table range is defined.');
@ -299,7 +277,7 @@ class Table
* *
* @return int The offset of the specified column within the table range * @return int The offset of the specified column within the table range
*/ */
public function getColumnOffset($column) public function getColumnOffset($column): int
{ {
return $this->isColumnInRange($column); return $this->isColumnInRange($column);
} }
@ -308,10 +286,8 @@ class Table
* Get a specified Table Column. * Get a specified Table Column.
* *
* @param string $column Column name (e.g. A) * @param string $column Column name (e.g. A)
*
* @return Table\Column
*/ */
public function getColumn($column) public function getColumn($column): Table\Column
{ {
$this->isColumnInRange($column); $this->isColumnInRange($column);
@ -326,10 +302,8 @@ class Table
* Get a specified Table Column by it's offset. * Get a specified Table Column by it's offset.
* *
* @param int $columnOffset Column offset within range (starting from 0) * @param int $columnOffset Column offset within range (starting from 0)
*
* @return Table\Column
*/ */
public function getColumnByOffset($columnOffset) public function getColumnByOffset($columnOffset): Table\Column
{ {
[$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range);
$pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset); $pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset);
@ -342,10 +316,8 @@ class Table
* *
* @param string|Table\Column $columnObjectOrString * @param string|Table\Column $columnObjectOrString
* A simple string containing a Column ID like 'A' is permitted * A simple string containing a Column ID like 'A' is permitted
*
* @return $this
*/ */
public function setColumn($columnObjectOrString) public function setColumn($columnObjectOrString): self
{ {
if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) { if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) {
$column = $columnObjectOrString; $column = $columnObjectOrString;
@ -371,10 +343,8 @@ class Table
* Clear a specified Table Column. * Clear a specified Table Column.
* *
* @param string $column Column name (e.g. A) * @param string $column Column name (e.g. A)
*
* @return $this
*/ */
public function clearColumn($column) public function clearColumn($column): self
{ {
$this->isColumnInRange($column); $this->isColumnInRange($column);
@ -394,10 +364,8 @@ class Table
* *
* @param string $fromColumn Column name (e.g. A) * @param string $fromColumn Column name (e.g. A)
* @param string $toColumn Column name (e.g. B) * @param string $toColumn Column name (e.g. B)
*
* @return $this
*/ */
public function shiftColumn($fromColumn, $toColumn) public function shiftColumn($fromColumn, $toColumn): self
{ {
$fromColumn = strtoupper($fromColumn); $fromColumn = strtoupper($fromColumn);
$toColumn = strtoupper($toColumn); $toColumn = strtoupper($toColumn);
@ -417,20 +385,16 @@ class Table
/** /**
* Get table Style. * Get table Style.
*
* @return TableStyle
*/ */
public function getStyle() public function getStyle(): Table\TableStyle
{ {
return $this->style; return $this->style;
} }
/** /**
* Set table Style. * Set table Style.
*
* @return $this
*/ */
public function setStyle(TableStyle $style) public function setStyle(TableStyle $style): self
{ {
$this->style = $style; $this->style = $style;

View File

@ -69,10 +69,8 @@ class Column
/** /**
* Get Table column index as string eg: 'A'. * Get Table column index as string eg: 'A'.
*
* @return string
*/ */
public function getColumnIndex() public function getColumnIndex(): string
{ {
return $this->columnIndex; return $this->columnIndex;
} }
@ -81,10 +79,8 @@ class Column
* Set Table column index as string eg: 'A'. * Set Table column index as string eg: 'A'.
* *
* @param string $column Column (e.g. A) * @param string $column Column (e.g. A)
*
* @return $this
*/ */
public function setColumnIndex($column) public function setColumnIndex($column): self
{ {
// Uppercase coordinate // Uppercase coordinate
$column = strtoupper($column); $column = strtoupper($column);
@ -99,20 +95,16 @@ class Column
/** /**
* Get show Filter Button. * Get show Filter Button.
*
* @return bool
*/ */
public function getShowFilterButton() public function getShowFilterButton(): bool
{ {
return $this->showFilterButton; return $this->showFilterButton;
} }
/** /**
* Set show Filter Button. * Set show Filter Button.
*
* @return $this
*/ */
public function setShowFilterButton(bool $showFilterButton) public function setShowFilterButton(bool $showFilterButton): self
{ {
$this->showFilterButton = $showFilterButton; $this->showFilterButton = $showFilterButton;
@ -121,20 +113,16 @@ class Column
/** /**
* Get total Row Label. * Get total Row Label.
*
* @return string
*/ */
public function getTotalsRowLabel() public function getTotalsRowLabel(): ?string
{ {
return $this->totalsRowLabel; return $this->totalsRowLabel;
} }
/** /**
* Set total Row Label. * Set total Row Label.
*
* @return $this
*/ */
public function setTotalsRowLabel(string $totalsRowLabel) public function setTotalsRowLabel(string $totalsRowLabel): self
{ {
$this->totalsRowLabel = $totalsRowLabel; $this->totalsRowLabel = $totalsRowLabel;
@ -143,20 +131,16 @@ class Column
/** /**
* Get total Row Function. * Get total Row Function.
*
* @return string
*/ */
public function getTotalsRowFunction() public function getTotalsRowFunction(): ?string
{ {
return $this->totalsRowFunction; return $this->totalsRowFunction;
} }
/** /**
* Set total Row Function. * Set total Row Function.
*
* @return $this
*/ */
public function setTotalsRowFunction(string $totalsRowFunction) public function setTotalsRowFunction(string $totalsRowFunction): self
{ {
$this->totalsRowFunction = $totalsRowFunction; $this->totalsRowFunction = $totalsRowFunction;
@ -165,20 +149,16 @@ class Column
/** /**
* Get total Row Formula. * Get total Row Formula.
*
* @return string
*/ */
public function getTotalsRowFormula() public function getTotalsRowFormula(): ?string
{ {
return $this->totalsRowFormula; return $this->totalsRowFormula;
} }
/** /**
* Set total Row Formula. * Set total Row Formula.
*
* @return $this
*/ */
public function setTotalsRowFormula(string $totalsRowFormula) public function setTotalsRowFormula(string $totalsRowFormula): self
{ {
$this->totalsRowFormula = $totalsRowFormula; $this->totalsRowFormula = $totalsRowFormula;
@ -187,20 +167,16 @@ class Column
/** /**
* Get column Formula. * Get column Formula.
*
* @return string
*/ */
public function getColumnFormula() public function getColumnFormula(): ?string
{ {
return $this->columnFormula; return $this->columnFormula;
} }
/** /**
* Set column Formula. * Set column Formula.
*
* @return $this
*/ */
public function setColumnFormula(string $columnFormula) public function setColumnFormula(string $columnFormula): self
{ {
$this->columnFormula = $columnFormula; $this->columnFormula = $columnFormula;
@ -209,20 +185,16 @@ class Column
/** /**
* Get this Column's Table. * Get this Column's Table.
*
* @return null|Table
*/ */
public function getTable() public function getTable(): ?Table
{ {
return $this->table; return $this->table;
} }
/** /**
* Set this Column's Table. * Set this Column's Table.
*
* @return $this
*/ */
public function setTable(?Table $table = null) public function setTable(?Table $table = null): self
{ {
$this->table = $table; $this->table = $table;

View File

@ -122,20 +122,16 @@ class TableStyle
/** /**
* Get theme. * Get theme.
*
* @return string
*/ */
public function getTheme() public function getTheme(): string
{ {
return $this->theme; return $this->theme;
} }
/** /**
* Set theme. * Set theme.
*
* @return $this
*/ */
public function setTheme(string $theme) public function setTheme(string $theme): self
{ {
$this->theme = $theme; $this->theme = $theme;
@ -144,20 +140,16 @@ class TableStyle
/** /**
* Get show First Column. * Get show First Column.
*
* @return bool
*/ */
public function getShowFirstColumn() public function getShowFirstColumn(): bool
{ {
return $this->showFirstColumn; return $this->showFirstColumn;
} }
/** /**
* Set show First Column. * Set show First Column.
*
* @return $this
*/ */
public function setShowFirstColumn(bool $showFirstColumn) public function setShowFirstColumn(bool $showFirstColumn): self
{ {
$this->showFirstColumn = $showFirstColumn; $this->showFirstColumn = $showFirstColumn;
@ -166,20 +158,16 @@ class TableStyle
/** /**
* Get show Last Column. * Get show Last Column.
*
* @return bool
*/ */
public function getShowLastColumn() public function getShowLastColumn(): bool
{ {
return $this->showLastColumn; return $this->showLastColumn;
} }
/** /**
* Set show Last Column. * Set show Last Column.
*
* @return $this
*/ */
public function setShowLastColumn(bool $showLastColumn) public function setShowLastColumn(bool $showLastColumn): self
{ {
$this->showLastColumn = $showLastColumn; $this->showLastColumn = $showLastColumn;
@ -188,20 +176,16 @@ class TableStyle
/** /**
* Get show Row Stripes. * Get show Row Stripes.
*
* @return bool
*/ */
public function getShowRowStripes() public function getShowRowStripes(): bool
{ {
return $this->showRowStripes; return $this->showRowStripes;
} }
/** /**
* Set show Row Stripes. * Set show Row Stripes.
*
* @return $this
*/ */
public function setShowRowStripes(bool $showRowStripes) public function setShowRowStripes(bool $showRowStripes): self
{ {
$this->showRowStripes = $showRowStripes; $this->showRowStripes = $showRowStripes;
@ -210,20 +194,16 @@ class TableStyle
/** /**
* Get show Column Stripes. * Get show Column Stripes.
*
* @return bool
*/ */
public function getShowColumnStripes() public function getShowColumnStripes(): bool
{ {
return $this->showColumnStripes; return $this->showColumnStripes;
} }
/** /**
* Set show Column Stripes. * Set show Column Stripes.
*
* @return $this
*/ */
public function setShowColumnStripes(bool $showColumnStripes) public function setShowColumnStripes(bool $showColumnStripes): self
{ {
$this->showColumnStripes = $showColumnStripes; $this->showColumnStripes = $showColumnStripes;
@ -232,20 +212,16 @@ class TableStyle
/** /**
* Get this Style's Table. * Get this Style's Table.
*
* @return null|Table
*/ */
public function getTable() public function getTable(): ?Table
{ {
return $this->table; return $this->table;
} }
/** /**
* Set this Style's Table. * Set this Style's Table.
*
* @return $this
*/ */
public function setTable(?Table $table = null) public function setTable(?Table $table = null): self
{ {
$this->table = $table; $this->table = $table;

View File

@ -15,7 +15,7 @@ class Table extends WriterPart
* *
* @return string XML Output * @return string XML Output
*/ */
public function writeTable(WorksheetTable $table, $tableRef) public function writeTable(WorksheetTable $table, $tableRef): string
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;