Skip to content

Commit bd0462b

Browse files
author
MarkBaker
committed
Work on renaming method arguments for the Readers and Writers
1 parent 0acc8ff commit bd0462b

33 files changed

+182
-180
lines changed

samples/Basic/24_Readfilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class MyReadFilter implements IReadFilter
2020
{
21-
public function readCell($column, $row, $worksheetName = '')
21+
public function readCell($columnAddress, $row, $worksheetName = '')
2222
{
2323
// Read title row and rows 20 - 30
2424
if ($row == 1 || ($row >= 20 && $row <= 30)) {

samples/Reader/09_Simple_file_reader_using_a_read_filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
class MyReadFilter implements IReadFilter
1515
{
16-
public function readCell($column, $row, $worksheetName = '')
16+
public function readCell($columnAddress, $row, $worksheetName = '')
1717
{
1818
// Read rows 1 to 7 and columns A to E only
1919
if ($row >= 1 && $row <= 7) {
20-
if (in_array($column, range('A', 'E'))) {
20+
if (in_array($columnAddress, range('A', 'E'))) {
2121
return true;
2222
}
2323
}

samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function __construct($startRow, $endRow, $columns)
2626
$this->columns = $columns;
2727
}
2828

29-
public function readCell($column, $row, $worksheetName = '')
29+
public function readCell($columnAddress, $row, $worksheetName = '')
3030
{
3131
if ($row >= $this->startRow && $row <= $this->endRow) {
32-
if (in_array($column, $this->columns)) {
32+
if (in_array($columnAddress, $this->columns)) {
3333
return true;
3434
}
3535
}

samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct($startRow, $chunkSize)
2929
$this->endRow = $startRow + $chunkSize;
3030
}
3131

32-
public function readCell($column, $row, $worksheetName = '')
32+
public function readCell($columnAddress, $row, $worksheetName = '')
3333
{
3434
// Only read the heading row, and the rows that were configured in the constructor
3535
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {

samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setRows($startRow, $chunkSize): void
2929
$this->endRow = $startRow + $chunkSize;
3030
}
3131

32-
public function readCell($column, $row, $worksheetName = '')
32+
public function readCell($columnAddress, $row, $worksheetName = '')
3333
{
3434
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
3535
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {

samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setRows($startRow, $chunkSize): void
3030
$this->endRow = $startRow + $chunkSize;
3131
}
3232

33-
public function readCell($column, $row, $worksheetName = '')
33+
public function readCell($columnAddress, $row, $worksheetName = '')
3434
{
3535
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
3636
if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) {

src/PhpSpreadsheet/Reader/BaseReader.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public function getReadDataOnly()
6666
return $this->readDataOnly;
6767
}
6868

69-
public function setReadDataOnly($pValue)
69+
public function setReadDataOnly($readCellValuesOnly)
7070
{
71-
$this->readDataOnly = (bool) $pValue;
71+
$this->readDataOnly = (bool) $readCellValuesOnly;
7272

7373
return $this;
7474
}
@@ -78,9 +78,9 @@ public function getReadEmptyCells()
7878
return $this->readEmptyCells;
7979
}
8080

81-
public function setReadEmptyCells($pValue)
81+
public function setReadEmptyCells($readEmptyCells)
8282
{
83-
$this->readEmptyCells = (bool) $pValue;
83+
$this->readEmptyCells = (bool) $readEmptyCells;
8484

8585
return $this;
8686
}
@@ -90,9 +90,9 @@ public function getIncludeCharts()
9090
return $this->includeCharts;
9191
}
9292

93-
public function setIncludeCharts($pValue)
93+
public function setIncludeCharts($includeCharts)
9494
{
95-
$this->includeCharts = (bool) $pValue;
95+
$this->includeCharts = (bool) $includeCharts;
9696

9797
return $this;
9898
}
@@ -102,13 +102,13 @@ public function getLoadSheetsOnly()
102102
return $this->loadSheetsOnly;
103103
}
104104

105-
public function setLoadSheetsOnly($value)
105+
public function setLoadSheetsOnly($sheetList)
106106
{
107-
if ($value === null) {
107+
if ($sheetList === null) {
108108
return $this->setLoadAllSheets();
109109
}
110110

111-
$this->loadSheetsOnly = is_array($value) ? $value : [$value];
111+
$this->loadSheetsOnly = is_array($sheetList) ? $sheetList : [$sheetList];
112112

113113
return $this;
114114
}
@@ -125,9 +125,9 @@ public function getReadFilter()
125125
return $this->readFilter;
126126
}
127127

128-
public function setReadFilter(IReadFilter $pValue)
128+
public function setReadFilter(IReadFilter $readFilter)
129129
{
130-
$this->readFilter = $pValue;
130+
$this->readFilter = $readFilter;
131131

132132
return $this;
133133
}
@@ -140,22 +140,22 @@ public function getSecurityScanner()
140140
/**
141141
* Open file for reading.
142142
*
143-
* @param string $pFilename
143+
* @param string $filename
144144
*/
145-
protected function openFile($pFilename): void
145+
protected function openFile($filename): void
146146
{
147-
if ($pFilename) {
148-
File::assertFile($pFilename);
147+
if ($filename) {
148+
File::assertFile($filename);
149149

150150
// Open file
151-
$fileHandle = fopen($pFilename, 'rb');
151+
$fileHandle = fopen($filename, 'rb');
152152
} else {
153153
$fileHandle = false;
154154
}
155155
if ($fileHandle !== false) {
156156
$this->fileHandle = $fileHandle;
157157
} else {
158-
throw new ReaderException('Could not open file ' . $pFilename . ' for reading.');
158+
throw new ReaderException('Could not open file ' . $filename . ' for reading.');
159159
}
160160
}
161161
}

src/PhpSpreadsheet/Reader/Csv.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public function __construct()
6262
/**
6363
* Set input encoding.
6464
*
65-
* @param string $pValue Input encoding, eg: 'UTF-8'
65+
* @param string $encoding Input encoding, eg: 'UTF-8'
6666
*
6767
* @return $this
6868
*/
69-
public function setInputEncoding($pValue)
69+
public function setInputEncoding($encoding)
7070
{
71-
$this->inputEncoding = $pValue;
71+
$this->inputEncoding = $encoding;
7272

7373
return $this;
7474
}
@@ -240,14 +240,14 @@ private function getNextLine()
240240
/**
241241
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns).
242242
*
243-
* @param string $pFilename
243+
* @param string $filename
244244
*
245245
* @return array
246246
*/
247-
public function listWorksheetInfo($pFilename)
247+
public function listWorksheetInfo($filename)
248248
{
249249
// Open file
250-
$this->openFileOrMemory($pFilename);
250+
$this->openFileOrMemory($filename);
251251
$fileHandle = $this->fileHandle;
252252

253253
// Skip BOM, if any
@@ -280,30 +280,30 @@ public function listWorksheetInfo($pFilename)
280280
/**
281281
* Loads Spreadsheet from file.
282282
*
283-
* @param string $pFilename
283+
* @param string $filename
284284
*
285285
* @return Spreadsheet
286286
*/
287-
public function load($pFilename)
287+
public function load($filename)
288288
{
289289
// Create new Spreadsheet
290290
$spreadsheet = new Spreadsheet();
291291

292292
// Load into this instance
293-
return $this->loadIntoExisting($pFilename, $spreadsheet);
293+
return $this->loadIntoExisting($filename, $spreadsheet);
294294
}
295295

296-
private function openFileOrMemory($pFilename): void
296+
private function openFileOrMemory($filename): void
297297
{
298298
// Open file
299-
$fhandle = $this->canRead($pFilename);
299+
$fhandle = $this->canRead($filename);
300300
if (!$fhandle) {
301-
throw new Exception($pFilename . ' is an Invalid Spreadsheet file.');
301+
throw new Exception($filename . ' is an Invalid Spreadsheet file.');
302302
}
303-
$this->openFile($pFilename);
303+
$this->openFile($filename);
304304
if ($this->inputEncoding !== 'UTF-8') {
305305
fclose($this->fileHandle);
306-
$entireFile = file_get_contents($pFilename);
306+
$entireFile = file_get_contents($filename);
307307
$this->fileHandle = fopen('php://memory', 'r+b');
308308
$data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding);
309309
fwrite($this->fileHandle, $data);
@@ -314,17 +314,17 @@ private function openFileOrMemory($pFilename): void
314314
/**
315315
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
316316
*
317-
* @param string $pFilename
317+
* @param string $filename
318318
*
319319
* @return Spreadsheet
320320
*/
321-
public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet)
321+
public function loadIntoExisting($filename, Spreadsheet $spreadsheet)
322322
{
323323
$lineEnding = ini_get('auto_detect_line_endings');
324324
ini_set('auto_detect_line_endings', true);
325325

326326
// Open file
327-
$this->openFileOrMemory($pFilename);
327+
$this->openFileOrMemory($filename);
328328
$fileHandle = $this->fileHandle;
329329

330330
// Skip BOM, if any
@@ -437,13 +437,13 @@ public function getSheetIndex()
437437
/**
438438
* Set sheet index.
439439
*
440-
* @param int $pValue Sheet index
440+
* @param int $indexValue Sheet index
441441
*
442442
* @return $this
443443
*/
444-
public function setSheetIndex($pValue)
444+
public function setSheetIndex($indexValue)
445445
{
446-
$this->sheetIndex = $pValue;
446+
$this->sheetIndex = $indexValue;
447447

448448
return $this;
449449
}
@@ -499,29 +499,29 @@ public function getEscapeCharacter()
499499
/**
500500
* Can the current IReader read the file?
501501
*
502-
* @param string $pFilename
502+
* @param string $filename
503503
*
504504
* @return bool
505505
*/
506-
public function canRead($pFilename)
506+
public function canRead($filename)
507507
{
508508
// Check if file exists
509509
try {
510-
$this->openFile($pFilename);
510+
$this->openFile($filename);
511511
} catch (InvalidArgumentException $e) {
512512
return false;
513513
}
514514

515515
fclose($this->fileHandle);
516516

517517
// Trust file extension if any
518-
$extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION));
518+
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
519519
if (in_array($extension, ['csv', 'tsv'])) {
520520
return true;
521521
}
522522

523523
// Attempt to guess mimetype
524-
$type = mime_content_type($pFilename);
524+
$type = mime_content_type($filename);
525525
$supportedTypes = [
526526
'application/csv',
527527
'text/csv',

src/PhpSpreadsheet/Reader/DefaultReadFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ class DefaultReadFilter implements IReadFilter
77
/**
88
* Should this cell be read?
99
*
10-
* @param string $column Column address (as a string value like "A", or "IV")
10+
* @param string $columnAddress Column address (as a string value like "A", or "IV")
1111
* @param int $row Row number
1212
* @param string $worksheetName Optional worksheet name
1313
*
1414
* @return bool
1515
*/
16-
public function readCell($column, $row, $worksheetName = '')
16+
public function readCell($columnAddress, $row, $worksheetName = '')
1717
{
1818
return true;
1919
}

src/PhpSpreadsheet/Reader/Gnumeric.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ public function __construct()
6363
/**
6464
* Can the current IReader read the file?
6565
*
66-
* @param string $pFilename
66+
* @param string $filename
6767
*
6868
* @return bool
6969
*/
70-
public function canRead($pFilename)
70+
public function canRead($filename)
7171
{
72-
File::assertFile($pFilename);
72+
File::assertFile($filename);
7373

7474
// Check if gzlib functions are available
7575
$data = '';
7676
if (function_exists('gzread')) {
7777
// Read signature data (first 3 bytes)
78-
$fh = fopen($pFilename, 'rb');
78+
$fh = fopen($filename, 'rb');
7979
$data = fread($fh, 2);
8080
fclose($fh);
8181
}
@@ -420,18 +420,18 @@ private function processComments(SimpleXMLElement $sheet): void
420420
/**
421421
* Loads Spreadsheet from file.
422422
*
423-
* @param string $pFilename
423+
* @param string $filename
424424
*
425425
* @return Spreadsheet
426426
*/
427-
public function load($pFilename)
427+
public function load($filename)
428428
{
429429
// Create new Spreadsheet
430430
$spreadsheet = new Spreadsheet();
431431
$spreadsheet->removeSheetByIndex(0);
432432

433433
// Load into this instance
434-
return $this->loadIntoExisting($pFilename, $spreadsheet);
434+
return $this->loadIntoExisting($filename, $spreadsheet);
435435
}
436436

437437
/**

0 commit comments

Comments
 (0)