From bd0462bcfcff091b16b85ff8f0a163ba3b15cb8d Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 19 Nov 2020 16:41:52 +0100 Subject: [PATCH] Work on renaming method arguments for the Readers and Writers --- samples/Basic/24_Readfilter.php | 2 +- ...Simple_file_reader_using_a_read_filter.php | 4 +- ...eader_using_a_configurable_read_filter.php | 4 +- ...a_configurable_read_filter_(version_1).php | 2 +- ...a_configurable_read_filter_(version_2).php | 2 +- ...ks_to_split_across_multiple_worksheets.php | 2 +- src/PhpSpreadsheet/Reader/BaseReader.php | 34 ++++++------- src/PhpSpreadsheet/Reader/Csv.php | 50 +++++++++---------- .../Reader/DefaultReadFilter.php | 4 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 14 +++--- src/PhpSpreadsheet/Reader/Html.php | 12 ++--- src/PhpSpreadsheet/Reader/IReadFilter.php | 4 +- src/PhpSpreadsheet/Reader/IReader.php | 26 +++++----- src/PhpSpreadsheet/Reader/Ods.php | 14 +++--- src/PhpSpreadsheet/Reader/Slk.php | 12 ++--- src/PhpSpreadsheet/Reader/Xls.php | 14 +++--- src/PhpSpreadsheet/Reader/Xlsx.php | 22 ++++---- src/PhpSpreadsheet/Reader/Xml.php | 12 ++--- src/PhpSpreadsheet/Writer/BaseWriter.php | 20 ++++---- src/PhpSpreadsheet/Writer/Csv.php | 6 +-- src/PhpSpreadsheet/Writer/Html.php | 6 +-- src/PhpSpreadsheet/Writer/IWriter.php | 20 ++++---- src/PhpSpreadsheet/Writer/Ods.php | 6 +-- src/PhpSpreadsheet/Writer/Pdf.php | 28 +++++------ src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 6 +-- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 6 +-- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 8 +-- src/PhpSpreadsheet/Writer/Xls.php | 6 +-- src/PhpSpreadsheet/Writer/Xlsx.php | 6 +-- .../Reader/CsvContiguousFilter.php | 2 +- .../Reader/Gnumeric/GnumericFilter.php | 2 +- .../Reader/OddColumnReadFilter.php | 4 +- .../Reader/Xml/XmlFilter.php | 2 +- 33 files changed, 182 insertions(+), 180 deletions(-) diff --git a/samples/Basic/24_Readfilter.php b/samples/Basic/24_Readfilter.php index ab1c2e41..e5b613a6 100644 --- a/samples/Basic/24_Readfilter.php +++ b/samples/Basic/24_Readfilter.php @@ -18,7 +18,7 @@ $helper->logWrite($writer, $filename, $callStartTime); class MyReadFilter implements IReadFilter { - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { // Read title row and rows 20 - 30 if ($row == 1 || ($row >= 20 && $row <= 30)) { diff --git a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php index 6e0eda14..04c47c64 100644 --- a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php +++ b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php @@ -13,11 +13,11 @@ $sheetname = 'Data Sheet #3'; class MyReadFilter implements IReadFilter { - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { // Read rows 1 to 7 and columns A to E only if ($row >= 1 && $row <= 7) { - if (in_array($column, range('A', 'E'))) { + if (in_array($columnAddress, range('A', 'E'))) { return true; } } diff --git a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php index 7b3fc440..6a600d43 100644 --- a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php +++ b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php @@ -26,10 +26,10 @@ class MyReadFilter implements IReadFilter $this->columns = $columns; } - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { if ($row >= $this->startRow && $row <= $this->endRow) { - if (in_array($column, $this->columns)) { + if (in_array($columnAddress, $this->columns)) { return true; } } diff --git a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php index 18562217..6c908703 100644 --- a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php +++ b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php @@ -29,7 +29,7 @@ class ChunkReadFilter implements IReadFilter $this->endRow = $startRow + $chunkSize; } - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { // Only read the heading row, and the rows that were configured in the constructor if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php index 61f624b2..c594c798 100644 --- a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php +++ b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php @@ -29,7 +29,7 @@ class ChunkReadFilter implements IReadFilter $this->endRow = $startRow + $chunkSize; } - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php index 02d3d939..87fbb225 100644 --- a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php +++ b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php @@ -30,7 +30,7 @@ class ChunkReadFilter implements IReadFilter $this->endRow = $startRow + $chunkSize; } - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index eb0e3ba2..9804b57b 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -66,9 +66,9 @@ abstract class BaseReader implements IReader return $this->readDataOnly; } - public function setReadDataOnly($pValue) + public function setReadDataOnly($readCellValuesOnly) { - $this->readDataOnly = (bool) $pValue; + $this->readDataOnly = (bool) $readCellValuesOnly; return $this; } @@ -78,9 +78,9 @@ abstract class BaseReader implements IReader return $this->readEmptyCells; } - public function setReadEmptyCells($pValue) + public function setReadEmptyCells($readEmptyCells) { - $this->readEmptyCells = (bool) $pValue; + $this->readEmptyCells = (bool) $readEmptyCells; return $this; } @@ -90,9 +90,9 @@ abstract class BaseReader implements IReader return $this->includeCharts; } - public function setIncludeCharts($pValue) + public function setIncludeCharts($includeCharts) { - $this->includeCharts = (bool) $pValue; + $this->includeCharts = (bool) $includeCharts; return $this; } @@ -102,13 +102,13 @@ abstract class BaseReader implements IReader return $this->loadSheetsOnly; } - public function setLoadSheetsOnly($value) + public function setLoadSheetsOnly($sheetList) { - if ($value === null) { + if ($sheetList === null) { return $this->setLoadAllSheets(); } - $this->loadSheetsOnly = is_array($value) ? $value : [$value]; + $this->loadSheetsOnly = is_array($sheetList) ? $sheetList : [$sheetList]; return $this; } @@ -125,9 +125,9 @@ abstract class BaseReader implements IReader return $this->readFilter; } - public function setReadFilter(IReadFilter $pValue) + public function setReadFilter(IReadFilter $readFilter) { - $this->readFilter = $pValue; + $this->readFilter = $readFilter; return $this; } @@ -140,22 +140,22 @@ abstract class BaseReader implements IReader /** * Open file for reading. * - * @param string $pFilename + * @param string $filename */ - protected function openFile($pFilename): void + protected function openFile($filename): void { - if ($pFilename) { - File::assertFile($pFilename); + if ($filename) { + File::assertFile($filename); // Open file - $fileHandle = fopen($pFilename, 'rb'); + $fileHandle = fopen($filename, 'rb'); } else { $fileHandle = false; } if ($fileHandle !== false) { $this->fileHandle = $fileHandle; } else { - throw new ReaderException('Could not open file ' . $pFilename . ' for reading.'); + throw new ReaderException('Could not open file ' . $filename . ' for reading.'); } } } diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index d6eb16b0..3fd95e14 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -62,13 +62,13 @@ class Csv extends BaseReader /** * Set input encoding. * - * @param string $pValue Input encoding, eg: 'UTF-8' + * @param string $encoding Input encoding, eg: 'UTF-8' * * @return $this */ - public function setInputEncoding($pValue) + public function setInputEncoding($encoding) { - $this->inputEncoding = $pValue; + $this->inputEncoding = $encoding; return $this; } @@ -240,14 +240,14 @@ class Csv extends BaseReader /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). * - * @param string $pFilename + * @param string $filename * * @return array */ - public function listWorksheetInfo($pFilename) + public function listWorksheetInfo($filename) { // Open file - $this->openFileOrMemory($pFilename); + $this->openFileOrMemory($filename); $fileHandle = $this->fileHandle; // Skip BOM, if any @@ -280,30 +280,30 @@ class Csv extends BaseReader /** * Loads Spreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } - private function openFileOrMemory($pFilename): void + private function openFileOrMemory($filename): void { // Open file - $fhandle = $this->canRead($pFilename); + $fhandle = $this->canRead($filename); if (!$fhandle) { - throw new Exception($pFilename . ' is an Invalid Spreadsheet file.'); + throw new Exception($filename . ' is an Invalid Spreadsheet file.'); } - $this->openFile($pFilename); + $this->openFile($filename); if ($this->inputEncoding !== 'UTF-8') { fclose($this->fileHandle); - $entireFile = file_get_contents($pFilename); + $entireFile = file_get_contents($filename); $this->fileHandle = fopen('php://memory', 'r+b'); $data = StringHelper::convertEncoding($entireFile, 'UTF-8', $this->inputEncoding); fwrite($this->fileHandle, $data); @@ -314,17 +314,17 @@ class Csv extends BaseReader /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function loadIntoExisting($pFilename, Spreadsheet $spreadsheet) + public function loadIntoExisting($filename, Spreadsheet $spreadsheet) { $lineEnding = ini_get('auto_detect_line_endings'); ini_set('auto_detect_line_endings', true); // Open file - $this->openFileOrMemory($pFilename); + $this->openFileOrMemory($filename); $fileHandle = $this->fileHandle; // Skip BOM, if any @@ -437,13 +437,13 @@ class Csv extends BaseReader /** * Set sheet index. * - * @param int $pValue Sheet index + * @param int $indexValue Sheet index * * @return $this */ - public function setSheetIndex($pValue) + public function setSheetIndex($indexValue) { - $this->sheetIndex = $pValue; + $this->sheetIndex = $indexValue; return $this; } @@ -499,15 +499,15 @@ class Csv extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { // Check if file exists try { - $this->openFile($pFilename); + $this->openFile($filename); } catch (InvalidArgumentException $e) { return false; } @@ -515,13 +515,13 @@ class Csv extends BaseReader fclose($this->fileHandle); // Trust file extension if any - $extension = strtolower(pathinfo($pFilename, PATHINFO_EXTENSION)); + $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (in_array($extension, ['csv', 'tsv'])) { return true; } // Attempt to guess mimetype - $type = mime_content_type($pFilename); + $type = mime_content_type($filename); $supportedTypes = [ 'application/csv', 'text/csv', diff --git a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php index e104186a..8fdb162b 100644 --- a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php +++ b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php @@ -7,13 +7,13 @@ class DefaultReadFilter implements IReadFilter /** * Should this cell be read? * - * @param string $column Column address (as a string value like "A", or "IV") + * @param string $columnAddress Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name * * @return bool */ - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { return true; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index dc921c1e..7f583663 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -63,19 +63,19 @@ class Gnumeric extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { - File::assertFile($pFilename); + File::assertFile($filename); // Check if gzlib functions are available $data = ''; if (function_exists('gzread')) { // Read signature data (first 3 bytes) - $fh = fopen($pFilename, 'rb'); + $fh = fopen($filename, 'rb'); $data = fread($fh, 2); fclose($fh); } @@ -420,18 +420,18 @@ class Gnumeric extends BaseReader /** * Loads Spreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); $spreadsheet->removeSheetByIndex(0); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } /** diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 73f4591e..ed58fb51 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -136,15 +136,15 @@ class Html extends BaseReader /** * Validate that the current file is an HTML file. * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { // Check if file exists try { - $this->openFile($pFilename); + $this->openFile($filename); } catch (Exception $e) { return false; } @@ -204,17 +204,17 @@ class Html extends BaseReader /** * Loads Spreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } /** diff --git a/src/PhpSpreadsheet/Reader/IReadFilter.php b/src/PhpSpreadsheet/Reader/IReadFilter.php index ccfe05ad..9f68a7f3 100644 --- a/src/PhpSpreadsheet/Reader/IReadFilter.php +++ b/src/PhpSpreadsheet/Reader/IReadFilter.php @@ -7,11 +7,11 @@ interface IReadFilter /** * Should this cell be read? * - * @param string $column Column address (as a string value like "A", or "IV") + * @param string $columnAddress Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name * * @return bool */ - public function readCell($column, $row, $worksheetName = ''); + public function readCell($columnAddress, $row, $worksheetName = ''); } diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index a8bd3606..bbbc1ec3 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -12,11 +12,11 @@ interface IReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename); + public function canRead($filename); /** * Read data only? @@ -32,11 +32,11 @@ interface IReader * Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information. * Set to false (the default) to advise the Reader to read both data and formatting for cells. * - * @param bool $pValue + * @param bool $readCellValuesOnly * * @return IReader */ - public function setReadDataOnly($pValue); + public function setReadDataOnly($readCellValuesOnly); /** * Read empty cells? @@ -52,11 +52,11 @@ interface IReader * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. * Set to false to advise the Reader to ignore cells containing a null value or an empty string. * - * @param bool $pValue + * @param bool $readEmptyCells * * @return IReader */ - public function setReadEmptyCells($pValue); + public function setReadEmptyCells($readEmptyCells); /** * Read charts in workbook? @@ -74,11 +74,11 @@ interface IReader * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. * Set to false (the default) to discard charts. * - * @param bool $pValue + * @param bool $includeCharts * * @return IReader */ - public function setIncludeCharts($pValue); + public function setIncludeCharts($includeCharts); /** * Get which sheets to load @@ -92,13 +92,13 @@ interface IReader /** * Set which sheets to load. * - * @param mixed $value + * @param mixed $sheetList * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. * If NULL, then it tells the Reader to read all worksheets in the workbook * * @return IReader */ - public function setLoadSheetsOnly($value); + public function setLoadSheetsOnly($sheetList); /** * Set all sheets to load @@ -120,14 +120,14 @@ interface IReader * * @return IReader */ - public function setReadFilter(IReadFilter $pValue); + public function setReadFilter(IReadFilter $readFilter); /** * Loads PhpSpreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return \PhpOffice\PhpSpreadsheet\Spreadsheet */ - public function load($pFilename); + public function load($filename); } diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 4ceac653..668176d1 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -40,20 +40,20 @@ class Ods extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { - File::assertFile($pFilename); + File::assertFile($filename); $mimeType = 'UNKNOWN'; // Load file $zip = new ZipArchive(); - if ($zip->open($pFilename) === true) { + if ($zip->open($filename) === true) { // check if it is an OOXML archive $stat = $zip->statName('mimetype'); if ($stat && ($stat['size'] <= 255)) { @@ -231,17 +231,17 @@ class Ods extends BaseReader /** * Loads PhpSpreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } /** diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 0e147376..5f1ff250 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -65,14 +65,14 @@ class Slk extends BaseReader /** * Validate that the current file is a SYLK file. * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { try { - $this->openFile($pFilename); + $this->openFile($filename); } catch (InvalidArgumentException $e) { return false; } @@ -196,17 +196,17 @@ class Slk extends BaseReader /** * Loads PhpSpreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } private $colorArray = [ diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index b5c92d8d..d9ac6410 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -418,20 +418,20 @@ class Xls extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { - File::assertFile($pFilename); + File::assertFile($filename); try { // Use ParseXL for the hard work. $ole = new OLERead(); // get excel data - $ole->read($pFilename); + $ole->read($filename); return true; } catch (PhpSpreadsheetException $e) { @@ -621,14 +621,14 @@ class Xls extends BaseReader /** * Loads PhpSpreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Read the OLE file - $this->loadOLE($pFilename); + $this->loadOLE($filename); // Initialisations $this->spreadsheet = new Spreadsheet(); diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 22584c51..aaf6c56b 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -69,18 +69,18 @@ class Xlsx extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { - File::assertFile($pFilename); + File::assertFile($filename); $result = false; $zip = new ZipArchive(); - if ($zip->open($pFilename) === true) { + if ($zip->open($filename) === true) { $workbookBasename = $this->getWorkbookBaseName($zip); $result = !empty($workbookBasename); @@ -311,13 +311,13 @@ class Xlsx extends BaseReader /** * Loads Spreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { - File::assertFile($pFilename); + File::assertFile($filename); // Initialisations $excel = new Spreadsheet(); @@ -329,7 +329,7 @@ class Xlsx extends BaseReader $unparsedLoadedData = []; $zip = new ZipArchive(); - $zip->open($pFilename); + $zip->open($filename); // Read the theme first, because we need the colour scheme when reading the styles //~ http://schemas.openxmlformats.org/package/2006/relationships" @@ -1036,7 +1036,7 @@ class Xlsx extends BaseReader $hfImages[(string) $shape['id']]->setName((string) $imageData['title']); } - $hfImages[(string) $shape['id']]->setPath('zip://' . File::realpath($pFilename) . '#' . $drawings[(string) $imageData['relid']], false); + $hfImages[(string) $shape['id']]->setPath('zip://' . File::realpath($filename) . '#' . $drawings[(string) $imageData['relid']], false); $hfImages[(string) $shape['id']]->setResizeProportional(false); $hfImages[(string) $shape['id']]->setWidth($style['width']); $hfImages[(string) $shape['id']]->setHeight($style['height']); @@ -1124,7 +1124,7 @@ class Xlsx extends BaseReader $objDrawing->setName((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name')); $objDrawing->setDescription((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr')); $objDrawing->setPath( - 'zip://' . File::realpath($pFilename) . '#' . + 'zip://' . File::realpath($filename) . '#' . $images[(string) self::getArrayItem( $blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'embed' @@ -1176,7 +1176,7 @@ class Xlsx extends BaseReader $objDrawing->setName((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'name')); $objDrawing->setDescription((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), 'descr')); $objDrawing->setPath( - 'zip://' . File::realpath($pFilename) . '#' . + 'zip://' . File::realpath($filename) . '#' . $images[(string) self::getArrayItem( $blip->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'embed' diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index e4d251e2..97e85790 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -96,11 +96,11 @@ class Xml extends BaseReader /** * Can the current IReader read the file? * - * @param string $pFilename + * @param string $filename * * @return bool */ - public function canRead($pFilename) + public function canRead($filename) { // Office xmlns:o="urn:schemas-microsoft-com:office:office" // Excel xmlns:x="urn:schemas-microsoft-com:office:excel" @@ -118,7 +118,7 @@ class Xml extends BaseReader ]; // Open file - $data = file_get_contents($pFilename); + $data = file_get_contents($filename); // Why? //$data = str_replace("'", '"', $data); // fix headers with single quote @@ -272,18 +272,18 @@ class Xml extends BaseReader /** * Loads Spreadsheet from file. * - * @param string $pFilename + * @param string $filename * * @return Spreadsheet */ - public function load($pFilename) + public function load($filename) { // Create new Spreadsheet $spreadsheet = new Spreadsheet(); $spreadsheet->removeSheetByIndex(0); // Load into this instance - return $this->loadIntoExisting($pFilename, $spreadsheet); + return $this->loadIntoExisting($filename, $spreadsheet); } private static function identifyFixedStyleValue($styleList, &$styleAttributeValue) diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index afda5c43..6e8f7495 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -50,9 +50,9 @@ abstract class BaseWriter implements IWriter return $this->includeCharts; } - public function setIncludeCharts($pValue) + public function setIncludeCharts($includeCharts) { - $this->includeCharts = (bool) $pValue; + $this->includeCharts = (bool) $includeCharts; return $this; } @@ -62,9 +62,9 @@ abstract class BaseWriter implements IWriter return $this->preCalculateFormulas; } - public function setPreCalculateFormulas($pValue) + public function setPreCalculateFormulas($precalculateFormulas) { - $this->preCalculateFormulas = (bool) $pValue; + $this->preCalculateFormulas = (bool) $precalculateFormulas; return $this; } @@ -74,15 +74,15 @@ abstract class BaseWriter implements IWriter return $this->useDiskCaching; } - public function setUseDiskCaching($pValue, $pDirectory = null) + public function setUseDiskCaching($useDiskCache, $cacheDirectory = null) { - $this->useDiskCaching = $pValue; + $this->useDiskCaching = $useDiskCache; - if ($pDirectory !== null) { - if (is_dir($pDirectory)) { - $this->diskCachingDirectory = $pDirectory; + if ($cacheDirectory !== null) { + if (is_dir($cacheDirectory)) { + $this->diskCachingDirectory = $cacheDirectory; } else { - throw new Exception("Directory does not exist: $pDirectory"); + throw new Exception("Directory does not exist: $cacheDirectory"); } } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 74f28636..d6d688c0 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -77,9 +77,9 @@ class Csv extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param resource|string $pFilename + * @param resource|string $filename */ - public function save($pFilename): void + public function save($filename): void { // Fetch sheet $sheet = $this->spreadsheet->getSheet($this->sheetIndex); @@ -90,7 +90,7 @@ class Csv extends BaseWriter Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE); // Open file - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); if ($this->excelCompatibility) { $this->setUseBOM(true); // Enforce UTF-8 BOM Header diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 31cc05af..d40d10d7 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -151,12 +151,12 @@ class Html extends BaseWriter /** * Save Spreadsheet to file. * - * @param resource|string $pFilename + * @param resource|string $filename */ - public function save($pFilename): void + public function save($filename): void { // Open file - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); // Write html fwrite($this->fileHandle, $this->generateHTMLAll()); diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index 5129d655..ac2972bc 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -8,6 +8,8 @@ interface IWriter { /** * IWriter constructor. + * + * @param Spreadsheet $spreadsheet The spreadsheet that we want to save using this Writer */ public function __construct(Spreadsheet $spreadsheet); @@ -25,11 +27,11 @@ interface IWriter * Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object. * Set to false (the default) to ignore charts. * - * @param bool $pValue + * @param bool $includeCharts * * @return IWriter */ - public function setIncludeCharts($pValue); + public function setIncludeCharts($includeCharts); /** * Get Pre-Calculate Formulas flag @@ -48,18 +50,18 @@ interface IWriter * Set to true (the default) to advise the Writer to calculate all formulae on save * Set to false to prevent precalculation of formulae on save. * - * @param bool $pValue Pre-Calculate Formulas? + * @param bool $precalculateFormulas Pre-Calculate Formulas? * * @return IWriter */ - public function setPreCalculateFormulas($pValue); + public function setPreCalculateFormulas($precalculateFormulas); /** * Save PhpSpreadsheet to file. * - * @param resource|string $pFilename Name of the file to save + * @param resource|string $filename Name of the file to save */ - public function save($pFilename); + public function save($filename); /** * Get use disk caching where possible? @@ -71,12 +73,12 @@ interface IWriter /** * Set use disk caching where possible? * - * @param bool $pValue - * @param string $pDirectory Disk caching directory + * @param bool $useDiskCache + * @param string $cacheDirectory Disk caching directory * * @return IWriter */ - public function setUseDiskCaching($pValue, $pDirectory = null); + public function setUseDiskCaching($useDiskCache, $cacheDirectory = null); /** * Get disk caching directory. diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 36f3e9ca..61a91c1e 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -73,9 +73,9 @@ class Ods extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param resource|string $pFilename + * @param resource|string $filename */ - public function save($pFilename): void + public function save($filename): void { if (!$this->spreadSheet) { throw new WriterException('PhpSpreadsheet object unassigned.'); @@ -84,7 +84,7 @@ class Ods extends BaseWriter // garbage collect $this->spreadSheet->garbageCollect(); - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); $zip = $this->createZip(); diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 87220458..d1ac69fa 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -165,13 +165,13 @@ abstract class Pdf extends Html /** * Set Paper Size. * - * @param string $pValue Paper size see PageSetup::PAPERSIZE_* + * @param string $paperSize Paper size see PageSetup::PAPERSIZE_* * * @return self */ - public function setPaperSize($pValue) + public function setPaperSize($paperSize) { - $this->paperSize = $pValue; + $this->paperSize = $paperSize; return $this; } @@ -189,13 +189,13 @@ abstract class Pdf extends Html /** * Set Orientation. * - * @param string $pValue Page orientation see PageSetup::ORIENTATION_* + * @param string $orientation Page orientation see PageSetup::ORIENTATION_* * * @return self */ - public function setOrientation($pValue) + public function setOrientation($orientation) { - $this->orientation = $pValue; + $this->orientation = $orientation; return $this; } @@ -213,16 +213,16 @@ abstract class Pdf extends Html /** * Set temporary storage directory. * - * @param string $pValue Temporary storage directory + * @param string $temporaryDirectory Temporary storage directory * * @return self */ - public function setTempDir($pValue) + public function setTempDir($temporaryDirectory) { - if (is_dir($pValue)) { - $this->tempDir = $pValue; + if (is_dir($temporaryDirectory)) { + $this->tempDir = $temporaryDirectory; } else { - throw new WriterException("Directory does not exist: $pValue"); + throw new WriterException("Directory does not exist: $temporaryDirectory"); } return $this; @@ -231,14 +231,14 @@ abstract class Pdf extends Html /** * Save Spreadsheet to PDF file, pre-save. * - * @param string $pFilename Name of the file to save as + * @param string $filename Name of the file to save as * * @return resource */ - protected function prepareForSave($pFilename) + protected function prepareForSave($filename) { // Open file - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); return $this->fileHandle; } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 9ae2ccee..51b0e1f1 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -20,11 +20,11 @@ class Dompdf extends Pdf /** * Save Spreadsheet to file. * - * @param string $pFilename Name of the file to save as + * @param string $filename Name of the file to save as */ - public function save($pFilename): void + public function save($filename): void { - $fileHandle = parent::prepareForSave($pFilename); + $fileHandle = parent::prepareForSave($filename); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 75e0010d..bbc35e15 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -22,11 +22,11 @@ class Mpdf extends Pdf /** * Save Spreadsheet to file. * - * @param string $pFilename Name of the file to save as + * @param string $filename Name of the file to save as */ - public function save($pFilename): void + public function save($filename): void { - $fileHandle = parent::prepareForSave($pFilename); + $fileHandle = parent::prepareForSave($filename); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 7530b1ef..770c2248 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -36,11 +36,11 @@ class Tcpdf extends Pdf /** * Save Spreadsheet to file. * - * @param string $pFilename Name of the file to save as + * @param string $filename Name of the file to save as */ - public function save($pFilename): void + public function save($filename): void { - $fileHandle = parent::prepareForSave($pFilename); + $fileHandle = parent::prepareForSave($filename); // Default PDF paper size $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) @@ -97,7 +97,7 @@ class Tcpdf extends Pdf $pdf->SetCreator($this->spreadsheet->getProperties()->getCreator()); // Write to file - fwrite($fileHandle, $pdf->output($pFilename, 'S')); + fwrite($fileHandle, $pdf->output($filename, 'S')); parent::restoreStateAfterSave(); } diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index c7c2e7d6..741aee74 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -114,9 +114,9 @@ class Xls extends BaseWriter /** * Save Spreadsheet to file. * - * @param resource|string $pFilename + * @param resource|string $filename */ - public function save($pFilename): void + public function save($filename): void { // garbage collect $this->spreadsheet->garbageCollect(); @@ -218,7 +218,7 @@ class Xls extends BaseWriter $root = new Root(time(), time(), $arrRootData); // save the OLE file - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); $root->save($this->fileHandle); $this->maybeCloseFileHandle(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index d71541c8..104e6041 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -174,15 +174,15 @@ class Xlsx extends BaseWriter /** * Save PhpSpreadsheet to file. * - * @param resource|string $pFilename + * @param resource|string $filename */ - public function save($pFilename): void + public function save($filename): void { // garbage collect $this->pathNames = []; $this->spreadSheet->garbageCollect(); - $this->openFileHandle($pFilename); + $this->openFileHandle($filename); $saveDebugLog = Calculation::getInstance($this->spreadSheet)->getDebugLog()->getWriteDebugLog(); Calculation::getInstance($this->spreadSheet)->getDebugLog()->setWriteDebugLog(false); diff --git a/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php index 9bc16ae0..b6b24751 100644 --- a/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/CsvContiguousFilter.php @@ -46,7 +46,7 @@ class CsvContiguousFilter implements IReadFilter return false; } - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { if ($this->filterType == 1) { return $this->filter1($row); diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php index 0904e2d4..8d8fd62b 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php @@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; /** Define a Read Filter class implementing IReadFilter */ class GnumericFilter implements IReadFilter { - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { return $row !== 4; } diff --git a/tests/PhpSpreadsheetTests/Reader/OddColumnReadFilter.php b/tests/PhpSpreadsheetTests/Reader/OddColumnReadFilter.php index b9373314..2ee6015b 100644 --- a/tests/PhpSpreadsheetTests/Reader/OddColumnReadFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/OddColumnReadFilter.php @@ -9,8 +9,8 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; */ class OddColumnReadFilter implements IReadFilter { - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { - return (\ord(\substr($column, -1, 1)) % 2) === 1; + return (\ord(\substr($columnAddress, -1, 1)) % 2) === 1; } } diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php index 1a20bb21..b53fffd5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php @@ -7,7 +7,7 @@ use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; /** Define a Read Filter class implementing IReadFilter */ class XmlFilter implements IReadFilter { - public function readCell($column, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = '') { return $row !== 4; }