From 75d3bdb0168d3cdc44a348f50dc9364b296a76d3 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 16 Apr 2017 14:13:16 +0900 Subject: [PATCH] Declare arguments as required when they are Closes #110 --- src/PhpSpreadsheet/Cell.php | 8 +-- src/PhpSpreadsheet/Chart/Legend.php | 5 +- src/PhpSpreadsheet/Chart/PlotArea.php | 3 +- src/PhpSpreadsheet/Chart/Title.php | 1 + src/PhpSpreadsheet/HashTable.php | 4 +- src/PhpSpreadsheet/NamedRange.php | 2 +- src/PhpSpreadsheet/ReferenceHelper.php | 2 +- src/PhpSpreadsheet/RichText.php | 2 +- src/PhpSpreadsheet/Shared/Date.php | 2 +- src/PhpSpreadsheet/Shared/Font.php | 2 +- src/PhpSpreadsheet/Style/Border.php | 2 +- src/PhpSpreadsheet/Style/Fill.php | 4 +- src/PhpSpreadsheet/Style/Font.php | 2 +- src/PhpSpreadsheet/Worksheet.php | 6 +- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 2 +- src/PhpSpreadsheet/Writer/Ods.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Xf.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 10 +-- .../Writer/Xlsx/ContentTypes.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 6 +- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 8 +-- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 8 +-- src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 2 +- .../Writer/Xlsx/StringTable.php | 65 +++++++++---------- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 32 ++++----- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 16 ++--- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 38 +++++------ src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 8 +-- .../Writer/Ods/ContentTest.php | 8 +-- 34 files changed, 130 insertions(+), 140 deletions(-) diff --git a/src/PhpSpreadsheet/Cell.php b/src/PhpSpreadsheet/Cell.php index 48f0f721..0263853d 100644 --- a/src/PhpSpreadsheet/Cell.php +++ b/src/PhpSpreadsheet/Cell.php @@ -118,7 +118,7 @@ class Cell * * @throws Exception */ - public function __construct($pValue = null, $pDataType = null, Worksheet $pSheet = null) + public function __construct($pValue, $pDataType, Worksheet $pSheet) { // Initialise cell value $this->value = $pValue; @@ -990,12 +990,8 @@ class Cell * * @throws Exception */ - public static function setValueBinder(Cell\IValueBinder $binder = null) + public static function setValueBinder(Cell\IValueBinder $binder) { - if ($binder === null) { - throw new Exception('A \\PhpOffice\\PhpSpreadsheet\\Cell\\IValueBinder is required for PhpSpreadsheet to function correctly.'); - } - self::$valueBinder = $binder; } diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index dea8610d..2abb28e2 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -73,8 +73,9 @@ class Legend /** * Create a new Legend. * - * @param mixed $position - * @param mixed $overlay + * @param string $position + * @param Layout|null $layout + * @param bool $overlay */ public function __construct($position = self::POSITION_RIGHT, Layout $layout = null, $overlay = false) { diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index f3c4d9f2..5c16db84 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -43,7 +43,8 @@ class PlotArea /** * Create a new PlotArea. * - * @param mixed $plotSeries + * @param Layout|null $layout + * @param array $plotSeries */ public function __construct(Layout $layout = null, array $plotSeries = []) { diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 491f5ecb..88f1e59e 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -44,6 +44,7 @@ class Title * Create a new Title. * * @param null|mixed $caption + * @param null|Layout $layout */ public function __construct($caption = null, Layout $layout = null) { diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index cda8c0d5..e8ac403b 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -81,7 +81,7 @@ class HashTable * * @throws Exception */ - public function add(IComparable $pSource = null) + public function add(IComparable $pSource) { $hash = $pSource->getHashCode(); if (!isset($this->items[$hash])) { @@ -97,7 +97,7 @@ class HashTable * * @throws Exception */ - public function remove(IComparable $pSource = null) + public function remove(IComparable $pSource) { $hash = $pSource->getHashCode(); if (isset($this->items[$hash])) { diff --git a/src/PhpSpreadsheet/NamedRange.php b/src/PhpSpreadsheet/NamedRange.php index 35942ea5..b1783662 100644 --- a/src/PhpSpreadsheet/NamedRange.php +++ b/src/PhpSpreadsheet/NamedRange.php @@ -238,7 +238,7 @@ class NamedRange * * @return NamedRange */ - public static function resolveRange($pNamedRange, Worksheet $pSheet = null) + public static function resolveRange($pNamedRange, Worksheet $pSheet) { return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet); } diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 5de4d727..30eb9436 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -384,7 +384,7 @@ class ReferenceHelper * * @throws Exception */ - public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, Worksheet $pSheet = null) + public function insertNewBefore($pBefore, $pNumCols, $pNumRows, Worksheet $pSheet) { $remove = ($pNumCols < 0 || $pNumRows < 0); $allCoordinates = $pSheet->getCoordinates(); diff --git a/src/PhpSpreadsheet/RichText.php b/src/PhpSpreadsheet/RichText.php index f6d56772..8c9dc2f2 100644 --- a/src/PhpSpreadsheet/RichText.php +++ b/src/PhpSpreadsheet/RichText.php @@ -68,7 +68,7 @@ class RichText implements IComparable * * @return RichText */ - public function addText(RichText\ITextElement $pText = null) + public function addText(RichText\ITextElement $pText) { $this->richTextElements[] = $pText; diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index cc1638d9..a7409e38 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -251,7 +251,7 @@ class Date * * @return float MS Excel serialized date/time value */ - public static function dateTimeToExcel(\DateTimeInterface $dateValue = null) + public static function dateTimeToExcel(\DateTimeInterface $dateValue) { return self::formattedPHPToExcel( $dateValue->format('Y'), diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index c305579c..befc2751 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -330,7 +330,7 @@ class Font * * @return int Text width in pixels (no padding added) */ - public static function getTextWidthPixelsApprox($columnText, \PhpOffice\PhpSpreadsheet\Style\Font $font = null, $rotation = 0) + public static function getTextWidthPixelsApprox($columnText, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0) { $fontName = $font->getName(); $fontSize = $font->getSize(); diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 48497aa5..9c2d8891 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -256,7 +256,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Border */ - public function setColor(Color $pValue = null) + public function setColor(Color $pValue) { // make sure parameter is a real color and not a supervisor $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 57d64f34..9cbf6841 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -264,7 +264,7 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Fill */ - public function setStartColor(Color $pValue = null) + public function setStartColor(Color $pValue) { // make sure parameter is a real color and not a supervisor $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; @@ -298,7 +298,7 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Fill */ - public function setEndColor(Color $pValue = null) + public function setEndColor(Color $pValue) { // make sure parameter is a real color and not a supervisor $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index b40b788b..3436382a 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -528,7 +528,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setColor(Color $pValue = null) + public function setColor(Color $pValue) { // make sure parameter is a real color and not a supervisor $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 7565c854..4a6799d3 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -550,7 +550,7 @@ class Worksheet implements IComparable * * @return Chart */ - public function addChart(Chart $pChart = null, $iChartIndex = null) + public function addChart(Chart $pChart, $iChartIndex = null) { $pChart->setWorksheet($this); if (is_null($iChartIndex)) { @@ -1546,7 +1546,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function duplicateStyle(Style $pCellStyle = null, $pRange = '') + public function duplicateStyle(Style $pCellStyle, $pRange) { // make sure we have a real style and not supervisor $style = $pCellStyle->getIsSupervisor() ? $pCellStyle->getSharedComponent() : $pCellStyle; @@ -1594,7 +1594,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') + public function duplicateConditionalStyle(array $pCellStyle, $pRange = '') { foreach ($pCellStyle as $cellStyle) { if (!($cellStyle instanceof Style\Conditional)) { diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 6a0d084e..92760132 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -428,7 +428,7 @@ class HeaderFooter * * @return HeaderFooter */ - public function addImage(HeaderFooterDrawing $image = null, $location = self::IMAGE_HEADER_LEFT) + public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT) { $this->headerFooterImages[$location] = $image; diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 4276fa6d..f82d4a73 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -48,7 +48,7 @@ class Ods extends BaseWriter implements IWriter * * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet */ - public function __construct(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function __construct(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { $this->setSpreadsheet($spreadsheet); @@ -183,7 +183,7 @@ class Ods extends BaseWriter implements IWriter * * @return self */ - public function setSpreadsheet(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function setSpreadsheet(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { $this->spreadSheet = $spreadsheet; diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index 5b4ad203..ba5c51bd 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -45,7 +45,7 @@ class Font * * @param \PhpOffice\PhpSpreadsheet\Style\Font $font */ - public function __construct(\PhpOffice\PhpSpreadsheet\Style\Font $font = null) + public function __construct(\PhpOffice\PhpSpreadsheet\Style\Font $font) { $this->colorIndex = 0x7FFF; $this->font = $font; diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index 3b5af382..23f76f6a 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -136,7 +136,7 @@ class Xf * * @param \PhpOffice\PhpSpreadsheet\Style The XF format */ - public function __construct(\PhpOffice\PhpSpreadsheet\Style $style = null) + public function __construct(\PhpOffice\PhpSpreadsheet\Style $style) { $this->isStyleXf = false; $this->fontIndex = 0; diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 0885f927..56f1c508 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -111,7 +111,7 @@ class Xlsx extends BaseWriter implements IWriter * * @param \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet */ - public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet = null) + public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet) { // Assign PhpSpreadsheet $this->setSpreadsheet($spreadsheet); @@ -411,7 +411,7 @@ class Xlsx extends BaseWriter implements IWriter * * @return Xlsx */ - public function setSpreadsheet(Spreadsheet $spreadsheet = null) + public function setSpreadsheet(Spreadsheet $spreadsheet) { $this->spreadSheet = $spreadsheet; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index b6396f3f..418688f7 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -47,7 +47,7 @@ class Chart extends WriterPart * * @return string XML Output */ - public function writeChart(\PhpOffice\PhpSpreadsheet\Chart $pChart = null, $calculateCellValues = true) + public function writeChart(\PhpOffice\PhpSpreadsheet\Chart $pChart, $calculateCellValues = true) { $this->calculateCellValues = $calculateCellValues; @@ -358,7 +358,7 @@ class Chart extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDataLabels($objWriter, Layout $chartLayout = null) + private function writeDataLabels(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, Layout $chartLayout = null) { $objWriter->startElement('c:dLbls'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index 72dba7ea..e630b797 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -35,7 +35,7 @@ class Comments extends WriterPart * * @return string XML Output */ - public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet = null) + public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet) { // Create XML writer $objWriter = null; @@ -94,7 +94,7 @@ class Comments extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, $pCellReference = 'A1', \PhpOffice\PhpSpreadsheet\Comment $pComment = null, $pAuthors = null) + private function writeComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pCellReference, \PhpOffice\PhpSpreadsheet\Comment $pComment, array $pAuthors) { // comment $objWriter->startElement('comment'); @@ -118,7 +118,7 @@ class Comments extends WriterPart * * @return string XML Output */ - public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet = null) + public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet) { // Create XML writer $objWriter = null; @@ -187,12 +187,12 @@ class Comments extends WriterPart * Write VML comment to XML format. * * @param \PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter XML Writer - * @param string $pCellReference Cell reference + * @param string $pCellReference Cell reference, eg: 'A1' * @param \PhpOffice\PhpSpreadsheet\Comment $pComment Comment * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeVMLComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, $pCellReference = 'A1', \PhpOffice\PhpSpreadsheet\Comment $pComment = null) + private function writeVMLComment(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pCellReference, \PhpOffice\PhpSpreadsheet\Comment $pComment) { // Metadata list($column, $row) = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($pCellReference); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 32c681d5..bf01e978 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -36,7 +36,7 @@ class ContentTypes extends WriterPart * * @return string XML Output */ - public function writeContentTypes(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet = null, $includeCharts = false) + public function writeContentTypes(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet, $includeCharts = false) { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php index 3cc78cbe..7eb9a06e 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php @@ -35,7 +35,7 @@ class DocProps extends WriterPart * * @return string XML Output */ - public function writeDocPropsApp(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeDocPropsApp(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; @@ -134,7 +134,7 @@ class DocProps extends WriterPart * * @return string XML Output */ - public function writeDocPropsCore(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeDocPropsCore(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; @@ -203,7 +203,7 @@ class DocProps extends WriterPart * * @return string XML Output */ - public function writeDocPropsCustom(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeDocPropsCustom(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); if (empty($customPropertyList)) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 18fe9945..afd27f30 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -90,7 +90,7 @@ class Drawing extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function writeChart(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Chart $pChart = null, $pRelationId = -1) + public function writeChart(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart $pChart, $pRelationId = -1) { $tl = $pChart->getTopLeftPosition(); $tl['colRow'] = \PhpOffice\PhpSpreadsheet\Cell::coordinateFromString($tl['cell']); @@ -293,7 +293,7 @@ class Drawing extends WriterPart * * @return string XML Output */ - public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet = null) + public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet) { // Create XML writer $objWriter = null; @@ -442,7 +442,7 @@ class Drawing extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeVMLHeaderFooterImage(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, $pReference = '', \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing $pImage = null) + private function writeVMLHeaderFooterImage(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pReference, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing $pImage) { // Calculate object id preg_match('{(\d+)}', md5($pReference), $m); @@ -485,7 +485,7 @@ class Drawing extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Worksheet\Drawing[] All drawings in PhpSpreadsheet */ - public function allDrawings(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allDrawings(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of all drawings $aDrawings = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 74a1823f..2d4ceef5 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -35,7 +35,7 @@ class Rels extends WriterPart * * @return string XML Output */ - public function writeRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; @@ -110,7 +110,7 @@ class Rels extends WriterPart * * @return string XML Output */ - public function writeWorkbookRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeWorkbookRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; @@ -193,7 +193,7 @@ class Rels extends WriterPart * * @return string XML Output */ - public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = false) + public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet, $pWorksheetId = 1, $includeCharts = false) { // Create XML writer $objWriter = null; @@ -353,7 +353,7 @@ class Rels extends WriterPart * * @return string XML Output */ - public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet = null) + public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet $pWorksheet) { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php index d89a3dcd..da414a2f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php @@ -35,7 +35,7 @@ class RelsRibbon extends WriterPart * * @return string XML Output */ - public function writeRibbonRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeRibbonRelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php index b25e6705..dbf4dfed 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php @@ -35,7 +35,7 @@ class RelsVBA extends WriterPart * * @return string XML Output */ - public function writeVBARelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeVBARelationships(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 195572f3..4232445a 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -85,49 +85,46 @@ class StringTable extends WriterPart * * @return string XML Output */ - public function writeStringTable(array $pStringTable = null) + public function writeStringTable(array $pStringTable) { - if ($pStringTable !== null) { - // Create XML writer - $objWriter = null; - if ($this->getParentWriter()->getUseDiskCaching()) { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); - } else { - $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); - } + // Create XML writer + $objWriter = null; + if ($this->getParentWriter()->getUseDiskCaching()) { + $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); + } else { + $objWriter = new \PhpOffice\PhpSpreadsheet\Shared\XMLWriter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter::STORAGE_MEMORY); + } - // XML header - $objWriter->startDocument('1.0', 'UTF-8', 'yes'); + // XML header + $objWriter->startDocument('1.0', 'UTF-8', 'yes'); - // String table - $objWriter->startElement('sst'); - $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); - $objWriter->writeAttribute('uniqueCount', count($pStringTable)); + // String table + $objWriter->startElement('sst'); + $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + $objWriter->writeAttribute('uniqueCount', count($pStringTable)); - // Loop through string table - foreach ($pStringTable as $textElement) { - $objWriter->startElement('si'); + // Loop through string table + foreach ($pStringTable as $textElement) { + $objWriter->startElement('si'); - if (!$textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { - $textToWrite = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($textElement); - $objWriter->startElement('t'); - if ($textToWrite !== trim($textToWrite)) { - $objWriter->writeAttribute('xml:space', 'preserve'); - } - $objWriter->writeRawData($textToWrite); - $objWriter->endElement(); - } elseif ($textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { - $this->writeRichText($objWriter, $textElement); + if (!$textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { + $textToWrite = \PhpOffice\PhpSpreadsheet\Shared\StringHelper::controlCharacterPHP2OOXML($textElement); + $objWriter->startElement('t'); + if ($textToWrite !== trim($textToWrite)) { + $objWriter->writeAttribute('xml:space', 'preserve'); } - + $objWriter->writeRawData($textToWrite); $objWriter->endElement(); + } elseif ($textElement instanceof \PhpOffice\PhpSpreadsheet\RichText) { + $this->writeRichText($objWriter, $textElement); } $objWriter->endElement(); - - return $objWriter->getData(); } - throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('Invalid string table array passed.'); + + $objWriter->endElement(); + + return $objWriter->getData(); } /** @@ -139,7 +136,7 @@ class StringTable extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function writeRichText(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\RichText $pRichText = null, $prefix = null) + public function writeRichText(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\RichText $pRichText, $prefix = null) { if ($prefix !== null) { $prefix .= ':'; @@ -224,7 +221,7 @@ class StringTable extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function writeRichTextForCharts(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, $pRichText = null, $prefix = null) + public function writeRichTextForCharts(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pRichText = null, $prefix = null) { if (!$pRichText instanceof \PhpOffice\PhpSpreadsheet\RichText) { $textRun = $pRichText; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index 3be4b76c..96457aa1 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -35,7 +35,7 @@ class Style extends WriterPart * * @return string XML Output */ - public function writeStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; @@ -166,7 +166,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill = null) + private function writeFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) { // Check if this is a pattern type or gradient type if ($pFill->getFillType() === \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR || @@ -187,7 +187,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeGradientFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill = null) + private function writeGradientFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) { // fill $objWriter->startElement('fill'); @@ -232,7 +232,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writePatternFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill = null) + private function writePatternFill(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Fill $pFill) { // fill $objWriter->startElement('fill'); @@ -271,7 +271,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeFont(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\Font $pFont = null) + private function writeFont(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Font $pFont) { // font $objWriter->startElement('font'); @@ -352,7 +352,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBorder(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\Borders $pBorders = null) + private function writeBorder(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\Borders $pBorders) { // Write border $objWriter->startElement('border'); @@ -390,7 +390,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeCellStyleXf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style $pStyle = null, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + private function writeCellStyleXf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // xf $objWriter->startElement('xf'); @@ -466,7 +466,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeCellStyleDxf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style $pStyle = null) + private function writeCellStyleDxf(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style $pStyle) { // dxf $objWriter->startElement('dxf'); @@ -532,7 +532,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBorderPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, $pName = 'left', \PhpOffice\PhpSpreadsheet\Style\Border $pBorder = null) + private function writeBorderPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, $pName, \PhpOffice\PhpSpreadsheet\Style\Border $pBorder) { // Write BorderPr if ($pBorder->getBorderStyle() != \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_NONE) { @@ -557,7 +557,7 @@ class Style extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeNumFmt(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Style\NumberFormat $pNumberFormat = null, $pId = 0) + private function writeNumFmt(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Style\NumberFormat $pNumberFormat, $pId = 0) { // Translate formatcode $formatCode = $pNumberFormat->getFormatCode(); @@ -580,7 +580,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style[] All styles in PhpSpreadsheet */ - public function allStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { return $spreadsheet->getCellXfCollection(); } @@ -594,7 +594,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style\Conditional[] All conditional styles in PhpSpreadsheet */ - public function allConditionalStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allConditionalStyles(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of all styles $aStyles = []; @@ -620,7 +620,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style\Fill[] All fills in PhpSpreadsheet */ - public function allFills(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allFills(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of unique fills $aFills = []; @@ -654,7 +654,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style\Font[] All fonts in PhpSpreadsheet */ - public function allFonts(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allFonts(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of unique fonts $aFonts = []; @@ -679,7 +679,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style\Borders[] All borders in PhpSpreadsheet */ - public function allBorders(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allBorders(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of unique borders $aBorders = []; @@ -704,7 +704,7 @@ class Style extends WriterPart * * @return \PhpOffice\PhpSpreadsheet\Style\NumberFormat[] All number formats in PhpSpreadsheet */ - public function allNumberFormats(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function allNumberFormats(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Get an array of unique number formats $aNumFmts = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index 89ec67e6..4dde8153 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -137,7 +137,7 @@ class Theme extends WriterPart * * @return string XML Output */ - public function writeTheme(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + public function writeTheme(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index bc1c4159..16f9f73b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -36,7 +36,7 @@ class Workbook extends WriterPart * * @return string XML Output */ - public function writeWorkbook(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null, $recalcRequired = false) + public function writeWorkbook(\PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet, $recalcRequired = false) { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { @@ -128,7 +128,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBookViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + private function writeBookViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // bookViews $objWriter->startElement('bookViews'); @@ -159,7 +159,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeWorkbookProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + private function writeWorkbookProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { if ($spreadsheet->getSecurity()->isSecurityEnabled()) { $objWriter->startElement('workbookProtection'); @@ -211,7 +211,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeSheets(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + private function writeSheets(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Write sheets $objWriter->startElement('sheets'); @@ -266,7 +266,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDefinedNames(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet = null) + private function writeDefinedNames(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\SpreadSheet $spreadsheet) { // Write defined names $objWriter->startElement('definedNames'); @@ -351,7 +351,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDefinedNameForAutofilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null, $pSheetId = 0) + private function writeDefinedNameForAutofilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) { // definedName for autoFilter $autoFilterRange = $pSheet->getAutoFilter()->getRange(); @@ -388,7 +388,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDefinedNameForPrintTitles(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null, $pSheetId = 0) + private function writeDefinedNameForPrintTitles(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) { // definedName for PrintTitles if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) { @@ -432,7 +432,7 @@ class Workbook extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDefinedNameForPrintArea(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null, $pSheetId = 0) + private function writeDefinedNameForPrintArea(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet, $pSheetId = 0) { // definedName for PrintArea if ($pSheet->getPageSetup()->isPrintAreaSet()) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index b1a5debd..e8d3b715 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -144,7 +144,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeSheetPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeSheetPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // sheetPr $objWriter->startElement('sheetPr'); @@ -192,7 +192,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDimension(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeDimension(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // dimension $objWriter->startElement('dimension'); @@ -208,7 +208,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeSheetViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeSheetViews(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // sheetViews $objWriter->startElement('sheetViews'); @@ -321,7 +321,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeSheetFormatPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeSheetFormatPr(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // sheetFormatPr $objWriter->startElement('sheetFormatPr'); @@ -374,7 +374,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeCols(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeCols(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // cols if (count($pSheet->getColumnDimensions()) > 0) { @@ -440,7 +440,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeSheetProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeSheetProtection(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // sheetProtection $objWriter->startElement('sheetProtection'); @@ -476,7 +476,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeConditionalFormatting(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeConditionalFormatting(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // Conditional id $id = 1; @@ -550,7 +550,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeDataValidations(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeDataValidations(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // Datavalidation collection $dataValidationCollection = $pSheet->getDataValidationCollection(); @@ -617,7 +617,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeHyperlinks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeHyperlinks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // Hyperlink collection $hyperlinkCollection = $pSheet->getHyperlinkCollection(); @@ -659,7 +659,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeProtectedRanges(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeProtectedRanges(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { if (count($pSheet->getProtectedCells()) > 0) { // protectedRanges @@ -689,7 +689,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeMergeCells(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeMergeCells(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { if (count($pSheet->getMergeCells()) > 0) { // mergeCells @@ -715,7 +715,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writePrintOptions(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writePrintOptions(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // printOptions $objWriter->startElement('printOptions'); @@ -742,7 +742,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writePageMargins(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writePageMargins(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // pageMargins $objWriter->startElement('pageMargins'); @@ -763,7 +763,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeAutoFilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeAutoFilter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { $autoFilterRange = $pSheet->getAutoFilter()->getRange(); if (!empty($autoFilterRange)) { @@ -857,7 +857,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writePageSetup(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writePageSetup(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // pageSetup $objWriter->startElement('pageSetup'); @@ -893,7 +893,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeHeaderFooter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeHeaderFooter(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // headerFooter $objWriter->startElement('headerFooter'); @@ -919,7 +919,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeBreaks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeBreaks(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // Get row and column breaks $aRowBreaks = []; @@ -1201,7 +1201,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeLegacyDrawing(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeLegacyDrawing(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // If sheet contains comments, add the relationships if (count($pSheet->getComments()) > 0) { @@ -1219,7 +1219,7 @@ class Worksheet extends WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - private function writeLegacyDrawingHF(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter = null, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet = null) + private function writeLegacyDrawingHF(\PhpOffice\PhpSpreadsheet\Shared\XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Worksheet $pSheet) { // If sheet contains images, add the relationships if (count($pSheet->getHeaderFooter()->getImages()) > 0) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php index 48744bb9..881683db 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -40,7 +40,7 @@ abstract class WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function setParentWriter(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter = null) + public function setParentWriter(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter) { $this->parentWriter = $pWriter; } @@ -67,10 +67,8 @@ abstract class WriterPart * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function __construct(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter = null) + public function __construct(\PhpOffice\PhpSpreadsheet\Writer\IWriter $pWriter) { - if (!is_null($pWriter)) { - $this->parentWriter = $pWriter; - } + $this->parentWriter = $pWriter; } } diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index 941e684f..8a4aae64 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -38,9 +38,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase public function testWriteEmptySpreadsheet() { - $content = new Content(); - $content->setParentWriter(new Ods(new Spreadsheet())); - + $content = new Content(new Ods(new Spreadsheet())); $xml = $content->write(); $this->assertXmlStringEqualsXmlFile($this->samplesPath . '/content-empty.xml', $xml); @@ -91,9 +89,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase $worksheet2->setCellValue('A1', 2); // Write - $content = new Content(); - $content->setParentWriter(new Ods($workbook)); - + $content = new Content(new Ods($workbook)); $xml = $content->write(); $this->assertXmlStringEqualsXmlFile($this->samplesPath . '/content-with-data.xml', $xml);