Skip to content

Commit 44d63f0

Browse files
committed
Fixed coding standard with return typehints
1 parent ea32636 commit 44d63f0

File tree

4 files changed

+46
-134
lines changed

4 files changed

+46
-134
lines changed

src/PhpSpreadsheet/Worksheet/Table.php

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,16 @@ public function __construct(string $range = '', ?Worksheet $worksheet = null)
7373

7474
/**
7575
* Get Table name.
76-
*
77-
* @return string
7876
*/
79-
public function getName()
77+
public function getName(): string
8078
{
8179
return $this->name;
8280
}
8381

8482
/**
8583
* Set Table name.
86-
*
87-
* @return $this
8884
*/
89-
public function setName(string $name)
85+
public function setName(string $name): self
9086
{
9187
$name = trim($name);
9288

@@ -117,20 +113,16 @@ public function setName(string $name)
117113

118114
/**
119115
* Get show Header Row.
120-
*
121-
* @return bool
122116
*/
123-
public function getShowHeaderRow()
117+
public function getShowHeaderRow(): bool
124118
{
125119
return $this->showHeaderRow;
126120
}
127121

128122
/**
129123
* Set show Header Row.
130-
*
131-
* @return $this
132124
*/
133-
public function setShowHeaderRow(bool $showHeaderRow)
125+
public function setShowHeaderRow(bool $showHeaderRow): self
134126
{
135127
$this->showHeaderRow = $showHeaderRow;
136128

@@ -139,20 +131,16 @@ public function setShowHeaderRow(bool $showHeaderRow)
139131

140132
/**
141133
* Get show Totals Row.
142-
*
143-
* @return bool
144134
*/
145-
public function getShowTotalsRow()
135+
public function getShowTotalsRow(): bool
146136
{
147137
return $this->showTotalsRow;
148138
}
149139

150140
/**
151141
* Set show Totals Row.
152-
*
153-
* @return $this
154142
*/
155-
public function setShowTotalsRow(bool $showTotalsRow)
143+
public function setShowTotalsRow(bool $showTotalsRow): self
156144
{
157145
$this->showTotalsRow = $showTotalsRow;
158146

@@ -161,18 +149,14 @@ public function setShowTotalsRow(bool $showTotalsRow)
161149

162150
/**
163151
* Get Table Range.
164-
*
165-
* @return string
166152
*/
167-
public function getRange()
153+
public function getRange(): string
168154
{
169155
return $this->range;
170156
}
171157

172158
/**
173159
* Set Table Cell Range.
174-
*
175-
* @return $this
176160
*/
177161
public function setRange(string $range): self
178162
{
@@ -210,8 +194,6 @@ public function setRange(string $range): self
210194

211195
/**
212196
* Set Table Cell Range to max row.
213-
*
214-
* @return $this
215197
*/
216198
public function setRangeToMaxRow(): self
217199
{
@@ -228,20 +210,16 @@ public function setRangeToMaxRow(): self
228210

229211
/**
230212
* Get Table's Worksheet.
231-
*
232-
* @return null|Worksheet
233213
*/
234-
public function getWorksheet()
214+
public function getWorksheet(): ?Worksheet
235215
{
236216
return $this->workSheet;
237217
}
238218

239219
/**
240220
* Set Table's Worksheet.
241-
*
242-
* @return $this
243221
*/
244-
public function setWorksheet(?Worksheet $worksheet = null)
222+
public function setWorksheet(?Worksheet $worksheet = null): self
245223
{
246224
if ($this->name !== '' && $worksheet !== null) {
247225
$spreadsheet = $worksheet->getParent();
@@ -265,7 +243,7 @@ public function setWorksheet(?Worksheet $worksheet = null)
265243
*
266244
* @return Table\Column[]
267245
*/
268-
public function getColumns()
246+
public function getColumns(): array
269247
{
270248
return $this->columns;
271249
}
@@ -277,7 +255,7 @@ public function getColumns()
277255
*
278256
* @return int The column offset within the table range
279257
*/
280-
public function isColumnInRange($column)
258+
public function isColumnInRange(string $column): int
281259
{
282260
if (empty($this->range)) {
283261
throw new PhpSpreadsheetException('No table range is defined.');
@@ -299,7 +277,7 @@ public function isColumnInRange($column)
299277
*
300278
* @return int The offset of the specified column within the table range
301279
*/
302-
public function getColumnOffset($column)
280+
public function getColumnOffset($column): int
303281
{
304282
return $this->isColumnInRange($column);
305283
}
@@ -308,10 +286,8 @@ public function getColumnOffset($column)
308286
* Get a specified Table Column.
309287
*
310288
* @param string $column Column name (e.g. A)
311-
*
312-
* @return Table\Column
313289
*/
314-
public function getColumn($column)
290+
public function getColumn($column): Table\Column
315291
{
316292
$this->isColumnInRange($column);
317293

@@ -326,10 +302,8 @@ public function getColumn($column)
326302
* Get a specified Table Column by it's offset.
327303
*
328304
* @param int $columnOffset Column offset within range (starting from 0)
329-
*
330-
* @return Table\Column
331305
*/
332-
public function getColumnByOffset($columnOffset)
306+
public function getColumnByOffset($columnOffset): Table\Column
333307
{
334308
[$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range);
335309
$pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset);
@@ -342,10 +316,8 @@ public function getColumnByOffset($columnOffset)
342316
*
343317
* @param string|Table\Column $columnObjectOrString
344318
* A simple string containing a Column ID like 'A' is permitted
345-
*
346-
* @return $this
347319
*/
348-
public function setColumn($columnObjectOrString)
320+
public function setColumn($columnObjectOrString): self
349321
{
350322
if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) {
351323
$column = $columnObjectOrString;
@@ -371,10 +343,8 @@ public function setColumn($columnObjectOrString)
371343
* Clear a specified Table Column.
372344
*
373345
* @param string $column Column name (e.g. A)
374-
*
375-
* @return $this
376346
*/
377-
public function clearColumn($column)
347+
public function clearColumn($column): self
378348
{
379349
$this->isColumnInRange($column);
380350

@@ -394,10 +364,8 @@ public function clearColumn($column)
394364
*
395365
* @param string $fromColumn Column name (e.g. A)
396366
* @param string $toColumn Column name (e.g. B)
397-
*
398-
* @return $this
399367
*/
400-
public function shiftColumn($fromColumn, $toColumn)
368+
public function shiftColumn($fromColumn, $toColumn): self
401369
{
402370
$fromColumn = strtoupper($fromColumn);
403371
$toColumn = strtoupper($toColumn);
@@ -417,20 +385,16 @@ public function shiftColumn($fromColumn, $toColumn)
417385

418386
/**
419387
* Get table Style.
420-
*
421-
* @return TableStyle
422388
*/
423-
public function getStyle()
389+
public function getStyle(): Table\TableStyle
424390
{
425391
return $this->style;
426392
}
427393

428394
/**
429395
* Set table Style.
430-
*
431-
* @return $this
432396
*/
433-
public function setStyle(TableStyle $style)
397+
public function setStyle(TableStyle $style): self
434398
{
435399
$this->style = $style;
436400

src/PhpSpreadsheet/Worksheet/Table/Column.php

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ public function __construct($column, ?Table $table = null)
6969

7070
/**
7171
* Get Table column index as string eg: 'A'.
72-
*
73-
* @return string
7472
*/
75-
public function getColumnIndex()
73+
public function getColumnIndex(): string
7674
{
7775
return $this->columnIndex;
7876
}
@@ -81,10 +79,8 @@ public function getColumnIndex()
8179
* Set Table column index as string eg: 'A'.
8280
*
8381
* @param string $column Column (e.g. A)
84-
*
85-
* @return $this
8682
*/
87-
public function setColumnIndex($column)
83+
public function setColumnIndex($column): self
8884
{
8985
// Uppercase coordinate
9086
$column = strtoupper($column);
@@ -99,20 +95,16 @@ public function setColumnIndex($column)
9995

10096
/**
10197
* Get show Filter Button.
102-
*
103-
* @return bool
10498
*/
105-
public function getShowFilterButton()
99+
public function getShowFilterButton(): bool
106100
{
107101
return $this->showFilterButton;
108102
}
109103

110104
/**
111105
* Set show Filter Button.
112-
*
113-
* @return $this
114106
*/
115-
public function setShowFilterButton(bool $showFilterButton)
107+
public function setShowFilterButton(bool $showFilterButton): self
116108
{
117109
$this->showFilterButton = $showFilterButton;
118110

@@ -121,20 +113,16 @@ public function setShowFilterButton(bool $showFilterButton)
121113

122114
/**
123115
* Get total Row Label.
124-
*
125-
* @return string
126116
*/
127-
public function getTotalsRowLabel()
117+
public function getTotalsRowLabel(): ?string
128118
{
129119
return $this->totalsRowLabel;
130120
}
131121

132122
/**
133123
* Set total Row Label.
134-
*
135-
* @return $this
136124
*/
137-
public function setTotalsRowLabel(string $totalsRowLabel)
125+
public function setTotalsRowLabel(string $totalsRowLabel): self
138126
{
139127
$this->totalsRowLabel = $totalsRowLabel;
140128

@@ -143,20 +131,16 @@ public function setTotalsRowLabel(string $totalsRowLabel)
143131

144132
/**
145133
* Get total Row Function.
146-
*
147-
* @return string
148134
*/
149-
public function getTotalsRowFunction()
135+
public function getTotalsRowFunction(): ?string
150136
{
151137
return $this->totalsRowFunction;
152138
}
153139

154140
/**
155141
* Set total Row Function.
156-
*
157-
* @return $this
158142
*/
159-
public function setTotalsRowFunction(string $totalsRowFunction)
143+
public function setTotalsRowFunction(string $totalsRowFunction): self
160144
{
161145
$this->totalsRowFunction = $totalsRowFunction;
162146

@@ -165,20 +149,16 @@ public function setTotalsRowFunction(string $totalsRowFunction)
165149

166150
/**
167151
* Get total Row Formula.
168-
*
169-
* @return string
170152
*/
171-
public function getTotalsRowFormula()
153+
public function getTotalsRowFormula(): ?string
172154
{
173155
return $this->totalsRowFormula;
174156
}
175157

176158
/**
177159
* Set total Row Formula.
178-
*
179-
* @return $this
180160
*/
181-
public function setTotalsRowFormula(string $totalsRowFormula)
161+
public function setTotalsRowFormula(string $totalsRowFormula): self
182162
{
183163
$this->totalsRowFormula = $totalsRowFormula;
184164

@@ -187,20 +167,16 @@ public function setTotalsRowFormula(string $totalsRowFormula)
187167

188168
/**
189169
* Get column Formula.
190-
*
191-
* @return string
192170
*/
193-
public function getColumnFormula()
171+
public function getColumnFormula(): ?string
194172
{
195173
return $this->columnFormula;
196174
}
197175

198176
/**
199177
* Set column Formula.
200-
*
201-
* @return $this
202178
*/
203-
public function setColumnFormula(string $columnFormula)
179+
public function setColumnFormula(string $columnFormula): self
204180
{
205181
$this->columnFormula = $columnFormula;
206182

@@ -209,20 +185,16 @@ public function setColumnFormula(string $columnFormula)
209185

210186
/**
211187
* Get this Column's Table.
212-
*
213-
* @return null|Table
214188
*/
215-
public function getTable()
189+
public function getTable(): ?Table
216190
{
217191
return $this->table;
218192
}
219193

220194
/**
221195
* Set this Column's Table.
222-
*
223-
* @return $this
224196
*/
225-
public function setTable(?Table $table = null)
197+
public function setTable(?Table $table = null): self
226198
{
227199
$this->table = $table;
228200

0 commit comments

Comments
 (0)