diff --git a/docs/topics/migration-from-PHPExcel.md b/docs/topics/migration-from-PHPExcel.md index b948eac2..c34fba7f 100644 --- a/docs/topics/migration-from-PHPExcel.md +++ b/docs/topics/migration-from-PHPExcel.md @@ -171,3 +171,24 @@ to `\PhpOffice\PhpSpreadsheet::getCoordinates()` and `\PhpOffice\PhpSpreadsheet::getCellCollection()` for clarity. Refer to [the new documentation](./memory_saving.md) to see how to migrate. + +## Dropped conditionally returned cell + +For all the following methods, it is no more possible to change the type of +returned value. It always return the Worksheet and never the Cell or Rule: + +- Worksheet::setCellValue() +- Worksheet::setCellValueByColumnAndRow() +- Worksheet::setCellValueExplicit() +- Worksheet::setCellValueExplicitByColumnAndRow() +- Worksheet::addRule() + +Migration would be similar to: + +``` php +// Before +$cell = $worksheet->setCellValue('A1', 'value', true); + +// After +$cell = $worksheet->getCell('A1')->setValue('value'); +``` diff --git a/src/PhpSpreadsheet/CalcEngine/Logger.php b/src/PhpSpreadsheet/CalcEngine/Logger.php index 9bc97179..ba4b2971 100644 --- a/src/PhpSpreadsheet/CalcEngine/Logger.php +++ b/src/PhpSpreadsheet/CalcEngine/Logger.php @@ -74,7 +74,7 @@ class Logger * * @param bool $pValue */ - public function setWriteDebugLog($pValue = false) + public function setWriteDebugLog($pValue) { $this->writeDebugLog = $pValue; } @@ -94,7 +94,7 @@ class Logger * * @param bool $pValue */ - public function setEchoDebugLog($pValue = false) + public function setEchoDebugLog($pValue) { $this->echoDebugLog = $pValue; } diff --git a/src/PhpSpreadsheet/Calculation.php b/src/PhpSpreadsheet/Calculation.php index 2d75f29a..46414a4a 100644 --- a/src/PhpSpreadsheet/Calculation.php +++ b/src/PhpSpreadsheet/Calculation.php @@ -2176,7 +2176,7 @@ class Calculation * * @param bool $pValue */ - public function setCalculationCacheEnabled($pValue = true) + public function setCalculationCacheEnabled($pValue) { $this->calculationCacheEnabled = $pValue; $this->clearCalculationCache(); @@ -2245,11 +2245,11 @@ class Calculation /** * Set the locale code. * - * @param string $locale The locale to use for formula translation + * @param string $locale The locale to use for formula translation, eg: 'en_us' * * @return bool */ - public function setLocale($locale = 'en_us') + public function setLocale($locale) { // Identify our locale and language $language = $locale = strtolower($locale); diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php index ab46f5b1..ff3c8585 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -142,11 +142,11 @@ class FormulaToken } /** - * Set Token Type. + * Set Token Type (represented by TOKEN_TYPE_*). * * @param string $value */ - public function setTokenType($value = self::TOKEN_TYPE_UNKNOWN) + public function setTokenType($value) { $this->tokenType = $value; } @@ -162,11 +162,11 @@ class FormulaToken } /** - * Set Token SubType. + * Set Token SubType (represented by TOKEN_SUBTYPE_*). * * @param string $value */ - public function setTokenSubType($value = self::TOKEN_SUBTYPE_NOTHING) + public function setTokenSubType($value) { $this->tokenSubType = $value; } diff --git a/src/PhpSpreadsheet/Cell.php b/src/PhpSpreadsheet/Cell.php index e01a473c..102c0d7c 100644 --- a/src/PhpSpreadsheet/Cell.php +++ b/src/PhpSpreadsheet/Cell.php @@ -202,7 +202,7 @@ class Cell * * @return Cell */ - public function setValue($pValue = null) + public function setValue($pValue) { if (!self::getValueBinder()->bindValue($this, $pValue)) { throw new Exception('Value could not be bound to cell.'); @@ -215,13 +215,13 @@ class Cell * Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder). * * @param mixed $pValue Value - * @param string $pDataType Explicit data type + * @param string $pDataType Explicit data type, see Cell\DataType::TYPE_* * * @throws Exception * * @return Cell */ - public function setValueExplicit($pValue = null, $pDataType = Cell\DataType::TYPE_STRING) + public function setValueExplicit($pValue, $pDataType) { // set the value according to data type switch ($pDataType) { @@ -311,7 +311,7 @@ class Cell * * @return Cell */ - public function setCalculatedValue($pValue = null) + public function setCalculatedValue($pValue) { if ($pValue !== null) { $this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue; @@ -348,11 +348,11 @@ class Cell /** * Set cell data type. * - * @param string $pDataType + * @param string $pDataType see Cell\DataType::TYPE_* * * @return Cell */ - public function setDataType($pDataType = Cell\DataType::TYPE_STRING) + public function setDataType($pDataType) { if ($pDataType == Cell\DataType::TYPE_STRING2) { $pDataType = Cell\DataType::TYPE_STRING; @@ -571,7 +571,7 @@ class Cell * * @return bool */ - public function isInRange($pRange = 'A1:A1') + public function isInRange($pRange) { list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); @@ -587,13 +587,13 @@ class Cell /** * Coordinate from string. * - * @param string $pCoordinateString + * @param string $pCoordinateString eg: 'A1' * * @throws Exception * * @return string[] Array containing column and row (indexes 0 and 1) */ - public static function coordinateFromString($pCoordinateString = 'A1') + public static function coordinateFromString($pCoordinateString) { if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { return [$matches[1], $matches[2]]; @@ -616,7 +616,7 @@ class Cell * * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' */ - public static function absoluteReference($pCoordinateString = 'A1') + public static function absoluteReference($pCoordinateString) { if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { // Split out any worksheet name from the reference @@ -651,7 +651,7 @@ class Cell * * @return string Absolute coordinate e.g. '$A$1' */ - public static function absoluteCoordinate($pCoordinateString = 'A1') + public static function absoluteCoordinate($pCoordinateString) { if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { // Split out any worksheet name from the coordinate @@ -684,7 +684,7 @@ class Cell * e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11')) * or array('B4') */ - public static function splitRange($pRange = 'A1:A1') + public static function splitRange($pRange) { // Ensure $pRange is a valid range if (empty($pRange)) { @@ -735,7 +735,7 @@ class Cell * @return array Range coordinates array(Start Cell, End Cell) * where Start Cell and End Cell are arrays (Column Number, Row Number) */ - public static function rangeBoundaries($pRange = 'A1:A1') + public static function rangeBoundaries($pRange) { // Ensure $pRange is a valid range if (empty($pRange)) { @@ -770,7 +770,7 @@ class Cell * * @return array Range dimension (width, height) */ - public static function rangeDimension($pRange = 'A1:A1') + public static function rangeDimension($pRange) { // Calculate range outer borders list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); @@ -786,7 +786,7 @@ class Cell * @return array Range coordinates array(Start Cell, End Cell) * where Start Cell and End Cell are arrays (Column ID, Row Number) */ - public static function getRangeBoundaries($pRange = 'A1:A1') + public static function getRangeBoundaries($pRange) { // Ensure $pRange is a valid range if (empty($pRange)) { @@ -809,11 +809,11 @@ class Cell /** * Column index from string. * - * @param string $pString + * @param string $pString eg 'A' * * @return int Column index (base 1 !!!) */ - public static function columnIndexFromString($pString = 'A') + public static function columnIndexFromString($pString) { // Using a lookup cache adds a slight memory overhead, but boosts speed // caching using a static within the method is faster than a class static, @@ -856,11 +856,11 @@ class Cell /** * String from columnindex. * - * @param int $pColumnIndex Column index (base 0 !!!) + * @param int $pColumnIndex Column index (A = 0) * * @return string */ - public static function stringFromColumnIndex($pColumnIndex = 0) + public static function stringFromColumnIndex($pColumnIndex) { // Using a lookup cache adds a slight memory overhead, but boosts speed // caching using a static within the method is faster than a class static, @@ -891,7 +891,7 @@ class Cell * * @return array Array containing single cell references */ - public static function extractAllCellReferencesInRange($pRange = 'A1') + public static function extractAllCellReferencesInRange($pRange) { // Returnvalue $returnValue = []; @@ -1031,7 +1031,7 @@ class Cell * * @return Cell */ - public function setXfIndex($pValue = 0) + public function setXfIndex($pValue) { $this->xfIndex = $pValue; diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index ee2fa6b6..2f41b66c 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -69,7 +69,7 @@ class DataType * * @return mixed Sanitized value */ - public static function checkString($pValue = null) + public static function checkString($pValue) { if ($pValue instanceof \PhpOffice\PhpSpreadsheet\RichText) { // TODO: Sanitize Rich-Text string (max. character count is 32,767) @@ -93,7 +93,7 @@ class DataType * * @return string Sanitized value */ - public static function checkErrorCode($pValue = null) + public static function checkErrorCode($pValue) { $pValue = (string) $pValue; diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 7d710164..ae138bde 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -166,7 +166,7 @@ class DataValidation * * @return DataValidation */ - public function setFormula1($value = '') + public function setFormula1($value) { $this->formula1 = $value; @@ -190,7 +190,7 @@ class DataValidation * * @return DataValidation */ - public function setFormula2($value = '') + public function setFormula2($value) { $this->formula2 = $value; @@ -214,7 +214,7 @@ class DataValidation * * @return DataValidation */ - public function setType($value = self::TYPE_NONE) + public function setType($value) { $this->type = $value; @@ -234,11 +234,11 @@ class DataValidation /** * Set Error style. * - * @param string $value + * @param string $value see self::STYLE_* * * @return DataValidation */ - public function setErrorStyle($value = self::STYLE_STOP) + public function setErrorStyle($value) { $this->errorStyle = $value; @@ -262,7 +262,7 @@ class DataValidation * * @return DataValidation */ - public function setOperator($value = '') + public function setOperator($value) { $this->operator = $value; @@ -286,7 +286,7 @@ class DataValidation * * @return DataValidation */ - public function setAllowBlank($value = false) + public function setAllowBlank($value) { $this->allowBlank = $value; @@ -310,7 +310,7 @@ class DataValidation * * @return DataValidation */ - public function setShowDropDown($value = false) + public function setShowDropDown($value) { $this->showDropDown = $value; @@ -334,7 +334,7 @@ class DataValidation * * @return DataValidation */ - public function setShowInputMessage($value = false) + public function setShowInputMessage($value) { $this->showInputMessage = $value; @@ -358,7 +358,7 @@ class DataValidation * * @return DataValidation */ - public function setShowErrorMessage($value = false) + public function setShowErrorMessage($value) { $this->showErrorMessage = $value; @@ -382,7 +382,7 @@ class DataValidation * * @return DataValidation */ - public function setErrorTitle($value = '') + public function setErrorTitle($value) { $this->errorTitle = $value; @@ -406,7 +406,7 @@ class DataValidation * * @return DataValidation */ - public function setError($value = '') + public function setError($value) { $this->error = $value; @@ -430,7 +430,7 @@ class DataValidation * * @return DataValidation */ - public function setPromptTitle($value = '') + public function setPromptTitle($value) { $this->promptTitle = $value; @@ -454,7 +454,7 @@ class DataValidation * * @return DataValidation */ - public function setPrompt($value = '') + public function setPrompt($value) { $this->prompt = $value; diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 461c96e6..f9e7729f 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -62,7 +62,7 @@ class DefaultValueBinder implements IValueBinder * * @return string */ - public static function dataTypeForValue($pValue = null) + public static function dataTypeForValue($pValue) { // Match the value against a few data types if ($pValue === null) { diff --git a/src/PhpSpreadsheet/Cell/Hyperlink.php b/src/PhpSpreadsheet/Cell/Hyperlink.php index 0ec811b7..6065357d 100644 --- a/src/PhpSpreadsheet/Cell/Hyperlink.php +++ b/src/PhpSpreadsheet/Cell/Hyperlink.php @@ -70,7 +70,7 @@ class Hyperlink * * @return Hyperlink */ - public function setUrl($value = '') + public function setUrl($value) { $this->url = $value; @@ -94,7 +94,7 @@ class Hyperlink * * @return Hyperlink */ - public function setTooltip($value = '') + public function setTooltip($value) { $this->tooltip = $value; diff --git a/src/PhpSpreadsheet/Chart.php b/src/PhpSpreadsheet/Chart.php index 17530463..ea31112a 100644 --- a/src/PhpSpreadsheet/Chart.php +++ b/src/PhpSpreadsheet/Chart.php @@ -341,7 +341,7 @@ class Chart * * @return Chart */ - public function setPlotVisibleOnly($plotVisibleOnly = true) + public function setPlotVisibleOnly($plotVisibleOnly) { $this->plotVisibleOnly = $plotVisibleOnly; @@ -365,7 +365,7 @@ class Chart * * @return Chart */ - public function setDisplayBlanksAs($displayBlanksAs = '0') + public function setDisplayBlanksAs($displayBlanksAs) { $this->displayBlanksAs = $displayBlanksAs; } @@ -494,11 +494,12 @@ class Chart * * @return Chart */ - public function setTopLeftOffset($xOffset = null, $yOffset = null) + public function setTopLeftOffset($xOffset, $yOffset) { if (!is_null($xOffset)) { $this->setTopLeftXOffset($xOffset); } + if (!is_null($yOffset)) { $this->setTopLeftYOffset($yOffset); } @@ -604,11 +605,12 @@ class Chart * * @return Chart */ - public function setBottomRightOffset($xOffset = null, $yOffset = null) + public function setBottomRightOffset($xOffset, $yOffset) { if (!is_null($xOffset)) { $this->setBottomRightXOffset($xOffset); } + if (!is_null($yOffset)) { $this->setBottomRightYOffset($yOffset); } diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 6dc90760..092736a6 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -178,7 +178,7 @@ class DataSeries * * @return DataSeries */ - public function setPlotType($plotType = '') + public function setPlotType($plotType) { $this->plotType = $plotType; @@ -202,7 +202,7 @@ class DataSeries * * @return DataSeries */ - public function setPlotGrouping($groupingType = null) + public function setPlotGrouping($groupingType) { $this->plotGrouping = $groupingType; @@ -226,7 +226,7 @@ class DataSeries * * @return DataSeries */ - public function setPlotDirection($plotDirection = null) + public function setPlotDirection($plotDirection) { $this->plotDirection = $plotDirection; @@ -318,7 +318,7 @@ class DataSeries * * @return DataSeries */ - public function setPlotStyle($plotStyle = null) + public function setPlotStyle($plotStyle) { $this->plotStyle = $plotStyle; @@ -381,7 +381,7 @@ class DataSeries * * @return DataSeries */ - public function setSmoothLine($smoothLine = true) + public function setSmoothLine($smoothLine) { $this->smoothLine = $smoothLine; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index d1e92df1..82813400 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -120,7 +120,7 @@ class DataSeriesValues * * @return DataSeriesValues */ - public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) + public function setDataType($dataType) { if (!in_array($dataType, self::$dataTypeValues)) { throw new Exception('Invalid datatype for chart data series values'); @@ -144,18 +144,13 @@ class DataSeriesValues * Set Series Data Source (formula). * * @param string $dataSource - * @param mixed $refreshDataValues * * @return DataSeriesValues */ - public function setDataSource($dataSource = null, $refreshDataValues = true) + public function setDataSource($dataSource) { $this->dataSource = $dataSource; - if ($refreshDataValues) { - // TO DO - } - return $this; } @@ -176,7 +171,7 @@ class DataSeriesValues * * @return DataSeriesValues */ - public function setPointMarker($marker = null) + public function setPointMarker($marker) { $this->pointMarker = $marker; @@ -200,7 +195,7 @@ class DataSeriesValues * * @return DataSeriesValues */ - public function setFormatCode($formatCode = null) + public function setFormatCode($formatCode) { $this->formatCode = $formatCode; @@ -277,29 +272,17 @@ class DataSeriesValues * Set Series Data Values. * * @param array $dataValues - * @param bool $refreshDataSource - * TRUE - refresh the value of dataSource based on the values of $dataValues - * FALSE - don't change the value of dataSource * * @return DataSeriesValues */ - public function setDataValues($dataValues = [], $refreshDataSource = true) + public function setDataValues($dataValues) { $this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($dataValues); $this->pointCount = count($dataValues); - if ($refreshDataSource) { - // TO DO - } - return $this; } - private function stripNulls($var) - { - return $var !== null; - } - public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet, $flatten = true) { if ($this->dataSource !== null) { diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index 98e5e6f6..9480d691 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -133,9 +133,9 @@ class Layout /** * Create a new Layout. * - * @param mixed $layout + * @param array $layout */ - public function __construct($layout = []) + public function __construct(array $layout = []) { if (isset($layout['layoutTarget'])) { $this->layoutTarget = $layout['layoutTarget']; diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index c472cd8f..dea8610d 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -96,9 +96,9 @@ class Legend /** * Get legend position using an excel string value. * - * @param string $position + * @param string $position see self::POSITION_* */ - public function setPosition($position = self::POSITION_RIGHT) + public function setPosition($position) { if (!in_array($position, self::$positionXLref)) { return false; @@ -112,7 +112,7 @@ class Legend /** * Get legend position as an Excel internal numeric value. * - * @return number + * @return int */ public function getPositionXL() { @@ -122,9 +122,9 @@ class Legend /** * Set legend position using an Excel internal numeric value. * - * @param number $positionXL + * @param int $positionXL see self::XL_LEGEND_POSITION_* */ - public function setPositionXL($positionXL = self::XL_LEGEND_POSITION_RIGHT) + public function setPositionXL($positionXL) { if (!isset(self::$positionXLref[$positionXL])) { return false; @@ -152,7 +152,7 @@ class Legend * * @return bool */ - public function setOverlay($overlay = false) + public function setOverlay($overlay) { if (!is_bool($overlay)) { return false; diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index afcced96..f3c4d9f2 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -45,7 +45,7 @@ class PlotArea * * @param mixed $plotSeries */ - public function __construct(Layout $layout = null, $plotSeries = []) + public function __construct(Layout $layout = null, array $plotSeries = []) { $this->layout = $layout; $this->plotSeries = $plotSeries; @@ -116,7 +116,7 @@ class PlotArea * * @return PlotArea */ - public function setPlotSeries($plotSeries = []) + public function setPlotSeries(array $plotSeries) { $this->plotSeries = $plotSeries; diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 753e63e8..491f5ecb 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -68,7 +68,7 @@ class Title * * @return Title */ - public function setCaption($caption = null) + public function setCaption($caption) { $this->caption = $caption; diff --git a/src/PhpSpreadsheet/Comment.php b/src/PhpSpreadsheet/Comment.php index f04f3ce6..28bce22c 100644 --- a/src/PhpSpreadsheet/Comment.php +++ b/src/PhpSpreadsheet/Comment.php @@ -116,13 +116,13 @@ class Comment implements IComparable /** * Set Author. * - * @param string $pValue + * @param string $author * * @return Comment */ - public function setAuthor($pValue = '') + public function setAuthor($author) { - $this->author = $pValue; + $this->author = $author; return $this; } @@ -164,13 +164,13 @@ class Comment implements IComparable /** * Set comment width (CSS style, i.e. XXpx or YYpt). * - * @param string $value + * @param string $width * * @return Comment */ - public function setWidth($value = '96pt') + public function setWidth($width) { - $this->width = $value; + $this->width = $width; return $this; } @@ -192,7 +192,7 @@ class Comment implements IComparable * * @return Comment */ - public function setHeight($value = '55.5pt') + public function setHeight($value) { $this->height = $value; @@ -216,7 +216,7 @@ class Comment implements IComparable * * @return Comment */ - public function setMarginLeft($value = '59.25pt') + public function setMarginLeft($value) { $this->marginLeft = $value; @@ -240,7 +240,7 @@ class Comment implements IComparable * * @return Comment */ - public function setMarginTop($value = '1.5pt') + public function setMarginTop($value) { $this->marginTop = $value; @@ -264,7 +264,7 @@ class Comment implements IComparable * * @return Comment */ - public function setVisible($value = false) + public function setVisible($value) { $this->visible = $value; @@ -284,13 +284,13 @@ class Comment implements IComparable /** * Set Alignment. * - * @param string $pValue + * @param string $alignment see Style\Alignment::HORIZONTAL_* * * @return Comment */ - public function setAlignment($pValue = Style\Alignment::HORIZONTAL_GENERAL) + public function setAlignment($alignment) { - $this->alignment = $pValue; + $this->alignment = $alignment; return $this; } diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index d0705dc8..da00fd2c 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -142,13 +142,13 @@ class Properties /** * Set Creator. * - * @param string $pValue + * @param string $creator * * @return Properties */ - public function setCreator($pValue = '') + public function setCreator($creator) { - $this->creator = $pValue; + $this->creator = $creator; return $this; } @@ -170,7 +170,7 @@ class Properties * * @return Properties */ - public function setLastModifiedBy($pValue = '') + public function setLastModifiedBy($pValue) { $this->lastModifiedBy = $pValue; @@ -194,7 +194,7 @@ class Properties * * @return Properties */ - public function setCreated($pValue = null) + public function setCreated($pValue) { if ($pValue === null) { $pValue = time(); @@ -228,7 +228,7 @@ class Properties * * @return Properties */ - public function setModified($pValue = null) + public function setModified($pValue) { if ($pValue === null) { $pValue = time(); @@ -258,13 +258,13 @@ class Properties /** * Set Title. * - * @param string $pValue + * @param string $title * * @return Properties */ - public function setTitle($pValue = '') + public function setTitle($title) { - $this->title = $pValue; + $this->title = $title; return $this; } @@ -282,13 +282,13 @@ class Properties /** * Set Description. * - * @param string $pValue + * @param string $description * * @return Properties */ - public function setDescription($pValue = '') + public function setDescription($description) { - $this->description = $pValue; + $this->description = $description; return $this; } @@ -306,13 +306,13 @@ class Properties /** * Set Subject. * - * @param string $pValue + * @param string $subject * * @return Properties */ - public function setSubject($pValue = '') + public function setSubject($subject) { - $this->subject = $pValue; + $this->subject = $subject; return $this; } @@ -330,13 +330,13 @@ class Properties /** * Set Keywords. * - * @param string $pValue + * @param string $keywords * * @return Properties */ - public function setKeywords($pValue = '') + public function setKeywords($keywords) { - $this->keywords = $pValue; + $this->keywords = $keywords; return $this; } @@ -354,13 +354,13 @@ class Properties /** * Set Category. * - * @param string $pValue + * @param string $category * * @return Properties */ - public function setCategory($pValue = '') + public function setCategory($category) { - $this->category = $pValue; + $this->category = $category; return $this; } @@ -378,13 +378,13 @@ class Properties /** * Set Company. * - * @param string $pValue + * @param string $company * * @return Properties */ - public function setCompany($pValue = '') + public function setCompany($company) { - $this->company = $pValue; + $this->company = $company; return $this; } @@ -402,13 +402,13 @@ class Properties /** * Set Manager. * - * @param string $pValue + * @param string $manager * * @return Properties */ - public function setManager($pValue = '') + public function setManager($manager) { - $this->manager = $pValue; + $this->manager = $manager; return $this; } diff --git a/src/PhpSpreadsheet/Document/Security.php b/src/PhpSpreadsheet/Document/Security.php index 380f7265..6bb99b97 100644 --- a/src/PhpSpreadsheet/Document/Security.php +++ b/src/PhpSpreadsheet/Document/Security.php @@ -97,7 +97,7 @@ class Security * * @return Security */ - public function setLockRevision($pValue = false) + public function setLockRevision($pValue) { $this->lockRevision = $pValue; @@ -121,7 +121,7 @@ class Security * * @return Security */ - public function setLockStructure($pValue = false) + public function setLockStructure($pValue) { $this->lockStructure = $pValue; @@ -145,7 +145,7 @@ class Security * * @return Security */ - public function setLockWindows($pValue = false) + public function setLockWindows($pValue) { $this->lockWindows = $pValue; @@ -170,7 +170,7 @@ class Security * * @return Security */ - public function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) + public function setRevisionsPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); @@ -198,7 +198,7 @@ class Security * * @return Security */ - public function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) + public function setWorkbookPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index fededf17..cda8c0d5 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -62,13 +62,11 @@ class HashTable * * @throws Exception */ - public function addFromSource($pSource = null) + public function addFromSource(array $pSource = null) { // Check if an array was passed if ($pSource == null) { return; - } elseif (!is_array($pSource)) { - throw new Exception('Invalid array parameter passed.'); } foreach ($pSource as $item) { @@ -145,7 +143,7 @@ class HashTable * * @return int Index */ - public function getIndexForHashCode($pHashCode = '') + public function getIndexForHashCode($pHashCode) { return array_search($pHashCode, $this->keyMap); } @@ -157,7 +155,7 @@ class HashTable * * @return IComparable */ - public function getByIndex($pIndex = 0) + public function getByIndex($pIndex) { if (isset($this->keyMap[$pIndex])) { return $this->getByHashCode($this->keyMap[$pIndex]); @@ -173,7 +171,7 @@ class HashTable * * @return IComparable */ - public function getByHashCode($pHashCode = '') + public function getByHashCode($pHashCode) { if (isset($this->items[$pHashCode])) { return $this->items[$pHashCode]; diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index 949cc87d..c59530a9 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -102,7 +102,7 @@ class IOFactory * @param string $location Example: PhpSpreadsheet/Writer/{0}.php * @param string $classname Example: Writer\{0} */ - public static function addSearchLocation($type = '', $location = '', $classname = '') + public static function addSearchLocation($type, $location, $classname) { self::$searchLocations[] = ['type' => $type, 'path' => $location, 'class' => $classname]; } @@ -151,7 +151,7 @@ class IOFactory * * @return Reader\IReader */ - public static function createReader($readerType = '') + public static function createReader($readerType) { // Search type $searchType = 'IReader'; diff --git a/src/PhpSpreadsheet/NamedRange.php b/src/PhpSpreadsheet/NamedRange.php index fffe7ee9..35942ea5 100644 --- a/src/PhpSpreadsheet/NamedRange.php +++ b/src/PhpSpreadsheet/NamedRange.php @@ -104,7 +104,7 @@ class NamedRange * * @return NamedRange */ - public function setName($value = null) + public function setName($value) { if ($value !== null) { // Old title @@ -171,7 +171,7 @@ class NamedRange * * @return NamedRange */ - public function setRange($value = null) + public function setRange($value) { if ($value !== null) { $this->range = $value; @@ -197,7 +197,7 @@ class NamedRange * * @return NamedRange */ - public function setLocalOnly($value = false) + public function setLocalOnly($value) { $this->localOnly = $value; $this->scope = $value ? $this->worksheet : null; diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index dd8d0769..5ef189f4 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -92,7 +92,7 @@ abstract class BaseReader implements IReader * * @return IReader */ - public function setReadDataOnly($pValue = false) + public function setReadDataOnly($pValue) { $this->readDataOnly = (bool) $pValue; @@ -120,7 +120,7 @@ abstract class BaseReader implements IReader * * @return IReader */ - public function setReadEmptyCells($pValue = true) + public function setReadEmptyCells($pValue) { $this->readEmptyCells = (bool) $pValue; @@ -150,7 +150,7 @@ abstract class BaseReader implements IReader * * @return IReader */ - public function setIncludeCharts($pValue = false) + public function setIncludeCharts($pValue) { $this->includeCharts = (bool) $pValue; @@ -178,7 +178,7 @@ abstract class BaseReader implements IReader * * @return IReader */ - public function setLoadSheetsOnly($value = null) + public function setLoadSheetsOnly($value) { if ($value === null) { return $this->setLoadAllSheets(); diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 5c623fa5..29876f77 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -81,9 +81,9 @@ class Csv extends BaseReader implements IReader /** * Set input encoding. * - * @param string $pValue Input encoding + * @param string $pValue Input encoding, eg: 'UTF-8' */ - public function setInputEncoding($pValue = 'UTF-8') + public function setInputEncoding($pValue) { $this->inputEncoding = $pValue; @@ -294,13 +294,13 @@ class Csv extends BaseReader implements IReader /** * Set delimiter. * - * @param string $pValue Delimiter, defaults to , + * @param string $delimiter Delimiter, eg: ',' * * @return CSV */ - public function setDelimiter($pValue = ',') + public function setDelimiter($delimiter) { - $this->delimiter = $pValue; + $this->delimiter = $delimiter; return $this; } @@ -318,16 +318,16 @@ class Csv extends BaseReader implements IReader /** * Set enclosure. * - * @param string $pValue Enclosure, defaults to " + * @param string $enclosure Enclosure, defaults to " * * @return CSV */ - public function setEnclosure($pValue = '"') + public function setEnclosure($enclosure) { - if ($pValue == '') { - $pValue = '"'; + if ($enclosure == '') { + $enclosure = '"'; } - $this->enclosure = $pValue; + $this->enclosure = $enclosure; return $this; } @@ -349,7 +349,7 @@ class Csv extends BaseReader implements IReader * * @return CSV */ - public function setSheetIndex($pValue = 0) + public function setSheetIndex($pValue) { $this->sheetIndex = $pValue; @@ -361,7 +361,7 @@ class Csv extends BaseReader implements IReader * * @param bool $contiguous */ - public function setContiguous($contiguous = false) + public function setContiguous($contiguous) { $this->contiguous = (bool) $contiguous; if (!$contiguous) { diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index c31ecd15..c6418704 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -804,7 +804,7 @@ class Gnumeric extends BaseReader implements IReader return $styleArray; } - private function parseRichText($is = '') + private function parseRichText($is) { $value = new \PhpOffice\PhpSpreadsheet\RichText(); $value->createText($is); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 95fccc61..2f0aa473 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -208,9 +208,9 @@ class Html extends BaseReader implements IReader /** * Set input encoding. * - * @param string $pValue Input encoding + * @param string $pValue Input encoding, eg: 'ANSI' */ - public function setInputEncoding($pValue = 'ANSI') + public function setInputEncoding($pValue) { $this->inputEncoding = $pValue; @@ -263,7 +263,7 @@ class Html extends BaseReader implements IReader // Only actually write it if there's content in the string // Write to worksheet to be done here... // ... we return the cell so we can mess about with styles more easily - $sheet->setCellValue($column . $row, $cellContent, true); + $sheet->setCellValue($column . $row, $cellContent); $this->dataArray[$row][$column] = $cellContent; } } else { @@ -556,7 +556,7 @@ class Html extends BaseReader implements IReader * * @return HTML */ - public function setSheetIndex($pValue = 0) + public function setSheetIndex($pValue) { $this->sheetIndex = $pValue; diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 075b4e52..ac629aca 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -797,7 +797,7 @@ class Ods extends BaseReader implements IReader * * @return \PhpOffice\PhpSpreadsheet\RichText */ - private function parseRichText($is = '') + private function parseRichText($is) { $value = new \PhpOffice\PhpSpreadsheet\RichText(); $value->createText($is); diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 6e422fb6..dbe2cd0f 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -99,9 +99,9 @@ class Slk extends BaseReader implements IReader /** * Set input encoding. * - * @param string $pValue Input encoding + * @param string $pValue Input encoding, eg: 'ANSI' */ - public function setInputEncoding($pValue = 'ANSI') + public function setInputEncoding($pValue) { $this->inputEncoding = $pValue; @@ -474,7 +474,7 @@ class Slk extends BaseReader implements IReader * * @return SYLK */ - public function setSheetIndex($pValue = 0) + public function setSheetIndex($pValue) { $this->sheetIndex = $pValue; diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index af6def07..801b27d7 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -7465,7 +7465,7 @@ class Xls extends BaseReader implements IReader return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24; } - private function parseRichText($is = '') + private function parseRichText($is) { $value = new \PhpOffice\PhpSpreadsheet\RichText(); $value->createText($is); diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 5d582e25..a0e98187 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -2034,7 +2034,7 @@ class Xlsx extends BaseReader implements IReader * * @return RichText */ - private function parseRichText($is = null) + private function parseRichText($is) { $value = new RichText(); @@ -2179,7 +2179,7 @@ class Xlsx extends BaseReader implements IReader return $style; } - private static function boolean($value = null) + private static function boolean($value) { if (is_object($value)) { $value = (string) $value; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index af96c998..48564d6d 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -88,17 +88,17 @@ class Chart break; case 'catAx': if (isset($chartDetail->title)) { - $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat'); + $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); } break; case 'dateAx': if (isset($chartDetail->title)) { - $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat'); + $XaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); } break; case 'valAx': if (isset($chartDetail->title)) { - $YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta, 'cat'); + $YaxisLabel = self::chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta); } break; case 'barChart': @@ -176,7 +176,7 @@ class Chart $dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string'); break; case 'title': - $title = self::chartTitle($chartDetails, $namespacesChartMeta, 'title'); + $title = self::chartTitle($chartDetails, $namespacesChartMeta); break; case 'legend': $legendPos = 'r'; @@ -206,7 +206,7 @@ class Chart return $chart; } - private static function chartTitle($titleDetails, $namespacesChartMeta, $type) + private static function chartTitle(\SimpleXMLElement $titleDetails, array $namespacesChartMeta) { $caption = []; $titleLayout = null; @@ -399,7 +399,7 @@ class Chart ]; } - private static function parseRichText($titleDetailPart = null) + private static function parseRichText(\SimpleXMLElement $titleDetailPart) { $value = new \PhpOffice\PhpSpreadsheet\RichText(); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php index 5767ded8..ba014537 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php @@ -96,7 +96,7 @@ class Theme * * @return string */ - public function getColourByIndex($index = 0) + public function getColourByIndex($index) { if (isset($this->colourMap[$index])) { return $this->colourMap[$index]; diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index df0fa48e..00e29808 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -770,7 +770,7 @@ class Xml extends BaseReader implements IReader return $string; } - protected function parseRichText($is = '') + protected function parseRichText($is) { $value = new \PhpOffice\PhpSpreadsheet\RichText(); diff --git a/src/PhpSpreadsheet/RichText.php b/src/PhpSpreadsheet/RichText.php index 5f4efe2a..f6d56772 100644 --- a/src/PhpSpreadsheet/RichText.php +++ b/src/PhpSpreadsheet/RichText.php @@ -84,7 +84,7 @@ class RichText implements IComparable * * @return RichText\TextElement */ - public function createText($pText = '') + public function createText($pText) { $objText = new RichText\TextElement($pText); $this->addText($objText); @@ -101,7 +101,7 @@ class RichText implements IComparable * * @return RichText\Run */ - public function createTextRun($pText = '') + public function createTextRun($pText) { $objText = new RichText\Run($pText); $this->addText($objText); @@ -150,19 +150,15 @@ class RichText implements IComparable /** * Set Rich Text elements. * - * @param RichText\ITextElement[] $pElements Array of elements + * @param RichText\ITextElement[] $textElements Array of elements * * @throws Exception * * @return RichText */ - public function setRichTextElements($pElements = null) + public function setRichTextElements(array $textElements) { - if (is_array($pElements)) { - $this->richTextElements = $pElements; - } else { - throw new Exception("Invalid \PhpOffice\PhpSpreadsheet\RichText\ITextElement[] array passed."); - } + $this->richTextElements = $textElements; return $this; } diff --git a/src/PhpSpreadsheet/RichText/ITextElement.php b/src/PhpSpreadsheet/RichText/ITextElement.php index ae8081da..c69916e1 100644 --- a/src/PhpSpreadsheet/RichText/ITextElement.php +++ b/src/PhpSpreadsheet/RichText/ITextElement.php @@ -34,11 +34,11 @@ interface ITextElement /** * Set text. * - * @param $pText string Text + * @param $text string Text * * @return ITextElement */ - public function setText($pText = ''); + public function setText($text); /** * Get font. diff --git a/src/PhpSpreadsheet/RichText/TextElement.php b/src/PhpSpreadsheet/RichText/TextElement.php index 4bf405e7..5bc9bfca 100644 --- a/src/PhpSpreadsheet/RichText/TextElement.php +++ b/src/PhpSpreadsheet/RichText/TextElement.php @@ -55,13 +55,13 @@ class TextElement implements ITextElement /** * Set text. * - * @param $pText string Text + * @param $text string Text * * @return ITextElement */ - public function setText($pText = '') + public function setText($text) { - $this->text = $pText; + $this->text = $text; return $this; } diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 62371bdd..e3bac89d 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -92,7 +92,7 @@ class Settings * * @return bool Success or failure */ - public static function setLocale($locale = 'en_us') + public static function setLocale($locale) { return Calculation::getInstance()->setLocale($locale); } @@ -208,7 +208,7 @@ class Settings * * @param int $options Default options for libxml loader */ - public static function setLibXmlLoaderOptions($options = null) + public static function setLibXmlLoaderOptions($options) { if (is_null($options) && defined('LIBXML_DTDLOAD')) { $options = LIBXML_DTDLOAD | LIBXML_DTDATTR; diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index 4645e9fd..6e56d231 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -36,7 +36,7 @@ class CodePage * * @return string Code Page Name */ - public static function numberToName($codePage = 1252) + public static function numberToName($codePage) { switch ($codePage) { case 367: diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index d04e0bdc..cc1638d9 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -176,7 +176,7 @@ class Date * * @return \DateTime PHP date/time object */ - public static function excelToDateTimeObject($excelTimestamp = 0, $timeZone = null) + public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) { $timeZone = ($timeZone === null) ? self::getDefaultTimezone() : self::validateTimeZone($timeZone); if ($excelTimestamp < 1.0) { @@ -217,7 +217,7 @@ class Date * * @return int Unix timetamp for this date/time */ - public static function excelToTimestamp($excelTimestamp = 0, $timeZone = null) + public static function excelToTimestamp($excelTimestamp, $timeZone = null) { return (int) self::excelToDateTimeObject($excelTimestamp, $timeZone) ->format('U'); @@ -231,7 +231,7 @@ class Date * @return float|bool Excel date/time value * or boolean FALSE on failure */ - public static function PHPToExcel($dateValue = 0) + public static function PHPToExcel($dateValue) { if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) { return self::dateTimeToExcel($dateValue); @@ -270,7 +270,7 @@ class Date * * @return float MS Excel serialized date/time value */ - public static function timestampToExcel($dateValue = 0) + public static function timestampToExcel($dateValue) { if (!is_numeric($dateValue)) { return false; @@ -363,7 +363,7 @@ class Date * * @return bool */ - public static function isDateTimeFormatCode($pFormatCode = '') + public static function isDateTimeFormatCode($pFormatCode) { if (strtolower($pFormatCode) === strtolower(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_GENERAL)) { // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) @@ -437,7 +437,7 @@ class Date * * @return float|false Excel date/time serial value */ - public static function stringToExcel($dateValue = '') + public static function stringToExcel($dateValue) { if (strlen($dateValue) < 2) { return false; diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index 969d9bf8..436112be 100644 --- a/src/PhpSpreadsheet/Shared/Drawing.php +++ b/src/PhpSpreadsheet/Shared/Drawing.php @@ -33,7 +33,7 @@ class Drawing * * @return int Value in EMU */ - public static function pixelsToEMU($pValue = 0) + public static function pixelsToEMU($pValue) { return round($pValue * 9525); } @@ -45,7 +45,7 @@ class Drawing * * @return int Value in pixels */ - public static function EMUToPixels($pValue = 0) + public static function EMUToPixels($pValue) { if ($pValue != 0) { return round($pValue / 9525); @@ -118,7 +118,7 @@ class Drawing * * @return float Value in points */ - public static function pixelsToPoints($pValue = 0) + public static function pixelsToPoints($pValue) { return $pValue * 0.67777777; } @@ -130,7 +130,7 @@ class Drawing * * @return int Value in pixels */ - public static function pointsToPixels($pValue = 0) + public static function pointsToPixels($pValue) { if ($pValue != 0) { return (int) ceil($pValue * 1.333333333); @@ -146,7 +146,7 @@ class Drawing * * @return int Angle */ - public static function degreesToAngle($pValue = 0) + public static function degreesToAngle($pValue) { return (int) round($pValue * 60000); } @@ -158,7 +158,7 @@ class Drawing * * @return int Degrees */ - public static function angleToDegrees($pValue = 0) + public static function angleToDegrees($pValue) { if ($pValue != 0) { return round($pValue / 60000); diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index a1eac1df..c2b6787a 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -135,7 +135,7 @@ class SpContainer * * @param bool $value */ - public function setSpgr($value = false) + public function setSpgr($value) { $this->spgr = $value; } @@ -250,9 +250,9 @@ class SpContainer /** * Set cell coordinates of upper-left corner of shape. * - * @param string $value + * @param string $value eg: 'A1' */ - public function setStartCoordinates($value = 'A1') + public function setStartCoordinates($value) { $this->startCoordinates = $value; } @@ -272,7 +272,7 @@ class SpContainer * * @param int $startOffsetX */ - public function setStartOffsetX($startOffsetX = 0) + public function setStartOffsetX($startOffsetX) { $this->startOffsetX = $startOffsetX; } @@ -292,7 +292,7 @@ class SpContainer * * @param int $startOffsetY */ - public function setStartOffsetY($startOffsetY = 0) + public function setStartOffsetY($startOffsetY) { $this->startOffsetY = $startOffsetY; } @@ -310,9 +310,9 @@ class SpContainer /** * Set cell coordinates of bottom-right corner of shape. * - * @param string $value + * @param string $value eg: 'A1' */ - public function setEndCoordinates($value = 'A1') + public function setEndCoordinates($value) { $this->endCoordinates = $value; } @@ -332,7 +332,7 @@ class SpContainer * * @param int $endOffsetX */ - public function setEndOffsetX($endOffsetX = 0) + public function setEndOffsetX($endOffsetX) { $this->endOffsetX = $endOffsetX; } @@ -352,7 +352,7 @@ class SpContainer * * @param int $endOffsetY */ - public function setEndOffsetY($endOffsetY = 0) + public function setEndOffsetY($endOffsetY) { $this->endOffsetY = $endOffsetY; } diff --git a/src/PhpSpreadsheet/Shared/File.php b/src/PhpSpreadsheet/Shared/File.php index b6883726..9efd83ff 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -42,7 +42,7 @@ class File * * @param bool $useUploadTempDir Use File Upload Temporary directory (true or false) */ - public static function setUseUploadTempDirectory($useUploadTempDir = false) + public static function setUseUploadTempDirectory($useUploadTempDir) { self::$useUploadTempDirectory = (bool) $useUploadTempDir; } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index dbef7701..c305579c 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -182,11 +182,11 @@ class Font /** * Set autoSize method. * - * @param string $pValue + * @param string $pValue see self::AUTOSIZE_METHOD_* * * @return bool Success or failure */ - public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX) + public static function setAutoSizeMethod($pValue) { if (!in_array($pValue, self::$autoSizeMethods)) { return false; @@ -217,7 +217,7 @@ class Font * * @param string $pValue */ - public static function setTrueTypeFontPath($pValue = '') + public static function setTrueTypeFontPath($pValue) { self::$trueTypeFontPath = $pValue; } @@ -382,7 +382,7 @@ class Font * * @return int Font size (in pixels) */ - public static function fontSizeToPixels($fontSizeInPoints = 11) + public static function fontSizeToPixels($fontSizeInPoints) { return (int) ((4 / 3) * $fontSizeInPoints); } @@ -394,7 +394,7 @@ class Font * * @return int Size (in pixels) */ - public static function inchSizeToPixels($sizeInInch = 1) + public static function inchSizeToPixels($sizeInInch) { return $sizeInInch * 96; } @@ -406,7 +406,7 @@ class Font * * @return float Size (in pixels) */ - public static function centimeterSizeToPixels($sizeInCm = 1) + public static function centimeterSizeToPixels($sizeInCm) { return $sizeInCm * 37.795275591; } diff --git a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php index 79b96566..99d20d8f 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/CholeskyDecomposition.php @@ -48,41 +48,35 @@ class CholeskyDecomposition * @param mixed Matrix square symmetric positive definite matrix * @param null|mixed $A */ - public function __construct($A = null) + public function __construct(Matrix $A) { - if ($A instanceof Matrix) { - $this->L = $A->getArray(); - $this->m = $A->getRowDimension(); + $this->L = $A->getArray(); + $this->m = $A->getRowDimension(); - for ($i = 0; $i < $this->m; ++$i) { - for ($j = $i; $j < $this->m; ++$j) { - for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { - $sum -= $this->L[$i][$k] * $this->L[$j][$k]; - } - if ($i == $j) { - if ($sum >= 0) { - $this->L[$i][$i] = sqrt($sum); - } else { - $this->isspd = false; - } - } else { - if ($this->L[$i][$i] != 0) { - $this->L[$j][$i] = $sum / $this->L[$i][$i]; - } - } + for ($i = 0; $i < $this->m; ++$i) { + for ($j = $i; $j < $this->m; ++$j) { + for ($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) { + $sum -= $this->L[$i][$k] * $this->L[$j][$k]; } - - for ($k = $i + 1; $k < $this->m; ++$k) { - $this->L[$i][$k] = 0.0; + if ($i == $j) { + if ($sum >= 0) { + $this->L[$i][$i] = sqrt($sum); + } else { + $this->isspd = false; + } + } else { + if ($this->L[$i][$i] != 0) { + $this->L[$j][$i] = $sum / $this->L[$i][$i]; + } } } - } else { - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(ARGUMENT_TYPE_EXCEPTION)); + + for ($k = $i + 1; $k < $this->m; ++$k) { + $this->L[$i][$k] = 0.0; + } } } - // function __construct() - /** * Is the matrix symmetric and positive definite? * @@ -93,8 +87,6 @@ class CholeskyDecomposition return $this->isspd; } - // function isSPD() - /** * getL. * @@ -107,8 +99,6 @@ class CholeskyDecomposition return new Matrix($this->L); } - // function getL() - /** * Solve A*X = B. * @@ -116,44 +106,39 @@ class CholeskyDecomposition * * @return Matrix L * L' * X = B */ - public function solve($B = null) + public function solve(Matrix $B) { - if ($B instanceof Matrix) { - if ($B->getRowDimension() == $this->m) { - if ($this->isspd) { - $X = $B->getArrayCopy(); - $nx = $B->getColumnDimension(); + if ($B->getRowDimension() == $this->m) { + if ($this->isspd) { + $X = $B->getArrayCopy(); + $nx = $B->getColumnDimension(); - for ($k = 0; $k < $this->m; ++$k) { - for ($i = $k + 1; $i < $this->m; ++$i) { - for ($j = 0; $j < $nx; ++$j) { - $X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k]; - } - } + for ($k = 0; $k < $this->m; ++$k) { + for ($i = $k + 1; $i < $this->m; ++$i) { for ($j = 0; $j < $nx; ++$j) { - $X[$k][$j] /= $this->L[$k][$k]; + $X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k]; } } - - for ($k = $this->m - 1; $k >= 0; --$k) { - for ($j = 0; $j < $nx; ++$j) { - $X[$k][$j] /= $this->L[$k][$k]; - } - for ($i = 0; $i < $k; ++$i) { - for ($j = 0; $j < $nx; ++$j) { - $X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i]; - } - } + for ($j = 0; $j < $nx; ++$j) { + $X[$k][$j] /= $this->L[$k][$k]; } - - return new Matrix($X, $this->m, $nx); } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixSPDException)); - } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MATRIX_DIMENSION_EXCEPTION)); - } - throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(ARGUMENT_TYPE_EXCEPTION)); - } - // function solve() + for ($k = $this->m - 1; $k >= 0; --$k) { + for ($j = 0; $j < $nx; ++$j) { + $X[$k][$j] /= $this->L[$k][$k]; + } + for ($i = 0; $i < $k; ++$i) { + for ($j = 0; $j < $nx; ++$j) { + $X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i]; + } + } + } + + return new Matrix($X, $this->m, $nx); + } + throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MatrixSPDException)); + } + throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(JAMAError(MATRIX_DIMENSION_EXCEPTION)); + } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php b/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php index cc6a25e7..8aa78c55 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php +++ b/src/PhpSpreadsheet/Shared/JAMA/utils/Error.php @@ -67,17 +67,13 @@ $error['EN'][ROW_LENGTH_EXCEPTION] = 'All rows must have the same length.'; * * @param int $errorNumber Error number */ -function JAMAError($errorNumber = null) +function JAMAError($errorNumber) { global $error; - if (isset($errorNumber)) { - if (isset($error[JAMALANG][$errorNumber])) { - return $error[JAMALANG][$errorNumber]; - } - - return $error['EN'][$errorNumber]; + if (isset($error[JAMALANG][$errorNumber])) { + return $error[JAMALANG][$errorNumber]; } - return 'Invalid argument to JAMAError()'; + return $error['EN'][$errorNumber]; } diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 33153c57..a2763f72 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -486,7 +486,7 @@ class OLE * * @return string The string for the OLE container */ - public static function localDateToOLE($date = null) + public static function localDateToOLE($date) { if (!isset($date)) { return "\x00\x00\x00\x00\x00\x00\x00\x00"; diff --git a/src/PhpSpreadsheet/Shared/PasswordHasher.php b/src/PhpSpreadsheet/Shared/PasswordHasher.php index f47a6573..2a546e0d 100644 --- a/src/PhpSpreadsheet/Shared/PasswordHasher.php +++ b/src/PhpSpreadsheet/Shared/PasswordHasher.php @@ -37,7 +37,7 @@ class PasswordHasher * * @return string Hashed password */ - public static function hashPassword($pPassword = '') + public static function hashPassword($pPassword) { $password = 0x0000; $charPos = 1; // char position diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 2273333d..b1d51250 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -323,7 +323,7 @@ class StringHelper * * @return string */ - public static function controlCharacterOOXML2PHP($value = '') + public static function controlCharacterOOXML2PHP($value) { return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value); } @@ -343,7 +343,7 @@ class StringHelper * * @return string */ - public static function controlCharacterPHP2OOXML($value = '') + public static function controlCharacterPHP2OOXML($value) { return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value); } @@ -375,7 +375,7 @@ class StringHelper * * @return bool */ - public static function isUTF8($value = '') + public static function isUTF8($value) { return $value === '' || preg_match('/^./su', $value) === 1; } @@ -499,7 +499,7 @@ class StringHelper * * @return string */ - public static function substring($pValue = '', $pStart = 0, $pLength = 0) + public static function substring($pValue, $pStart, $pLength = 0) { return mb_substr($pValue, $pStart, $pLength, 'UTF-8'); } @@ -511,7 +511,7 @@ class StringHelper * * @return string */ - public static function strToUpper($pValue = '') + public static function strToUpper($pValue) { return mb_convert_case($pValue, MB_CASE_UPPER, 'UTF-8'); } @@ -523,7 +523,7 @@ class StringHelper * * @return string */ - public static function strToLower($pValue = '') + public static function strToLower($pValue) { return mb_convert_case($pValue, MB_CASE_LOWER, 'UTF-8'); } @@ -536,7 +536,7 @@ class StringHelper * * @return string */ - public static function strToTitle($pValue = '') + public static function strToTitle($pValue) { return mb_convert_case($pValue, MB_CASE_TITLE, 'UTF-8'); } @@ -561,7 +561,7 @@ class StringHelper * * @return string */ - public static function strCaseReverse($pValue = '') + public static function strCaseReverse($pValue) { $characters = self::mbStrSplit($pValue); foreach ($characters as &$character) { @@ -626,7 +626,7 @@ class StringHelper * * @param string $pValue Character for decimal separator */ - public static function setDecimalSeparator($pValue = '.') + public static function setDecimalSeparator($pValue) { self::$decimalSeparator = $pValue; } @@ -659,7 +659,7 @@ class StringHelper * * @param string $pValue Character for thousands separator */ - public static function setThousandsSeparator($pValue = ',') + public static function setThousandsSeparator($pValue) { self::$thousandsSeparator = $pValue; } @@ -697,7 +697,7 @@ class StringHelper * * @param string $pValue Character for currency code */ - public static function setCurrencyCode($pValue = '$') + public static function setCurrencyCode($pValue) { self::$currencyCode = $pValue; } @@ -709,7 +709,7 @@ class StringHelper * * @return string UTF-8 encoded string */ - public static function SYLKtoUTF8($pValue = '') + public static function SYLKtoUTF8($pValue) { // If there is no escape character in the string there is nothing to do if (strpos($pValue, '') === false) { diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 1893922f..2724286b 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -148,7 +148,7 @@ class Spreadsheet * * @param bool $hasMacros true|false */ - public function setHasMacros($hasMacros = false) + public function setHasMacros($hasMacros) { $this->hasMacros = (bool) $hasMacros; } @@ -158,7 +158,7 @@ class Spreadsheet * * @param string $macroCode string|null */ - public function setMacrosCode($macroCode = null) + public function setMacrosCode($macroCode) { $this->macrosCode = $macroCode; $this->setHasMacros(!is_null($macroCode)); @@ -179,7 +179,7 @@ class Spreadsheet * * @param string|null $certificate */ - public function setMacrosCertificate($certificate = null) + public function setMacrosCertificate($certificate) { $this->macrosCertificate = $certificate; } @@ -220,7 +220,7 @@ class Spreadsheet * @param null|mixed $target * @param null|mixed $xmlData */ - public function setRibbonXMLData($target = null, $xmlData = null) + public function setRibbonXMLData($target, $xmlData) { if (!is_null($target) && !is_null($xmlData)) { $this->ribbonXMLData = ['target' => $target, 'data' => $xmlData]; @@ -234,7 +234,7 @@ class Spreadsheet * * return string|null|array * - * @param mixed $what + * @param string $what * * @return string */ @@ -263,7 +263,7 @@ class Spreadsheet * @param null|mixed $BinObjectsNames * @param null|mixed $BinObjectsData */ - public function setRibbonBinObjects($BinObjectsNames = null, $BinObjectsData = null) + public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData) { if (!is_null($BinObjectsNames) && !is_null($BinObjectsData)) { $this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData]; @@ -285,20 +285,20 @@ class Spreadsheet /** * retrieve Binaries Ribbon Objects. * - * @param mixed $What + * @param mixed $what */ - public function getRibbonBinObjects($What = 'all') + public function getRibbonBinObjects($what = 'all') { $ReturnData = null; - $What = strtolower($What); - switch ($What) { + $what = strtolower($what); + switch ($what) { case 'all': return $this->ribbonBinObjects; break; case 'names': case 'data': - if (is_array($this->ribbonBinObjects) && isset($this->ribbonBinObjects[$What])) { - $ReturnData = $this->ribbonBinObjects[$What]; + if (is_array($this->ribbonBinObjects) && isset($this->ribbonBinObjects[$what])) { + $ReturnData = $this->ribbonBinObjects[$what]; } break; case 'types': @@ -354,7 +354,7 @@ class Spreadsheet * * @return Worksheet */ - public function getSheetByCodeName($pName = '') + public function getSheetByCodeName($pName) { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -486,16 +486,16 @@ class Spreadsheet /** * Create sheet and add it to this workbook. * - * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last) + * @param int|null $sheetIndex Index where sheet should go (0,1,..., or null for last) * * @throws Exception * * @return Worksheet */ - public function createSheet($iSheetIndex = null) + public function createSheet($sheetIndex = null) { $newSheet = new Worksheet($this); - $this->addSheet($newSheet, $iSheetIndex); + $this->addSheet($newSheet, $sheetIndex); return $newSheet; } @@ -564,7 +564,7 @@ class Spreadsheet * * @throws Exception */ - public function removeSheetByIndex($pIndex = 0) + public function removeSheetByIndex($pIndex) { $numSheets = count($this->workSheetCollection); if ($pIndex > $numSheets - 1) { @@ -590,7 +590,7 @@ class Spreadsheet * * @return Worksheet */ - public function getSheet($pIndex = 0) + public function getSheet($pIndex) { if (!isset($this->workSheetCollection[$pIndex])) { $numSheets = $this->getSheetCount(); @@ -619,7 +619,7 @@ class Spreadsheet * * @return Worksheet */ - public function getSheetByName($pName = '') + public function getSheetByName($pName) { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -708,7 +708,7 @@ class Spreadsheet * * @return Worksheet */ - public function setActiveSheetIndex($pIndex = 0) + public function setActiveSheetIndex($pIndex) { $numSheets = count($this->workSheetCollection); @@ -731,7 +731,7 @@ class Spreadsheet * * @return Worksheet */ - public function setActiveSheetIndexByName($pValue = '') + public function setActiveSheetIndexByName($pValue) { if (($worksheet = $this->getSheetByName($pValue)) instanceof Worksheet) { $this->setActiveSheetIndex($this->getIndex($worksheet)); @@ -931,7 +931,7 @@ class Spreadsheet * * @return Style */ - public function getCellXfByIndex($pIndex = 0) + public function getCellXfByIndex($pIndex) { return $this->cellXfCollection[$pIndex]; } @@ -943,7 +943,7 @@ class Spreadsheet * * @return Style|false */ - public function getCellXfByHashCode($pValue = '') + public function getCellXfByHashCode($pValue) { foreach ($this->cellXfCollection as $cellXf) { if ($cellXf->getHashCode() == $pValue) { @@ -961,7 +961,7 @@ class Spreadsheet * * @return bool */ - public function cellXfExists($pCellStyle = null) + public function cellXfExists($pCellStyle) { return in_array($pCellStyle, $this->cellXfCollection, true); } @@ -999,7 +999,7 @@ class Spreadsheet * * @throws Exception */ - public function removeCellXfByIndex($pIndex = 0) + public function removeCellXfByIndex($pIndex) { if ($pIndex > count($this->cellXfCollection) - 1) { throw new Exception('CellXf index is out of bounds.'); @@ -1051,7 +1051,7 @@ class Spreadsheet * * @return Style */ - public function getCellStyleXfByIndex($pIndex = 0) + public function getCellStyleXfByIndex($pIndex) { return $this->cellStyleXfCollection[$pIndex]; } @@ -1063,7 +1063,7 @@ class Spreadsheet * * @return Style|false */ - public function getCellStyleXfByHashCode($pValue = '') + public function getCellStyleXfByHashCode($pValue) { foreach ($this->cellStyleXfCollection as $cellStyleXf) { if ($cellStyleXf->getHashCode() == $pValue) { @@ -1092,7 +1092,7 @@ class Spreadsheet * * @throws Exception */ - public function removeCellStyleXfByIndex($pIndex = 0) + public function removeCellStyleXfByIndex($pIndex) { if ($pIndex > count($this->cellStyleXfCollection) - 1) { throw new Exception('CellStyleXf index is out of bounds.'); diff --git a/src/PhpSpreadsheet/Style.php b/src/PhpSpreadsheet/Style.php index b8c0675f..65902077 100644 --- a/src/PhpSpreadsheet/Style.php +++ b/src/PhpSpreadsheet/Style.php @@ -208,263 +208,259 @@ class Style extends Style\Supervisor implements IComparable * * @return Style */ - public function applyFromArray($pStyles = null, $pAdvanced = true) + public function applyFromArray(array $pStyles, $pAdvanced = true) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $pRange = $this->getSelectedCells(); + if ($this->isSupervisor) { + $pRange = $this->getSelectedCells(); - // Uppercase coordinate - $pRange = strtoupper($pRange); + // Uppercase coordinate + $pRange = strtoupper($pRange); - // Is it a cell range or a single cell? - if (strpos($pRange, ':') === false) { - $rangeA = $pRange; - $rangeB = $pRange; - } else { - list($rangeA, $rangeB) = explode(':', $pRange); - } - - // Calculate range outer borders - $rangeStart = Cell::coordinateFromString($rangeA); - $rangeEnd = Cell::coordinateFromString($rangeB); - - // Translate column into index - $rangeStart[0] = Cell::columnIndexFromString($rangeStart[0]) - 1; - $rangeEnd[0] = Cell::columnIndexFromString($rangeEnd[0]) - 1; - - // Make sure we can loop upwards on rows and columns - if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { - $tmp = $rangeStart; - $rangeStart = $rangeEnd; - $rangeEnd = $tmp; - } - - // ADVANCED MODE: - if ($pAdvanced && isset($pStyles['borders'])) { - // 'allborders' is a shorthand property for 'outline' and 'inside' and - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['allborders'])) { - foreach (['outline', 'inside'] as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['allborders']; - } - } - unset($pStyles['borders']['allborders']); // not needed any more - } - // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['outline'])) { - foreach (['top', 'right', 'bottom', 'left'] as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['outline']; - } - } - unset($pStyles['borders']['outline']); // not needed any more - } - // 'inside' is a shorthand property for 'vertical' and 'horizontal' - // it applies to components that have not been set explicitly - if (isset($pStyles['borders']['inside'])) { - foreach (['vertical', 'horizontal'] as $component) { - if (!isset($pStyles['borders'][$component])) { - $pStyles['borders'][$component] = $pStyles['borders']['inside']; - } - } - unset($pStyles['borders']['inside']); // not needed any more - } - // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) - $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); - $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); - - // loop through up to 3 x 3 = 9 regions - for ($x = 1; $x <= $xMax; ++$x) { - // start column index for region - $colStart = ($x == 3) ? - Cell::stringFromColumnIndex($rangeEnd[0]) - : Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); - // end column index for region - $colEnd = ($x == 1) ? - Cell::stringFromColumnIndex($rangeStart[0]) - : Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); - - for ($y = 1; $y <= $yMax; ++$y) { - // which edges are touching the region - $edges = []; - if ($x == 1) { - // are we at left edge - $edges[] = 'left'; - } - if ($x == $xMax) { - // are we at right edge - $edges[] = 'right'; - } - if ($y == 1) { - // are we at top edge? - $edges[] = 'top'; - } - if ($y == $yMax) { - // are we at bottom edge? - $edges[] = 'bottom'; - } - - // start row index for region - $rowStart = ($y == 3) ? - $rangeEnd[1] : $rangeStart[1] + $y - 1; - - // end row index for region - $rowEnd = ($y == 1) ? - $rangeStart[1] : $rangeEnd[1] - $yMax + $y; - - // build range for region - $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; - - // retrieve relevant style array for region - $regionStyles = $pStyles; - unset($regionStyles['borders']['inside']); - - // what are the inner edges of the region when looking at the selection - $innerEdges = array_diff(['top', 'right', 'bottom', 'left'], $edges); - - // inner edges that are not touching the region should take the 'inside' border properties if they have been set - foreach ($innerEdges as $innerEdge) { - switch ($innerEdge) { - case 'top': - case 'bottom': - // should pick up 'horizontal' border property if set - if (isset($pStyles['borders']['horizontal'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - case 'left': - case 'right': - // should pick up 'vertical' border property if set - if (isset($pStyles['borders']['vertical'])) { - $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; - } else { - unset($regionStyles['borders'][$innerEdge]); - } - break; - } - } - - // apply region style to region by calling applyFromArray() in simple mode - $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); - } - } - - return $this; - } - - // SIMPLE MODE: - // Selection type, inspect - if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { - $selectionType = 'COLUMN'; - } elseif (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { - $selectionType = 'ROW'; - } else { - $selectionType = 'CELL'; - } - - // First loop through columns, rows, or cells to find out which styles are affected by this operation - switch ($selectionType) { - case 'COLUMN': - $oldXfIndexes = []; - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; - } - break; - case 'ROW': - $oldXfIndexes = []; - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { - $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style - } else { - $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; - } - } - break; - case 'CELL': - $oldXfIndexes = []; - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; - } - } - break; - } - - // clone each of the affected styles, apply the style array, and add the new styles to the workbook - $workbook = $this->getActiveSheet()->getParent(); - foreach ($oldXfIndexes as $oldXfIndex => $dummy) { - $style = $workbook->getCellXfByIndex($oldXfIndex); - $newStyle = clone $style; - $newStyle->applyFromArray($pStyles); - - if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { - // there is already such cell Xf in our collection - $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); - } else { - // we don't have such a cell Xf, need to add - $workbook->addCellXf($newStyle); - $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); - } - } - - // Loop through columns, rows, or cells again and update the XF index - switch ($selectionType) { - case 'COLUMN': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); - $oldXfIndex = $columnDimension->getXfIndex(); - $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; - case 'ROW': - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $rowDimension = $this->getActiveSheet()->getRowDimension($row); - $oldXfIndex = $rowDimension->getXfIndex() === null ? - 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style - $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); - } - break; - case 'CELL': - for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { - for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { - $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); - $oldXfIndex = $cell->getXfIndex(); - $cell->setXfIndex($newXfIndexes[$oldXfIndex]); - } - } - break; - } + // Is it a cell range or a single cell? + if (strpos($pRange, ':') === false) { + $rangeA = $pRange; + $rangeB = $pRange; } else { - // not a supervisor, just apply the style array directly on style object - if (isset($pStyles['fill'])) { - $this->getFill()->applyFromArray($pStyles['fill']); + list($rangeA, $rangeB) = explode(':', $pRange); + } + + // Calculate range outer borders + $rangeStart = Cell::coordinateFromString($rangeA); + $rangeEnd = Cell::coordinateFromString($rangeB); + + // Translate column into index + $rangeStart[0] = Cell::columnIndexFromString($rangeStart[0]) - 1; + $rangeEnd[0] = Cell::columnIndexFromString($rangeEnd[0]) - 1; + + // Make sure we can loop upwards on rows and columns + if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) { + $tmp = $rangeStart; + $rangeStart = $rangeEnd; + $rangeEnd = $tmp; + } + + // ADVANCED MODE: + if ($pAdvanced && isset($pStyles['borders'])) { + // 'allborders' is a shorthand property for 'outline' and 'inside' and + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['allborders'])) { + foreach (['outline', 'inside'] as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['allborders']; + } + } + unset($pStyles['borders']['allborders']); // not needed any more } - if (isset($pStyles['font'])) { - $this->getFont()->applyFromArray($pStyles['font']); + // 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['outline'])) { + foreach (['top', 'right', 'bottom', 'left'] as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['outline']; + } + } + unset($pStyles['borders']['outline']); // not needed any more } - if (isset($pStyles['borders'])) { - $this->getBorders()->applyFromArray($pStyles['borders']); + // 'inside' is a shorthand property for 'vertical' and 'horizontal' + // it applies to components that have not been set explicitly + if (isset($pStyles['borders']['inside'])) { + foreach (['vertical', 'horizontal'] as $component) { + if (!isset($pStyles['borders'][$component])) { + $pStyles['borders'][$component] = $pStyles['borders']['inside']; + } + } + unset($pStyles['borders']['inside']); // not needed any more } - if (isset($pStyles['alignment'])) { - $this->getAlignment()->applyFromArray($pStyles['alignment']); + // width and height characteristics of selection, 1, 2, or 3 (for 3 or more) + $xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3); + $yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3); + + // loop through up to 3 x 3 = 9 regions + for ($x = 1; $x <= $xMax; ++$x) { + // start column index for region + $colStart = ($x == 3) ? + Cell::stringFromColumnIndex($rangeEnd[0]) + : Cell::stringFromColumnIndex($rangeStart[0] + $x - 1); + // end column index for region + $colEnd = ($x == 1) ? + Cell::stringFromColumnIndex($rangeStart[0]) + : Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x); + + for ($y = 1; $y <= $yMax; ++$y) { + // which edges are touching the region + $edges = []; + if ($x == 1) { + // are we at left edge + $edges[] = 'left'; + } + if ($x == $xMax) { + // are we at right edge + $edges[] = 'right'; + } + if ($y == 1) { + // are we at top edge? + $edges[] = 'top'; + } + if ($y == $yMax) { + // are we at bottom edge? + $edges[] = 'bottom'; + } + + // start row index for region + $rowStart = ($y == 3) ? + $rangeEnd[1] : $rangeStart[1] + $y - 1; + + // end row index for region + $rowEnd = ($y == 1) ? + $rangeStart[1] : $rangeEnd[1] - $yMax + $y; + + // build range for region + $range = $colStart . $rowStart . ':' . $colEnd . $rowEnd; + + // retrieve relevant style array for region + $regionStyles = $pStyles; + unset($regionStyles['borders']['inside']); + + // what are the inner edges of the region when looking at the selection + $innerEdges = array_diff(['top', 'right', 'bottom', 'left'], $edges); + + // inner edges that are not touching the region should take the 'inside' border properties if they have been set + foreach ($innerEdges as $innerEdge) { + switch ($innerEdge) { + case 'top': + case 'bottom': + // should pick up 'horizontal' border property if set + if (isset($pStyles['borders']['horizontal'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + case 'left': + case 'right': + // should pick up 'vertical' border property if set + if (isset($pStyles['borders']['vertical'])) { + $regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical']; + } else { + unset($regionStyles['borders'][$innerEdge]); + } + break; + } + } + + // apply region style to region by calling applyFromArray() in simple mode + $this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false); + } } - if (isset($pStyles['numberformat'])) { - $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); - } - if (isset($pStyles['protection'])) { - $this->getProtection()->applyFromArray($pStyles['protection']); - } - if (isset($pStyles['quotePrefix'])) { - $this->quotePrefix = $pStyles['quotePrefix']; + + return $this; + } + + // SIMPLE MODE: + // Selection type, inspect + if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) { + $selectionType = 'COLUMN'; + } elseif (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) { + $selectionType = 'ROW'; + } else { + $selectionType = 'CELL'; + } + + // First loop through columns, rows, or cells to find out which styles are affected by this operation + switch ($selectionType) { + case 'COLUMN': + $oldXfIndexes = []; + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true; + } + break; + case 'ROW': + $oldXfIndexes = []; + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) { + $oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style + } else { + $oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true; + } + } + break; + case 'CELL': + $oldXfIndexes = []; + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true; + } + } + break; + } + + // clone each of the affected styles, apply the style array, and add the new styles to the workbook + $workbook = $this->getActiveSheet()->getParent(); + foreach ($oldXfIndexes as $oldXfIndex => $dummy) { + $style = $workbook->getCellXfByIndex($oldXfIndex); + $newStyle = clone $style; + $newStyle->applyFromArray($pStyles); + + if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) { + // there is already such cell Xf in our collection + $newXfIndexes[$oldXfIndex] = $existingStyle->getIndex(); + } else { + // we don't have such a cell Xf, need to add + $workbook->addCellXf($newStyle); + $newXfIndexes[$oldXfIndex] = $newStyle->getIndex(); } } + + // Loop through columns, rows, or cells again and update the XF index + switch ($selectionType) { + case 'COLUMN': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + $columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col); + $oldXfIndex = $columnDimension->getXfIndex(); + $columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; + case 'ROW': + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $rowDimension = $this->getActiveSheet()->getRowDimension($row); + $oldXfIndex = $rowDimension->getXfIndex() === null ? + 0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style + $rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]); + } + break; + case 'CELL': + for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) { + for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) { + $cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row); + $oldXfIndex = $cell->getXfIndex(); + $cell->setXfIndex($newXfIndexes[$oldXfIndex]); + } + } + break; + } } else { - throw new Exception('Invalid style array passed.'); + // not a supervisor, just apply the style array directly on style object + if (isset($pStyles['fill'])) { + $this->getFill()->applyFromArray($pStyles['fill']); + } + if (isset($pStyles['font'])) { + $this->getFont()->applyFromArray($pStyles['font']); + } + if (isset($pStyles['borders'])) { + $this->getBorders()->applyFromArray($pStyles['borders']); + } + if (isset($pStyles['alignment'])) { + $this->getAlignment()->applyFromArray($pStyles['alignment']); + } + if (isset($pStyles['numberformat'])) { + $this->getNumberFormat()->applyFromArray($pStyles['numberformat']); + } + if (isset($pStyles['protection'])) { + $this->getProtection()->applyFromArray($pStyles['protection']); + } + if (isset($pStyles['quotePrefix'])) { + $this->quotePrefix = $pStyles['quotePrefix']; + } } return $this; @@ -547,15 +543,13 @@ class Style extends Style\Supervisor implements IComparable /** * Set Conditional Styles. Only used on supervisor. * - * @param Style\Conditional[] $pValue Array of condtional styles + * @param Style\Conditional[] $pValue Array of conditional styles * * @return Style */ - public function setConditionalStyles($pValue = null) + public function setConditionalStyles(array $pValue) { - if (is_array($pValue)) { - $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); - } + $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue); return $this; } diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 68ded6c4..6ee25160 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -162,37 +162,33 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells()) - ->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['horizontal'])) { - $this->setHorizontal($pStyles['horizontal']); - } - if (isset($pStyles['vertical'])) { - $this->setVertical($pStyles['vertical']); - } - if (isset($pStyles['rotation'])) { - $this->setTextRotation($pStyles['rotation']); - } - if (isset($pStyles['wrap'])) { - $this->setWrapText($pStyles['wrap']); - } - if (isset($pStyles['shrinkToFit'])) { - $this->setShrinkToFit($pStyles['shrinkToFit']); - } - if (isset($pStyles['indent'])) { - $this->setIndent($pStyles['indent']); - } - if (isset($pStyles['readorder'])) { - $this->setReadorder($pStyles['readorder']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells()) + ->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['horizontal'])) { + $this->setHorizontal($pStyles['horizontal']); + } + if (isset($pStyles['vertical'])) { + $this->setVertical($pStyles['vertical']); + } + if (isset($pStyles['rotation'])) { + $this->setTextRotation($pStyles['rotation']); + } + if (isset($pStyles['wrap'])) { + $this->setWrapText($pStyles['wrap']); + } + if (isset($pStyles['shrinkToFit'])) { + $this->setShrinkToFit($pStyles['shrinkToFit']); + } + if (isset($pStyles['indent'])) { + $this->setIndent($pStyles['indent']); + } + if (isset($pStyles['readorder'])) { + $this->setReadorder($pStyles['readorder']); + } } return $this; @@ -215,11 +211,11 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara /** * Set Horizontal. * - * @param string $pValue + * @param string $pValue see self::HORIZONTAL_* * * @return Alignment */ - public function setHorizontal($pValue = self::HORIZONTAL_GENERAL) + public function setHorizontal($pValue) { if ($pValue == '') { $pValue = self::HORIZONTAL_GENERAL; @@ -252,11 +248,11 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara /** * Set Vertical. * - * @param string $pValue + * @param string $pValue see self::VERTICAL_* * * @return Alignment */ - public function setVertical($pValue = self::VERTICAL_BOTTOM) + public function setVertical($pValue) { if ($pValue == '') { $pValue = self::VERTICAL_BOTTOM; @@ -295,7 +291,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function setTextRotation($pValue = 0) + public function setTextRotation($pValue) { // Excel2007 value 255 => PhpSpreadsheet value -165 if ($pValue == 255) { @@ -338,7 +334,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function setWrapText($pValue = false) + public function setWrapText($pValue) { if ($pValue == '') { $pValue = false; @@ -374,7 +370,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function setShrinkToFit($pValue = false) + public function setShrinkToFit($pValue) { if ($pValue == '') { $pValue = false; @@ -410,7 +406,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function setIndent($pValue = 0) + public function setIndent($pValue) { if ($pValue > 0) { if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && @@ -450,7 +446,7 @@ class Alignment extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompara * * @return Alignment */ - public function setReadorder($pValue = 0) + public function setReadorder($pValue) { if ($pValue < 0 || $pValue > 2) { $pValue = 0; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 8eed8981..48497aa5 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -181,21 +181,17 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Border */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['style'])) { - $this->setBorderStyle($pStyles['style']); - } - if (isset($pStyles['color'])) { - $this->getColor()->applyFromArray($pStyles['color']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['style'])) { + $this->setBorderStyle($pStyles['style']); + } + if (isset($pStyles['color'])) { + $this->getColor()->applyFromArray($pStyles['color']); + } } return $this; @@ -224,7 +220,7 @@ class Border extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Border */ - public function setBorderStyle($pValue = self::BORDER_NONE) + public function setBorderStyle($pValue) { if (empty($pValue)) { $pValue = self::BORDER_NONE; diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 674da8fb..06268d8b 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -218,39 +218,35 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl * * @return Borders */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['left'])) { - $this->getLeft()->applyFromArray($pStyles['left']); - } - if (isset($pStyles['right'])) { - $this->getRight()->applyFromArray($pStyles['right']); - } - if (isset($pStyles['top'])) { - $this->getTop()->applyFromArray($pStyles['top']); - } - if (isset($pStyles['bottom'])) { - $this->getBottom()->applyFromArray($pStyles['bottom']); - } - if (isset($pStyles['diagonal'])) { - $this->getDiagonal()->applyFromArray($pStyles['diagonal']); - } - if (isset($pStyles['diagonaldirection'])) { - $this->setDiagonalDirection($pStyles['diagonaldirection']); - } - if (isset($pStyles['allborders'])) { - $this->getLeft()->applyFromArray($pStyles['allborders']); - $this->getRight()->applyFromArray($pStyles['allborders']); - $this->getTop()->applyFromArray($pStyles['allborders']); - $this->getBottom()->applyFromArray($pStyles['allborders']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['left'])) { + $this->getLeft()->applyFromArray($pStyles['left']); + } + if (isset($pStyles['right'])) { + $this->getRight()->applyFromArray($pStyles['right']); + } + if (isset($pStyles['top'])) { + $this->getTop()->applyFromArray($pStyles['top']); + } + if (isset($pStyles['bottom'])) { + $this->getBottom()->applyFromArray($pStyles['bottom']); + } + if (isset($pStyles['diagonal'])) { + $this->getDiagonal()->applyFromArray($pStyles['diagonal']); + } + if (isset($pStyles['diagonaldirection'])) { + $this->setDiagonalDirection($pStyles['diagonaldirection']); + } + if (isset($pStyles['allborders'])) { + $this->getLeft()->applyFromArray($pStyles['allborders']); + $this->getRight()->applyFromArray($pStyles['allborders']); + $this->getTop()->applyFromArray($pStyles['allborders']); + $this->getBottom()->applyFromArray($pStyles['allborders']); + } } return $this; @@ -403,11 +399,11 @@ class Borders extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparabl /** * Set DiagonalDirection. * - * @param int $pValue + * @param int $pValue see self::DIAGONAL_* * * @return Borders */ - public function setDiagonalDirection($pValue = self::DIAGONAL_NONE) + public function setDiagonalDirection($pValue) { if ($pValue == '') { $pValue = self::DIAGONAL_NONE; diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 2079ba77..3fdd6308 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -152,21 +152,17 @@ class Color extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Color */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['rgb'])) { - $this->setRGB($pStyles['rgb']); - } - if (isset($pStyles['argb'])) { - $this->setARGB($pStyles['argb']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['rgb'])) { + $this->setRGB($pStyles['rgb']); + } + if (isset($pStyles['argb'])) { + $this->setARGB($pStyles['argb']); + } } return $this; @@ -189,11 +185,11 @@ class Color extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set ARGB. * - * @param string $pValue + * @param string $pValue see self::COLOR_* * * @return Color */ - public function setARGB($pValue = self::COLOR_BLACK) + public function setARGB($pValue) { if ($pValue == '') { $pValue = self::COLOR_BLACK; @@ -229,7 +225,7 @@ class Color extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Color */ - public function setRGB($pValue = '000000') + public function setRGB($pValue) { if ($pValue == '') { $pValue = '000000'; diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index d8d66213..84578411 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -108,11 +108,11 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Condition type. * - * @param string $pValue Condition type + * @param string $pValue Condition type, see self::CONDITION_* * * @return Conditional */ - public function setConditionType($pValue = self::CONDITION_NONE) + public function setConditionType($pValue) { $this->conditionType = $pValue; @@ -132,11 +132,11 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Operator type. * - * @param string $pValue Conditional operator type + * @param string $pValue Conditional operator type, see self::OPERATOR_* * * @return Conditional */ - public function setOperatorType($pValue = self::OPERATOR_NONE) + public function setOperatorType($pValue) { $this->operatorType = $pValue; @@ -160,7 +160,7 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Conditional */ - public function setText($value = null) + public function setText($value) { $this->text = $value; @@ -201,7 +201,7 @@ class Conditional implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Conditional */ - public function addCondition($pValue = '') + public function addCondition($pValue) { $this->condition[] = $pValue; diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 089fa6bb..57d64f34 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -153,31 +153,27 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Fill */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['type'])) { - $this->setFillType($pStyles['type']); - } - if (isset($pStyles['rotation'])) { - $this->setRotation($pStyles['rotation']); - } - if (isset($pStyles['startcolor'])) { - $this->getStartColor()->applyFromArray($pStyles['startcolor']); - } - if (isset($pStyles['endcolor'])) { - $this->getEndColor()->applyFromArray($pStyles['endcolor']); - } - if (isset($pStyles['color'])) { - $this->getStartColor()->applyFromArray($pStyles['color']); - $this->getEndColor()->applyFromArray($pStyles['color']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['type'])) { + $this->setFillType($pStyles['type']); + } + if (isset($pStyles['rotation'])) { + $this->setRotation($pStyles['rotation']); + } + if (isset($pStyles['startcolor'])) { + $this->getStartColor()->applyFromArray($pStyles['startcolor']); + } + if (isset($pStyles['endcolor'])) { + $this->getEndColor()->applyFromArray($pStyles['endcolor']); + } + if (isset($pStyles['color'])) { + $this->getStartColor()->applyFromArray($pStyles['color']); + $this->getEndColor()->applyFromArray($pStyles['color']); + } } return $this; @@ -200,11 +196,11 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Fill Type. * - * @param string $pValue Fill type + * @param string $pValue Fill type, see self::FILL_* * * @return Fill */ - public function setFillType($pValue = self::FILL_NONE) + public function setFillType($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['type' => $pValue]); @@ -237,7 +233,7 @@ class Fill extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Fill */ - public function setRotation($pValue = 0) + public function setRotation($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['rotation' => $pValue]); diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index ba4cc7f0..b40b788b 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -178,42 +178,38 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['name'])) { - $this->setName($pStyles['name']); - } - if (isset($pStyles['bold'])) { - $this->setBold($pStyles['bold']); - } - if (isset($pStyles['italic'])) { - $this->setItalic($pStyles['italic']); - } - if (isset($pStyles['superScript'])) { - $this->setSuperScript($pStyles['superScript']); - } - if (isset($pStyles['subScript'])) { - $this->setSubScript($pStyles['subScript']); - } - if (isset($pStyles['underline'])) { - $this->setUnderline($pStyles['underline']); - } - if (isset($pStyles['strike'])) { - $this->setStrikethrough($pStyles['strike']); - } - if (isset($pStyles['color'])) { - $this->getColor()->applyFromArray($pStyles['color']); - } - if (isset($pStyles['size'])) { - $this->setSize($pStyles['size']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['name'])) { + $this->setName($pStyles['name']); + } + if (isset($pStyles['bold'])) { + $this->setBold($pStyles['bold']); + } + if (isset($pStyles['italic'])) { + $this->setItalic($pStyles['italic']); + } + if (isset($pStyles['superScript'])) { + $this->setSuperScript($pStyles['superScript']); + } + if (isset($pStyles['subScript'])) { + $this->setSubScript($pStyles['subScript']); + } + if (isset($pStyles['underline'])) { + $this->setUnderline($pStyles['underline']); + } + if (isset($pStyles['strike'])) { + $this->setStrikethrough($pStyles['strike']); + } + if (isset($pStyles['color'])) { + $this->getColor()->applyFromArray($pStyles['color']); + } + if (isset($pStyles['size'])) { + $this->setSize($pStyles['size']); + } } return $this; @@ -240,7 +236,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setName($pValue = 'Calibri') + public function setName($pValue) { if ($pValue == '') { $pValue = 'Calibri'; @@ -276,7 +272,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setSize($pValue = 10) + public function setSize($pValue) { if ($pValue == '') { $pValue = 10; @@ -312,7 +308,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setBold($pValue = false) + public function setBold($pValue) { if ($pValue == '') { $pValue = false; @@ -348,7 +344,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setItalic($pValue = false) + public function setItalic($pValue) { if ($pValue == '') { $pValue = false; @@ -384,7 +380,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setSuperScript($pValue = false) + public function setSuperScript($pValue) { if ($pValue == '') { $pValue = false; @@ -421,7 +417,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setSubScript($pValue = false) + public function setSubScript($pValue) { if ($pValue == '') { $pValue = false; @@ -460,7 +456,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setUnderline($pValue = self::UNDERLINE_NONE) + public function setUnderline($pValue) { if (is_bool($pValue)) { $pValue = ($pValue) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE; @@ -498,7 +494,7 @@ class Font extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Font */ - public function setStrikethrough($pValue = false) + public function setStrikethrough($pValue) { if ($pValue == '') { $pValue = false; diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index fb729905..779fb2f9 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -155,18 +155,14 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp * * @return NumberFormat */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['code'])) { - $this->setFormatCode($pStyles['code']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['code'])) { + $this->setFormatCode($pStyles['code']); + } } return $this; @@ -192,11 +188,11 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp /** * Set Format Code. * - * @param string $pValue + * @param string $pValue see self::FORMAT_* * * @return NumberFormat */ - public function setFormatCode($pValue = self::FORMAT_GENERAL) + public function setFormatCode($pValue) { if ($pValue == '') { $pValue = self::FORMAT_GENERAL; @@ -233,7 +229,7 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp * * @return NumberFormat */ - public function setBuiltInFormatCode($pValue = 0) + public function setBuiltInFormatCode($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['code' => self::builtInFormatCode($pValue)]); @@ -588,12 +584,12 @@ class NumberFormat extends Supervisor implements \PhpOffice\PhpSpreadsheet\IComp * Convert a value in a pre-defined format to a PHP string. * * @param mixed $value Value to format - * @param string $format Format code + * @param string $format Format code, see = self::FORMAT_* * @param array $callBack Callback function for additional formatting of string * * @return string Formatted string */ - public static function toFormattedString($value = '0', $format = self::FORMAT_GENERAL, $callBack = null) + public static function toFormattedString($value, $format, $callBack = null) { // For now we do not treat strings although section 4 of a format code affects strings if (!is_numeric($value)) { diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 27145488..848ac1be 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -108,21 +108,17 @@ class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompar * * @return Protection */ - public function applyFromArray($pStyles = null) + public function applyFromArray(array $pStyles) { - if (is_array($pStyles)) { - if ($this->isSupervisor) { - $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); - } else { - if (isset($pStyles['locked'])) { - $this->setLocked($pStyles['locked']); - } - if (isset($pStyles['hidden'])) { - $this->setHidden($pStyles['hidden']); - } - } + if ($this->isSupervisor) { + $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles)); } else { - throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid style array passed.'); + if (isset($pStyles['locked'])) { + $this->setLocked($pStyles['locked']); + } + if (isset($pStyles['hidden'])) { + $this->setHidden($pStyles['hidden']); + } } return $this; @@ -145,11 +141,11 @@ class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompar /** * Set locked. * - * @param string $pValue + * @param string $pValue see self::PROTECTION_* * * @return Protection */ - public function setLocked($pValue = self::PROTECTION_INHERIT) + public function setLocked($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['locked' => $pValue]); @@ -178,11 +174,11 @@ class Protection extends Supervisor implements \PhpOffice\PhpSpreadsheet\ICompar /** * Set hidden. * - * @param string $pValue + * @param string $pValue see self::PROTECTION_* * * @return Protection */ - public function setHidden($pValue = self::PROTECTION_INHERIT) + public function setHidden($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['hidden' => $pValue]); diff --git a/src/PhpSpreadsheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet.php index 002e929a..7565c854 100644 --- a/src/PhpSpreadsheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet.php @@ -582,7 +582,7 @@ class Worksheet implements IComparable * * @return false|Chart */ - public function getChartByIndex($index = null) + public function getChartByIndex($index) { $chartCount = count($this->chartCollection); if ($chartCount == 0) { @@ -624,7 +624,7 @@ class Worksheet implements IComparable * * @return false|Chart */ - public function getChartByName($chartName = '') + public function getChartByName($chartName) { $chartCount = count($this->chartCollection); if ($chartCount == 0) { @@ -833,7 +833,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true) + public function setTitle($pValue, $updateFormulaCellReferences = true) { // Is this a 'rename' or not? if ($this->getTitle() == $pValue) { @@ -908,7 +908,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setSheetState($value = self::SHEETSTATE_VISIBLE) + public function setSheetState($value) { $this->sheetState = $value; @@ -1109,17 +1109,16 @@ class Worksheet implements IComparable /** * Set a cell value. * - * @param string $pCoordinate Coordinate of the cell + * @param string $pCoordinate Coordinate of the cell, eg: 'A1' * @param mixed $pValue Value of the cell - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) * - * @return Worksheet|Cell Depending on the last parameter being specified + * @return Worksheet */ - public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false) + public function setCellValue($pCoordinate, $pValue) { - $cell = $this->getCell(strtoupper($pCoordinate))->setValue($pValue); + $this->getCell($pCoordinate)->setValue($pValue); - return ($returnCell) ? $cell : $this; + return $this; } /** @@ -1128,57 +1127,55 @@ class Worksheet implements IComparable * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * @param mixed $pValue Value of the cell - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) * - * @return Worksheet|Cell Depending on the last parameter being specified + * @return Worksheet */ - public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false) + public function setCellValueByColumnAndRow($pColumn, $pRow, $pValue) { - $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValue($pValue); + $this->getCellByColumnAndRow($pColumn, $pRow)->setValue($pValue); - return ($returnCell) ? $cell : $this; + return $this; } /** * Set a cell value. * - * @param string $pCoordinate Coordinate of the cell + * @param string $pCoordinate Coordinate of the cell, eg: 'A1' * @param mixed $pValue Value of the cell - * @param string $pDataType Explicit data type - * @param bool $returnCell Return the worksheet (false, default) or the cell (true) + * @param string $pDataType Explicit data type, see Cell\DataType::TYPE_* * - * @return Worksheet|Cell Depending on the last parameter being specified + * @return Worksheet */ - public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = Cell\DataType::TYPE_STRING, $returnCell = false) + public function setCellValueExplicit($pCoordinate, $pValue, $pDataType) { // Set value - $cell = $this->getCell(strtoupper($pCoordinate))->setValueExplicit($pValue, $pDataType); + $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType); - return ($returnCell) ? $cell : $this; + return $this; } /** * Set a cell value by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * @param mixed $pValue Value of the cell - * @param string $pDataType Explicit data type + * @param string $pDataType Explicit data type, see Cell\DataType::TYPE_* * @param bool $returnCell Return the worksheet (false, default) or the cell (true) * - * @return Worksheet|Cell Depending on the last parameter being specified + * @return Worksheet */ - public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = Cell\DataType::TYPE_STRING, $returnCell = false) + public function setCellValueExplicitByColumnAndRow($pColumn, $pRow, $pValue, $pDataType) { - $cell = $this->getCellByColumnAndRow($pColumn, $pRow)->setValueExplicit($pValue, $pDataType); + $this->getCellByColumnAndRow($pColumn, $pRow)->setValueExplicit($pValue, $pDataType); - return ($returnCell) ? $cell : $this; + return $this; } /** * Get cell at a specific coordinate. * - * @param string $pCoordinate Coordinate of the cell + * @param string $pCoordinate Coordinate of the cell, eg: 'A1' * @param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't * already exist, or a null should be returned instead * @@ -1186,7 +1183,7 @@ class Worksheet implements IComparable * * @return null|Cell Cell that was found/created or null */ - public function getCell($pCoordinate = 'A1', $createIfNotExists = true) + public function getCell($pCoordinate, $createIfNotExists = true) { // Check cell collection if ($this->cellCollection->has(strtoupper($pCoordinate))) { @@ -1234,7 +1231,7 @@ class Worksheet implements IComparable * * @return null|Cell Cell that was found/created or null */ - public function getCellByColumnAndRow($pColumn = 0, $pRow = 1, $createIfNotExists = true) + public function getCellByColumnAndRow($pColumn, $pRow, $createIfNotExists = true) { $columnLetter = Cell::stringFromColumnIndex($pColumn); $coordinate = $columnLetter . $pRow; @@ -1286,13 +1283,13 @@ class Worksheet implements IComparable /** * Does the cell at a specific coordinate exist? * - * @param string $pCoordinate Coordinate of the cell + * @param string $pCoordinate Coordinate of the cell eg: 'A1' * * @throws Exception * * @return bool */ - public function cellExists($pCoordinate = 'A1') + public function cellExists($pCoordinate) { // Worksheet reference? if (strpos($pCoordinate, '!') !== false) { @@ -1336,12 +1333,12 @@ class Worksheet implements IComparable /** * Cell at a specific coordinate by using numeric cell coordinates exists? * - * @param string $pColumn Numeric column coordinate of the cell + * @param string $pColumn Numeric column coordinate of the cell (A = 0) * @param string $pRow Numeric row coordinate of the cell * * @return bool */ - public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1) + public function cellExistsByColumnAndRow($pColumn, $pRow) { return $this->cellExists(Cell::stringFromColumnIndex($pColumn) . $pRow); } @@ -1354,7 +1351,7 @@ class Worksheet implements IComparable * * @return Worksheet\RowDimension */ - public function getRowDimension($pRow = 1, $create = true) + public function getRowDimension($pRow, $create = true) { // Found $found = null; @@ -1375,12 +1372,12 @@ class Worksheet implements IComparable /** * Get column dimension at a specific column. * - * @param string $pColumn String index of the column + * @param string $pColumn String index of the column eg: 'A' * @param mixed $create * * @return Worksheet\ColumnDimension */ - public function getColumnDimension($pColumn = 'A', $create = true) + public function getColumnDimension($pColumn, $create = true) { // Uppercase coordinate $pColumn = strtoupper($pColumn); @@ -1403,11 +1400,11 @@ class Worksheet implements IComparable /** * Get column dimension at a specific column by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * * @return Worksheet\ColumnDimension */ - public function getColumnDimensionByColumn($pColumn = 0) + public function getColumnDimensionByColumn($pColumn) { return $this->getColumnDimension(Cell::stringFromColumnIndex($pColumn)); } @@ -1425,13 +1422,13 @@ class Worksheet implements IComparable /** * Get style for cell. * - * @param string $pCellCoordinate Cell coordinate (or range) to get style for + * @param string $pCellCoordinate Cell coordinate (or range) to get style for, eg: 'A1' * * @throws Exception * * @return Style */ - public function getStyle($pCellCoordinate = 'A1') + public function getStyle($pCellCoordinate) { // set this sheet as active $this->parent->setActiveSheetIndex($this->parent->getIndex($this)); @@ -1445,11 +1442,11 @@ class Worksheet implements IComparable /** * Get conditional styles for a cell. * - * @param string $pCoordinate + * @param string $pCoordinate eg: 'A1' * * @return Style\Conditional[] */ - public function getConditionalStyles($pCoordinate = 'A1') + public function getConditionalStyles($pCoordinate) { $pCoordinate = strtoupper($pCoordinate); if (!isset($this->conditionalStylesCollection[$pCoordinate])) { @@ -1462,11 +1459,11 @@ class Worksheet implements IComparable /** * Do conditional styles exist for this cell? * - * @param string $pCoordinate + * @param string $pCoordinate eg: 'A1' * * @return bool */ - public function conditionalStylesExists($pCoordinate = 'A1') + public function conditionalStylesExists($pCoordinate) { if (isset($this->conditionalStylesCollection[strtoupper($pCoordinate)])) { return true; @@ -1478,11 +1475,11 @@ class Worksheet implements IComparable /** * Removes conditional styles for a cell. * - * @param string $pCoordinate + * @param string $pCoordinate eg: 'A1' * * @return Worksheet */ - public function removeConditionalStyles($pCoordinate = 'A1') + public function removeConditionalStyles($pCoordinate) { unset($this->conditionalStylesCollection[strtoupper($pCoordinate)]); @@ -1517,16 +1514,16 @@ class Worksheet implements IComparable /** * Get style for cell by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell - * @param int pColumn2 Numeric column coordinate of the range cell + * @param int pColumn2 Numeric column coordinate of the range cell (A = 0) * @param int pRow2 Numeric row coordinate of the range cell * @param null|mixed $pColumn2 * @param null|mixed $pRow2 * * @return Style */ - public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) + public function getStyleByColumnAndRow($pColumn, $pRow, $pColumn2 = null, $pRow2 = null) { if (!is_null($pColumn2) && !is_null($pRow2)) { $cellRange = Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2; @@ -1628,25 +1625,25 @@ class Worksheet implements IComparable /** * Set break on a cell. * - * @param string $pCell Cell coordinate (e.g. A1) + * @param string $pCoordinate Cell coordinate (e.g. A1) * @param int $pBreak Break type (type of Worksheet::BREAK_*) * * @throws Exception * * @return Worksheet */ - public function setBreak($pCell = 'A1', $pBreak = self::BREAK_NONE) + public function setBreak($pCoordinate, $pBreak) { // Uppercase coordinate - $pCell = strtoupper($pCell); + $pCoordinate = strtoupper($pCoordinate); - if ($pCell != '') { + if ($pCoordinate != '') { if ($pBreak == self::BREAK_NONE) { - if (isset($this->breaks[$pCell])) { - unset($this->breaks[$pCell]); + if (isset($this->breaks[$pCoordinate])) { + unset($this->breaks[$pCoordinate]); } } else { - $this->breaks[$pCell] = $pBreak; + $this->breaks[$pCoordinate] = $pBreak; } } else { throw new Exception('No cell coordinate specified.'); @@ -1658,13 +1655,13 @@ class Worksheet implements IComparable /** * Set break on a cell by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * @param int $pBreak Break type (type of \PhpOffice\PhpSpreadsheet\Worksheet::BREAK_*) * * @return Worksheet */ - public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = self::BREAK_NONE) + public function setBreakByColumnAndRow($pColumn, $pRow, $pBreak) { return $this->setBreak(Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak); } @@ -1688,7 +1685,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function mergeCells($pRange = 'A1:A1') + public function mergeCells($pRange) { // Uppercase coordinate $pRange = strtoupper($pRange); @@ -1724,16 +1721,16 @@ class Worksheet implements IComparable /** * Set merge on a cell range by using numeric cell coordinates. * - * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) * @param int $pRow2 Numeric row coordinate of the last cell * * @throws Exception * * @return Worksheet */ - public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + public function mergeCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) { $cellRange = Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2; @@ -1749,7 +1746,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function unmergeCells($pRange = 'A1:A1') + public function unmergeCells($pRange) { // Uppercase coordinate $pRange = strtoupper($pRange); @@ -1770,16 +1767,16 @@ class Worksheet implements IComparable /** * Remove merge on a cell range by using numeric cell coordinates. * - * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) * @param int $pRow2 Numeric row coordinate of the last cell * * @throws Exception * * @return Worksheet */ - public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + public function unmergeCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) { $cellRange = Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2; @@ -1803,7 +1800,7 @@ class Worksheet implements IComparable * @param array * @param mixed $pValue */ - public function setMergeCells($pValue = []) + public function setMergeCells(array $pValue) { $this->mergeCells = $pValue; @@ -1821,7 +1818,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function protectCells($pRange = 'A1', $pPassword = '', $pAlreadyHashed = false) + public function protectCells($pRange, $pPassword, $pAlreadyHashed = false) { // Uppercase coordinate $pRange = strtoupper($pRange); @@ -1837,9 +1834,9 @@ class Worksheet implements IComparable /** * Set protection on a cell range by using numeric cell coordinates. * - * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) * @param int $pRow2 Numeric row coordinate of the last cell * @param string $pPassword Password to unlock the protection * @param bool $pAlreadyHashed If the password has already been hashed, set this to true @@ -1848,7 +1845,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) + public function protectCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2, $pPassword, $pAlreadyHashed = false) { $cellRange = Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2; @@ -1864,7 +1861,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function unprotectCells($pRange = 'A1') + public function unprotectCells($pRange) { // Uppercase coordinate $pRange = strtoupper($pRange); @@ -1881,9 +1878,9 @@ class Worksheet implements IComparable /** * Remove protection on a cell range by using numeric cell coordinates. * - * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the last cell + * @param int $pColumn2 Numeric column coordinate of the last cell (A = 0) * @param int $pRow2 Numeric row coordinate of the last cell * @param string $pPassword Password to unlock the protection * @param bool $pAlreadyHashed If the password has already been hashed, set this to true @@ -1892,7 +1889,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false) + public function unprotectCellsByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2, $pPassword, $pAlreadyHashed = false) { $cellRange = Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . Cell::stringFromColumnIndex($pColumn2) . $pRow2; @@ -1944,16 +1941,16 @@ class Worksheet implements IComparable /** * Set Autofilter Range by using numeric cell coordinates. * - * @param int $pColumn1 Numeric column coordinate of the first cell + * @param int $pColumn1 Numeric column coordinate of the first cell (A = 0) * @param int $pRow1 Numeric row coordinate of the first cell - * @param int $pColumn2 Numeric column coordinate of the second cell + * @param int $pColumn2 Numeric column coordinate of the second cell (A = 0) * @param int $pRow2 Numeric row coordinate of the second cell * * @throws Exception * * @return Worksheet */ - public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1) + public function setAutoFilterByColumnAndRow($pColumn1, $pRow1, $pColumn2, $pRow2) { return $this->setAutoFilter( Cell::stringFromColumnIndex($pColumn1) . $pRow1 @@ -1998,7 +1995,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function freezePane($pCell = '') + public function freezePane($pCell) { // Uppercase coordinate $pCell = strtoupper($pCell); @@ -2014,14 +2011,14 @@ class Worksheet implements IComparable /** * Freeze Pane by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * * @throws Exception * * @return Worksheet */ - public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1) + public function freezePaneByColumnAndRow($pColumn, $pRow) { return $this->freezePane(Cell::stringFromColumnIndex($pColumn) . $pRow); } @@ -2046,7 +2043,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) + public function insertNewRowBefore($pBefore, $pNumRows = 1) { if ($pBefore >= 1) { $objReferenceHelper = ReferenceHelper::getInstance(); @@ -2061,14 +2058,14 @@ class Worksheet implements IComparable /** * Insert a new column, updating all possible related data. * - * @param int $pBefore Insert before this one + * @param int $pBefore Insert before this one, eg: 'A' * @param int $pNumCols Number of columns to insert * * @throws Exception * * @return Worksheet */ - public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) + public function insertNewColumnBefore($pBefore, $pNumCols = 1) { if (!is_numeric($pBefore)) { $objReferenceHelper = ReferenceHelper::getInstance(); @@ -2083,14 +2080,14 @@ class Worksheet implements IComparable /** * Insert a new column, updating all possible related data. * - * @param int $pBefore Insert before this one (numeric column coordinate of the cell) + * @param int $pBefore Insert before this one (numeric column coordinate of the cell, A = 0) * @param int $pNumCols Number of columns to insert * * @throws Exception * * @return Worksheet */ - public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) + public function insertNewColumnBeforeByIndex($pBefore, $pNumCols = 1) { if ($pBefore >= 0) { return $this->insertNewColumnBefore(Cell::stringFromColumnIndex($pBefore), $pNumCols); @@ -2108,7 +2105,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function removeRow($pRow = 1, $pNumRows = 1) + public function removeRow($pRow, $pNumRows = 1) { if ($pRow >= 1) { $highestRow = $this->getHighestDataRow(); @@ -2128,14 +2125,14 @@ class Worksheet implements IComparable /** * Remove a column, updating all possible related data. * - * @param string $pColumn Remove starting with this one + * @param string $pColumn Remove starting with this one, eg: 'A' * @param int $pNumCols Number of columns to remove * * @throws Exception * * @return Worksheet */ - public function removeColumn($pColumn = 'A', $pNumCols = 1) + public function removeColumn($pColumn, $pNumCols = 1) { if (!is_numeric($pColumn)) { $highestColumn = $this->getHighestDataColumn(); @@ -2156,14 +2153,14 @@ class Worksheet implements IComparable /** * Remove a column, updating all possible related data. * - * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell) + * @param int $pColumn Remove starting with this one (numeric column coordinate of the cell A = 0) * @param int $pNumCols Number of columns to remove * * @throws Exception * * @return Worksheet */ - public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) + public function removeColumnByIndex($pColumn, $pNumCols = 1) { if ($pColumn >= 0) { return $this->removeColumn(Cell::stringFromColumnIndex($pColumn), $pNumCols); @@ -2188,7 +2185,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setShowGridlines($pValue = false) + public function setShowGridlines($pValue) { $this->showGridlines = $pValue; @@ -2212,7 +2209,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setPrintGridlines($pValue = false) + public function setPrintGridlines($pValue) { $this->printGridlines = $pValue; @@ -2236,7 +2233,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setShowRowColHeaders($pValue = false) + public function setShowRowColHeaders($pValue) { $this->showRowColHeaders = $pValue; @@ -2260,7 +2257,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setShowSummaryBelow($pValue = true) + public function setShowSummaryBelow($pValue) { $this->showSummaryBelow = $pValue; @@ -2284,7 +2281,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setShowSummaryRight($pValue = true) + public function setShowSummaryRight($pValue) { $this->showSummaryRight = $pValue; @@ -2309,7 +2306,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setComments($pValue = []) + public function setComments(array $pValue) { $this->comments = $pValue; @@ -2319,13 +2316,13 @@ class Worksheet implements IComparable /** * Get comment for cell. * - * @param string $pCellCoordinate Cell coordinate to get comment for + * @param string $pCellCoordinate Cell coordinate to get comment for, eg: 'A1' * * @throws Exception * * @return Comment */ - public function getComment($pCellCoordinate = 'A1') + public function getComment($pCellCoordinate) { // Uppercase coordinate $pCellCoordinate = strtoupper($pCellCoordinate); @@ -2353,12 +2350,12 @@ class Worksheet implements IComparable /** * Get comment for cell by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * * @return Comment */ - public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1) + public function getCommentByColumnAndRow($pColumn, $pRow) { return $this->getComment(Cell::stringFromColumnIndex($pColumn) . $pRow); } @@ -2390,7 +2387,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setSelectedCell($pCoordinate = 'A1') + public function setSelectedCell($pCoordinate) { return $this->setSelectedCells($pCoordinate); } @@ -2404,7 +2401,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setSelectedCells($pCoordinate = 'A1') + public function setSelectedCells($pCoordinate) { // Uppercase coordinate $pCoordinate = strtoupper($pCoordinate); @@ -2435,14 +2432,14 @@ class Worksheet implements IComparable /** * Selected cell by using numeric cell coordinates. * - * @param int $pColumn Numeric column coordinate of the cell + * @param int $pColumn Numeric column coordinate of the cell (A = 0) * @param int $pRow Numeric row coordinate of the cell * * @throws Exception * * @return Worksheet */ - public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1) + public function setSelectedCellByColumnAndRow($pColumn, $pRow) { return $this->setSelectedCells(Cell::stringFromColumnIndex($pColumn) . $pRow); } @@ -2464,7 +2461,7 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function setRightToLeft($value = false) + public function setRightToLeft($value) { $this->rightToLeft = $value; @@ -2483,38 +2480,34 @@ class Worksheet implements IComparable * * @return Worksheet */ - public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) + public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { - if (is_array($source)) { - // Convert a 1-D array to 2-D (for ease of looping) - if (!is_array(end($source))) { - $source = [$source]; - } + // Convert a 1-D array to 2-D (for ease of looping) + if (!is_array(end($source))) { + $source = [$source]; + } - // start coordinate - list($startColumn, $startRow) = Cell::coordinateFromString($startCell); + // start coordinate + list($startColumn, $startRow) = Cell::coordinateFromString($startCell); - // Loop through $source - foreach ($source as $rowData) { - $currentColumn = $startColumn; - foreach ($rowData as $cellValue) { - if ($strictNullComparison) { - if ($cellValue !== $nullValue) { - // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); - } - } else { - if ($cellValue != $nullValue) { - // Set cell value - $this->getCell($currentColumn . $startRow)->setValue($cellValue); - } + // Loop through $source + foreach ($source as $rowData) { + $currentColumn = $startColumn; + foreach ($rowData as $cellValue) { + if ($strictNullComparison) { + if ($cellValue !== $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); + } + } else { + if ($cellValue != $nullValue) { + // Set cell value + $this->getCell($currentColumn . $startRow)->setValue($cellValue); } - ++$currentColumn; } - ++$startRow; + ++$currentColumn; } - } else { - throw new Exception('Parameter $source should be an array.'); + ++$startRow; } return $this; @@ -2532,7 +2525,7 @@ class Worksheet implements IComparable * * @return array */ - public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) + public function rangeToArray($pRange, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { // Returnvalue $returnValue = []; @@ -2604,7 +2597,7 @@ class Worksheet implements IComparable * * @return array */ - public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) + public function namedRangeToArray($pNamedRange, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { $namedRange = NamedRange::resolveRange($pNamedRange, $this); if ($namedRange !== null) { @@ -2746,9 +2739,9 @@ class Worksheet implements IComparable /** * Get hyperlink. * - * @param string $pCellCoordinate Cell coordinate to get hyperlink for + * @param string $pCellCoordinate Cell coordinate to get hyperlink for, eg: 'A1' */ - public function getHyperlink($pCellCoordinate = 'A1') + public function getHyperlink($pCellCoordinate) { // return hyperlink if we already have one if (isset($this->hyperlinkCollection[$pCellCoordinate])) { @@ -2762,14 +2755,14 @@ class Worksheet implements IComparable } /** - * Set hyperlnk. + * Set hyperlink. * - * @param string $pCellCoordinate Cell coordinate to insert hyperlink - * @param Cell\Hyperlink $pHyperlink + * @param string $pCellCoordinate Cell coordinate to insert hyperlink, eg: 'A1' + * @param Cell\Hyperlink|null $pHyperlink * * @return Worksheet */ - public function setHyperlink($pCellCoordinate = 'A1', Cell\Hyperlink $pHyperlink = null) + public function setHyperlink($pCellCoordinate, Cell\Hyperlink $pHyperlink = null) { if ($pHyperlink === null) { unset($this->hyperlinkCollection[$pCellCoordinate]); @@ -2783,11 +2776,11 @@ class Worksheet implements IComparable /** * Hyperlink at a specific coordinate exists? * - * @param string $pCoordinate + * @param string $pCoordinate eg: 'A1' * * @return bool */ - public function hyperlinkExists($pCoordinate = 'A1') + public function hyperlinkExists($pCoordinate) { return isset($this->hyperlinkCollection[$pCoordinate]); } @@ -2805,9 +2798,9 @@ class Worksheet implements IComparable /** * Get data validation. * - * @param string $pCellCoordinate Cell coordinate to get data validation for + * @param string $pCellCoordinate Cell coordinate to get data validation for, eg: 'A1' */ - public function getDataValidation($pCellCoordinate = 'A1') + public function getDataValidation($pCellCoordinate) { // return data validation if we already have one if (isset($this->dataValidationCollection[$pCellCoordinate])) { @@ -2823,12 +2816,12 @@ class Worksheet implements IComparable /** * Set data validation. * - * @param string $pCellCoordinate Cell coordinate to insert data validation - * @param Cell\DataValidation $pDataValidation + * @param string $pCellCoordinate Cell coordinate to insert data validation, eg: 'A1' + * @param Cell\DataValidation|null $pDataValidation * * @return Worksheet */ - public function setDataValidation($pCellCoordinate = 'A1', Cell\DataValidation $pDataValidation = null) + public function setDataValidation($pCellCoordinate, Cell\DataValidation $pDataValidation = null) { if ($pDataValidation === null) { unset($this->dataValidationCollection[$pCellCoordinate]); @@ -2842,11 +2835,11 @@ class Worksheet implements IComparable /** * Data validation at a specific coordinate exists? * - * @param string $pCoordinate + * @param string $pCoordinate eg: 'A1' * * @return bool */ - public function dataValidationExists($pCoordinate = 'A1') + public function dataValidationExists($pCoordinate) { return isset($this->dataValidationCollection[$pCoordinate]); } @@ -2990,7 +2983,7 @@ class Worksheet implements IComparable * * @return objWorksheet */ - public function setCodeName($pValue = null) + public function setCodeName($pValue) { // Is this a 'rename' or not? if ($this->getCodeName() == $pValue) { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index fd9904c8..a9298433 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -102,7 +102,7 @@ class AutoFilter * * @return AutoFilter */ - public function setRange($pRange = '') + public function setRange($pRange) { // Uppercase coordinate $cellAddress = explode('!', strtoupper($pRange)); @@ -214,7 +214,7 @@ class AutoFilter * * @return AutoFilter\Column */ - public function getColumnByOffset($pColumnOffset = 0) + public function getColumnByOffset($pColumnOffset) { list($rangeStart, $rangeEnd) = \PhpOffice\PhpSpreadsheet\Cell::rangeBoundaries($this->range); $pColumn = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); @@ -278,7 +278,7 @@ class AutoFilter * Shift an AutoFilter Column Rule to a different column. * * Note: This method bypasses validation of the destination column to ensure it is within this AutoFilter range. - * Nor does it verify whether any column rule already exists at $toColumn, but will simply overrideany existing value. + * Nor does it verify whether any column rule already exists at $toColumn, but will simply override any existing value. * Use with caution. * * @param string $fromColumn Column name (e.g. A) @@ -286,7 +286,7 @@ class AutoFilter * * @return AutoFilter */ - public function shiftColumn($fromColumn = null, $toColumn = null) + public function shiftColumn($fromColumn, $toColumn) { $fromColumn = strtoupper($fromColumn); $toColumn = strtoupper($toColumn); diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index b5c0fbaa..305d70bf 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -194,7 +194,7 @@ class Column * * @return Column */ - public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER) + public function setFilterType($pFilterType) { if (!in_array($pFilterType, self::$filterTypes)) { throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid filter type for column AutoFilter.'); @@ -224,7 +224,7 @@ class Column * * @return Column */ - public function setJoin($pJoin = self::AUTOFILTER_COLUMN_JOIN_OR) + public function setJoin($pJoin) { // Lowercase And/Or $pJoin = strtolower($pJoin); @@ -240,15 +240,15 @@ class Column /** * Set AutoFilter Attributes. * - * @param string[] $pAttributes + * @param string[] $attributes * * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return Column */ - public function setAttributes($pAttributes = []) + public function setAttributes(array $attributes) { - $this->attributes = $pAttributes; + $this->attributes = $attributes; return $this; } @@ -273,7 +273,7 @@ class Column /** * Get AutoFilter Column Attributes. * - * @return string + * @return string[] */ public function getAttributes() { @@ -340,16 +340,15 @@ class Column * Add a new AutoFilter Column Rule to the ruleset. * * @param Column\Rule $pRule - * @param bool $returnRule Flag indicating whether the rule object or the column object should be returned * - * @return Column|Column\Rule + * @return Column */ - public function addRule(Column\Rule $pRule, $returnRule = true) + public function addRule(Column\Rule $pRule) { $pRule->setParent($this); $this->ruleset[] = $pRule; - return ($returnRule) ? $pRule : $this; + return $this; } /** diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index f9daee1e..bdf6fd52 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -277,13 +277,13 @@ class Rule /** * Set AutoFilter Rule Type. * - * @param string $pRuleType + * @param string $pRuleType see self::AUTOFILTER_RULETYPE_* * * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return Rule */ - public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER) + public function setRuleType($pRuleType) { if (!in_array($pRuleType, self::$ruleTypes)) { throw new \PhpOffice\PhpSpreadsheet\Exception('Invalid rule type for column AutoFilter Rule.'); @@ -313,7 +313,7 @@ class Rule * * @return Rule */ - public function setValue($pValue = '') + public function setValue($pValue) { if (is_array($pValue)) { $grouping = -1; @@ -351,13 +351,13 @@ class Rule /** * Set AutoFilter Rule Operator. * - * @param string $pOperator + * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_* * * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return Rule */ - public function setOperator($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL) + public function setOperator($pOperator) { if (empty($pOperator)) { $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL; @@ -390,7 +390,7 @@ class Rule * * @return Rule */ - public function setGrouping($pGrouping = null) + public function setGrouping($pGrouping) { if (($pGrouping !== null) && (!in_array($pGrouping, self::$dateTimeGroups)) && @@ -406,7 +406,7 @@ class Rule /** * Set AutoFilter Rule. * - * @param string $pOperator + * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_* * @param string|string[] $pValue * @param string $pGrouping * @@ -414,7 +414,7 @@ class Rule * * @return Rule */ - public function setRule($pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL, $pValue = '', $pGrouping = null) + public function setRule($pOperator, $pValue, $pGrouping = null) { $this->setOperator($pOperator); $this->setValue($pValue); diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index dbf75f24..9f975309 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -166,7 +166,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setName($pValue = '') + public function setName($pValue) { $this->name = $pValue; @@ -186,13 +186,13 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Description. * - * @param string $pValue + * @param string $description * * @return BaseDrawing */ - public function setDescription($pValue = '') + public function setDescription($description) { - $this->description = $pValue; + $this->description = $description; return $this; } @@ -260,11 +260,11 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable /** * Set Coordinates. * - * @param string $pValue + * @param string $pValue eg: 'A1' * * @return BaseDrawing */ - public function setCoordinates($pValue = 'A1') + public function setCoordinates($pValue) { $this->coordinates = $pValue; @@ -288,7 +288,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setOffsetX($pValue = 0) + public function setOffsetX($pValue) { $this->offsetX = $pValue; @@ -312,7 +312,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setOffsetY($pValue = 0) + public function setOffsetY($pValue) { $this->offsetY = $pValue; @@ -336,7 +336,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setWidth($pValue = 0) + public function setWidth($pValue) { // Resize proportional? if ($this->resizeProportional && $pValue != 0) { @@ -367,7 +367,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setHeight($pValue = 0) + public function setHeight($pValue) { // Resize proportional? if ($this->resizeProportional && $pValue != 0) { @@ -396,7 +396,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setWidthAndHeight($width = 0, $height = 0) + public function setWidthAndHeight($width, $height) { $xratio = $width / ($this->width != 0 ? $this->width : 1); $yratio = $height / ($this->height != 0 ? $this->height : 1); @@ -433,7 +433,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setResizeProportional($pValue = true) + public function setResizeProportional($pValue) { $this->resizeProportional = $pValue; @@ -457,7 +457,7 @@ class BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparable * * @return BaseDrawing */ - public function setRotation($pValue = 0) + public function setRotation($pValue) { $this->rotation = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php index 9dced6b3..cc3b10ea 100644 --- a/src/PhpSpreadsheet/Worksheet/CellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php @@ -79,7 +79,7 @@ abstract class CellIterator * * @throws \PhpOffice\PhpSpreadsheet\Exception */ - public function setIterateOnlyExistingCells($value = true) + public function setIterateOnlyExistingCells($value) { $this->onlyExistingCells = (bool) $value; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php index 7aa214de..b3b4b312 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php @@ -104,7 +104,7 @@ class ColumnDimension extends Dimension * * @return ColumnDimension */ - public function setWidth($pValue = -1) + public function setWidth($pValue) { $this->width = $pValue; @@ -128,7 +128,7 @@ class ColumnDimension extends Dimension * * @return ColumnDimension */ - public function setAutoSize($pValue = false) + public function setAutoSize($pValue) { $this->autoSize = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index 41493985..2ff18512 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -82,7 +82,7 @@ abstract class Dimension * * @return Dimension */ - public function setVisible($pValue = true) + public function setVisible($pValue) { $this->visible = $pValue; @@ -138,7 +138,7 @@ abstract class Dimension * * @return Dimension */ - public function setCollapsed($pValue = true) + public function setCollapsed($pValue) { $this->collapsed = $pValue; @@ -162,7 +162,7 @@ abstract class Dimension * * @return Dimension */ - public function setXfIndex($pValue = 0) + public function setXfIndex($pValue) { $this->xfIndex = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 26d40f9e..8154e501 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -100,7 +100,7 @@ class Drawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\IComparab * * @return Drawing */ - public function setPath($pValue = '', $pVerifyFile = true) + public function setPath($pValue, $pVerifyFile = true) { if ($pVerifyFile) { if (file_exists($pValue)) { diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index 644fe708..54f23a83 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -121,7 +121,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setVisible($pValue = false) + public function setVisible($pValue) { $this->visible = $pValue; @@ -145,7 +145,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setBlurRadius($pValue = 6) + public function setBlurRadius($pValue) { $this->blurRadius = $pValue; @@ -169,7 +169,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setDistance($pValue = 2) + public function setDistance($pValue) { $this->distance = $pValue; @@ -193,7 +193,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setDirection($pValue = 0) + public function setDirection($pValue) { $this->direction = $pValue; @@ -217,7 +217,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setAlignment($pValue = 0) + public function setAlignment($pValue) { $this->alignment = $pValue; @@ -267,7 +267,7 @@ class Shadow implements \PhpOffice\PhpSpreadsheet\IComparable * * @return Shadow */ - public function setAlpha($pValue = 0) + public function setAlpha($pValue) { $this->alpha = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index a8f5cf65..d7a52caa 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -339,7 +339,7 @@ class HeaderFooter * * @return HeaderFooter */ - public function setDifferentOddEven($pValue = false) + public function setDifferentOddEven($pValue) { $this->differentOddEven = $pValue; @@ -363,7 +363,7 @@ class HeaderFooter * * @return HeaderFooter */ - public function setDifferentFirst($pValue = false) + public function setDifferentFirst($pValue) { $this->differentFirst = $pValue; @@ -387,7 +387,7 @@ class HeaderFooter * * @return HeaderFooter */ - public function setScaleWithDocument($pValue = true) + public function setScaleWithDocument($pValue) { $this->scaleWithDocument = $pValue; @@ -411,7 +411,7 @@ class HeaderFooter * * @return HeaderFooter */ - public function setAlignWithMargins($pValue = true) + public function setAlignWithMargins($pValue) { $this->alignWithMargins = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php index 57a888b2..6db76ff5 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php @@ -107,7 +107,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setName($pValue = '') + public function setName($pValue) { $this->name = $pValue; @@ -131,7 +131,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setOffsetX($pValue = 0) + public function setOffsetX($pValue) { $this->offsetX = $pValue; @@ -155,7 +155,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setOffsetY($pValue = 0) + public function setOffsetY($pValue) { $this->offsetY = $pValue; @@ -179,7 +179,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setWidth($pValue = 0) + public function setWidth($pValue) { // Resize proportional? if ($this->resizeProportional && $pValue != 0) { @@ -210,7 +210,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setHeight($pValue = 0) + public function setHeight($pValue) { // Resize proportional? if ($this->resizeProportional && $pValue != 0) { @@ -239,7 +239,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setWidthAndHeight($width = 0, $height = 0) + public function setWidthAndHeight($width, $height) { $xratio = $width / $this->width; $yratio = $height / $this->height; @@ -273,7 +273,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setResizeProportional($pValue = true) + public function setResizeProportional($pValue) { $this->resizeProportional = $pValue; @@ -322,7 +322,7 @@ class HeaderFooterDrawing extends Drawing implements \PhpOffice\PhpSpreadsheet\I * * @return HeaderFooterDrawing */ - public function setPath($pValue = '', $pVerifyFile = true) + public function setPath($pValue, $pVerifyFile = true) { if ($pVerifyFile) { if (file_exists($pValue)) { diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index 4011aa59..b543b8d0 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -94,11 +94,11 @@ class MemoryDrawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\ICo /** * Set image resource. * - * @param $value resource + * @param resource $value * * @return MemoryDrawing */ - public function setImageResource($value = null) + public function setImageResource($value) { $this->imageResource = $value; @@ -124,11 +124,11 @@ class MemoryDrawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\ICo /** * Set rendering function. * - * @param string $value + * @param string $value see self::RENDERING_* * * @return MemoryDrawing */ - public function setRenderingFunction($value = self::RENDERING_DEFAULT) + public function setRenderingFunction($value) { $this->renderingFunction = $value; @@ -148,11 +148,11 @@ class MemoryDrawing extends BaseDrawing implements \PhpOffice\PhpSpreadsheet\ICo /** * Set mime type. * - * @param string $value + * @param string $value see self::MIMETYPE_* * * @return MemoryDrawing */ - public function setMimeType($value = self::MIMETYPE_DEFAULT) + public function setMimeType($value) { $this->mimeType = $value; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 41a1a22e..8e40ca1d 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -288,11 +288,11 @@ class PageSetup /** * Set Paper Size. * - * @param int $pValue + * @param int $pValue see self::PAPERSIZE_* * * @return PageSetup */ - public function setPaperSize($pValue = self::PAPERSIZE_LETTER) + public function setPaperSize($pValue) { $this->paperSize = $pValue; @@ -312,11 +312,11 @@ class PageSetup /** * Set Orientation. * - * @param string $pValue + * @param string $pValue see self::ORIENTATION_* * * @return PageSetup */ - public function setOrientation($pValue = self::ORIENTATION_DEFAULT) + public function setOrientation($pValue) { $this->orientation = $pValue; @@ -339,14 +339,14 @@ class PageSetup * Print scaling. Valid values range from 10 to 400 * This setting is overridden when fitToWidth and/or fitToHeight are in use * - * @param int? $pValue + * @param int|null $pValue * @param bool $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth * * @throws \PhpOffice\PhpSpreadsheet\Exception * * @return PageSetup */ - public function setScale($pValue = 100, $pUpdate = true) + public function setScale($pValue, $pUpdate = true) { // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // but it is apparently still able to handle any scale >= 0, where 0 results in 100 @@ -379,7 +379,7 @@ class PageSetup * * @return PageSetup */ - public function setFitToPage($pValue = true) + public function setFitToPage($pValue) { $this->fitToPage = $pValue; @@ -399,12 +399,12 @@ class PageSetup /** * Set Fit To Height. * - * @param int? $pValue + * @param int|null $pValue * @param bool $pUpdate Update fitToPage so it applies rather than scaling * * @return PageSetup */ - public function setFitToHeight($pValue = 1, $pUpdate = true) + public function setFitToHeight($pValue, $pUpdate = true) { $this->fitToHeight = $pValue; if ($pUpdate) { @@ -427,12 +427,12 @@ class PageSetup /** * Set Fit To Width. * - * @param int? $pValue + * @param int|null $pValue * @param bool $pUpdate Update fitToPage so it applies rather than scaling * * @return PageSetup */ - public function setFitToWidth($pValue = 1, $pUpdate = true) + public function setFitToWidth($pValue, $pUpdate = true) { $this->fitToWidth = $pValue; if ($pUpdate) { @@ -475,11 +475,9 @@ class PageSetup * * @return PageSetup */ - public function setColumnsToRepeatAtLeft($pValue = null) + public function setColumnsToRepeatAtLeft(array $pValue) { - if (is_array($pValue)) { - $this->columnsToRepeatAtLeft = $pValue; - } + $this->columnsToRepeatAtLeft = $pValue; return $this; } @@ -487,12 +485,12 @@ class PageSetup /** * Set Columns to repeat at left by start and end. * - * @param string $pStart - * @param string $pEnd + * @param string $pStart eg: 'A' + * @param string $pEnd eg: 'B' * * @return PageSetup */ - public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A') + public function setColumnsToRepeatAtLeftByStartAndEnd($pStart, $pEnd) { $this->columnsToRepeatAtLeft = [$pStart, $pEnd]; @@ -532,11 +530,9 @@ class PageSetup * * @return PageSetup */ - public function setRowsToRepeatAtTop($pValue = null) + public function setRowsToRepeatAtTop(array $pValue) { - if (is_array($pValue)) { - $this->rowsToRepeatAtTop = $pValue; - } + $this->rowsToRepeatAtTop = $pValue; return $this; } @@ -544,12 +540,12 @@ class PageSetup /** * Set Rows to repeat at top by start and end. * - * @param int $pStart - * @param int $pEnd + * @param int $pStart eg: 1 + * @param int $pEnd eg: 1 * * @return PageSetup */ - public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1) + public function setRowsToRepeatAtTopByStartAndEnd($pStart, $pEnd) { $this->rowsToRepeatAtTop = [$pStart, $pEnd]; @@ -573,7 +569,7 @@ class PageSetup * * @return PageSetup */ - public function setHorizontalCentered($value = false) + public function setHorizontalCentered($value) { $this->horizontalCentered = $value; @@ -597,7 +593,7 @@ class PageSetup * * @return PageSetup */ - public function setVerticalCentered($value = false) + public function setVerticalCentered($value) { $this->verticalCentered = $value; @@ -839,7 +835,7 @@ class PageSetup * * @return PageSetup */ - public function setFirstPageNumber($value = null) + public function setFirstPageNumber($value) { $this->firstPageNumber = $value; diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index cda264ee..ddb2dac3 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -194,7 +194,7 @@ class Protection * * @return Protection */ - public function setSheet($pValue = false) + public function setSheet($pValue) { $this->sheet = $pValue; @@ -218,7 +218,7 @@ class Protection * * @return Protection */ - public function setObjects($pValue = false) + public function setObjects($pValue) { $this->objects = $pValue; @@ -242,7 +242,7 @@ class Protection * * @return Protection */ - public function setScenarios($pValue = false) + public function setScenarios($pValue) { $this->scenarios = $pValue; @@ -266,7 +266,7 @@ class Protection * * @return Protection */ - public function setFormatCells($pValue = false) + public function setFormatCells($pValue) { $this->formatCells = $pValue; @@ -290,7 +290,7 @@ class Protection * * @return Protection */ - public function setFormatColumns($pValue = false) + public function setFormatColumns($pValue) { $this->formatColumns = $pValue; @@ -314,7 +314,7 @@ class Protection * * @return Protection */ - public function setFormatRows($pValue = false) + public function setFormatRows($pValue) { $this->formatRows = $pValue; @@ -338,7 +338,7 @@ class Protection * * @return Protection */ - public function setInsertColumns($pValue = false) + public function setInsertColumns($pValue) { $this->insertColumns = $pValue; @@ -362,7 +362,7 @@ class Protection * * @return Protection */ - public function setInsertRows($pValue = false) + public function setInsertRows($pValue) { $this->insertRows = $pValue; @@ -386,7 +386,7 @@ class Protection * * @return Protection */ - public function setInsertHyperlinks($pValue = false) + public function setInsertHyperlinks($pValue) { $this->insertHyperlinks = $pValue; @@ -410,7 +410,7 @@ class Protection * * @return Protection */ - public function setDeleteColumns($pValue = false) + public function setDeleteColumns($pValue) { $this->deleteColumns = $pValue; @@ -434,7 +434,7 @@ class Protection * * @return Protection */ - public function setDeleteRows($pValue = false) + public function setDeleteRows($pValue) { $this->deleteRows = $pValue; @@ -458,7 +458,7 @@ class Protection * * @return Protection */ - public function setSelectLockedCells($pValue = false) + public function setSelectLockedCells($pValue) { $this->selectLockedCells = $pValue; @@ -482,7 +482,7 @@ class Protection * * @return Protection */ - public function setSort($pValue = false) + public function setSort($pValue) { $this->sort = $pValue; @@ -506,7 +506,7 @@ class Protection * * @return Protection */ - public function setAutoFilter($pValue = false) + public function setAutoFilter($pValue) { $this->autoFilter = $pValue; @@ -530,7 +530,7 @@ class Protection * * @return Protection */ - public function setPivotTables($pValue = false) + public function setPivotTables($pValue) { $this->pivotTables = $pValue; @@ -554,7 +554,7 @@ class Protection * * @return Protection */ - public function setSelectUnlockedCells($pValue = false) + public function setSelectUnlockedCells($pValue) { $this->selectUnlockedCells = $pValue; @@ -579,7 +579,7 @@ class Protection * * @return Protection */ - public function setPassword($pValue = '', $pAlreadyHashed = false) + public function setPassword($pValue, $pAlreadyHashed = false) { if (!$pAlreadyHashed) { $pValue = \PhpOffice\PhpSpreadsheet\Shared\PasswordHasher::hashPassword($pValue); diff --git a/src/PhpSpreadsheet/Worksheet/RowDimension.php b/src/PhpSpreadsheet/Worksheet/RowDimension.php index d48a97bd..58ba4185 100644 --- a/src/PhpSpreadsheet/Worksheet/RowDimension.php +++ b/src/PhpSpreadsheet/Worksheet/RowDimension.php @@ -104,7 +104,7 @@ class RowDimension extends Dimension * * @return RowDimension */ - public function setRowHeight($pValue = -1) + public function setRowHeight($pValue) { $this->height = $pValue; @@ -128,7 +128,7 @@ class RowDimension extends Dimension * * @return RowDimension */ - public function setZeroHeight($pValue = false) + public function setZeroHeight($pValue) { $this->zeroHeight = $pValue; diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 64c60522..7ce233ce 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -92,7 +92,7 @@ class SheetView * * @return SheetView */ - public function setZoomScale($pValue = 100) + public function setZoomScale($pValue) { // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // but it is apparently still able to handle any scale >= 1 @@ -126,7 +126,7 @@ class SheetView * * @return SheetView */ - public function setZoomScaleNormal($pValue = 100) + public function setZoomScaleNormal($pValue) { if (($pValue >= 1) || is_null($pValue)) { $this->zoomScaleNormal = $pValue; @@ -161,7 +161,7 @@ class SheetView * * @return SheetView */ - public function setView($pValue = null) + public function setView($pValue) { // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface if ($pValue === null) { diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index 67d60017..eb6f2a18 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -48,14 +48,14 @@ abstract class BaseWriter implements IWriter * * @var bool */ - protected $_useDiskCaching = false; + private $useDiskCaching = false; /** * Disk caching directory. * * @var string */ - protected $_diskCachingDirectory = './'; + private $diskCachingDirectory = './'; /** * Write charts in workbook? @@ -78,7 +78,7 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setIncludeCharts($pValue = false) + public function setIncludeCharts($pValue) { $this->includeCharts = (bool) $pValue; @@ -109,7 +109,7 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setPreCalculateFormulas($pValue = true) + public function setPreCalculateFormulas($pValue) { $this->preCalculateFormulas = (bool) $pValue; @@ -123,7 +123,7 @@ abstract class BaseWriter implements IWriter */ public function getUseDiskCaching() { - return $this->_useDiskCaching; + return $this->useDiskCaching; } /** @@ -136,13 +136,13 @@ abstract class BaseWriter implements IWriter * * @return IWriter */ - public function setUseDiskCaching($pValue = false, $pDirectory = null) + public function setUseDiskCaching($pValue, $pDirectory = null) { - $this->_useDiskCaching = $pValue; + $this->useDiskCaching = $pValue; if ($pDirectory !== null) { if (is_dir($pDirectory)) { - $this->_diskCachingDirectory = $pDirectory; + $this->diskCachingDirectory = $pDirectory; } else { throw new Exception("Directory does not exist: $pDirectory"); } @@ -158,6 +158,6 @@ abstract class BaseWriter implements IWriter */ public function getDiskCachingDirectory() { - return $this->_diskCachingDirectory; + return $this->diskCachingDirectory; } } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 07afe03e..4ed6f89d 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -100,7 +100,7 @@ class Csv extends BaseWriter implements IWriter * * @throws Exception */ - public function save($pFilename = null) + public function save($pFilename) { // Fetch sheet $sheet = $this->spreadsheet->getSheet($this->sheetIndex); @@ -164,11 +164,11 @@ class Csv extends BaseWriter implements IWriter /** * Set delimiter. * - * @param string $pValue Delimiter, defaults to , + * @param string $pValue Delimiter, defaults to ',' * * @return CSV */ - public function setDelimiter($pValue = ',') + public function setDelimiter($pValue) { $this->delimiter = $pValue; @@ -192,7 +192,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setEnclosure($pValue = '"') + public function setEnclosure($pValue) { if ($pValue == '') { $pValue = null; @@ -219,7 +219,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setLineEnding($pValue = PHP_EOL) + public function setLineEnding($pValue) { $this->lineEnding = $pValue; @@ -243,7 +243,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setUseBOM($pValue = false) + public function setUseBOM($pValue) { $this->useBOM = $pValue; @@ -267,7 +267,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setIncludeSeparatorLine($pValue = false) + public function setIncludeSeparatorLine($pValue) { $this->includeSeparatorLine = $pValue; @@ -292,7 +292,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setExcelCompatibility($pValue = false) + public function setExcelCompatibility($pValue) { $this->excelCompatibility = $pValue; @@ -316,7 +316,7 @@ class Csv extends BaseWriter implements IWriter * * @return CSV */ - public function setSheetIndex($pValue = 0) + public function setSheetIndex($pValue) { $this->sheetIndex = $pValue; @@ -331,37 +331,33 @@ class Csv extends BaseWriter implements IWriter * * @throws Exception */ - private function writeLine($pFileHandle = null, $pValues = null) + private function writeLine($pFileHandle, array $pValues) { - if (is_array($pValues)) { - // No leading delimiter - $writeDelimiter = false; + // No leading delimiter + $writeDelimiter = false; - // Build the line - $line = ''; + // Build the line + $line = ''; - foreach ($pValues as $element) { - // Escape enclosures - $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element); + foreach ($pValues as $element) { + // Escape enclosures + $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element); - // Add delimiter - if ($writeDelimiter) { - $line .= $this->delimiter; - } else { - $writeDelimiter = true; - } - - // Add enclosed string - $line .= $this->enclosure . $element . $this->enclosure; + // Add delimiter + if ($writeDelimiter) { + $line .= $this->delimiter; + } else { + $writeDelimiter = true; } - // Add line ending - $line .= $this->lineEnding; - - // Write to file - fwrite($pFileHandle, $line); - } else { - throw new Exception('Invalid data row passed to CSV writer.'); + // Add enclosed string + $line .= $this->enclosure . $element . $this->enclosure; } + + // Add line ending + $line .= $this->lineEnding; + + // Write to file + fwrite($pFileHandle, $line); } } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 779113df..65d95a05 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -147,7 +147,7 @@ class Html extends BaseWriter implements IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { // garbage collect $this->spreadsheet->garbageCollect(); @@ -296,7 +296,7 @@ class Html extends BaseWriter implements IWriter * * @return HTML */ - public function setSheetIndex($pValue = 0) + public function setSheetIndex($pValue) { $this->sheetIndex = $pValue; @@ -320,7 +320,7 @@ class Html extends BaseWriter implements IWriter * * @return HTML */ - public function setGenerateSheetNavigationBlock($pValue = true) + public function setGenerateSheetNavigationBlock($pValue) { $this->generateSheetNavigationBlock = (bool) $pValue; @@ -1457,7 +1457,7 @@ class Html extends BaseWriter implements IWriter * * @return HTML */ - public function setImagesRoot($pValue = '.') + public function setImagesRoot($pValue) { $this->imagesRoot = $pValue; @@ -1481,7 +1481,7 @@ class Html extends BaseWriter implements IWriter * * @return HTML */ - public function setEmbedImages($pValue = true) + public function setEmbedImages($pValue) { $this->embedImages = $pValue; @@ -1505,7 +1505,7 @@ class Html extends BaseWriter implements IWriter * * @return HTML */ - public function setUseInlineCss($pValue = false) + public function setUseInlineCss($pValue) { $this->useInlineCss = $pValue; diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index 4093a34b..c1443481 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -33,5 +33,5 @@ interface IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null); + public function save($pFilename); } diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 1203f68f..4276fa6d 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -74,7 +74,7 @@ class Ods extends BaseWriter implements IWriter * * @return Ods\WriterPart|null */ - public function getWriterPart($pPartName = '') + public function getWriterPart($pPartName) { if ($pPartName != '' && isset($this->writerParts[strtolower($pPartName)])) { return $this->writerParts[strtolower($pPartName)]; @@ -90,7 +90,7 @@ class Ods extends BaseWriter implements IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { if (!$this->spreadSheet) { throw new \PhpOffice\PhpSpreadsheet\Writer\Exception('PhpSpreadsheet object unassigned.'); diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 2bb20fc7..eeec2334 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -73,7 +73,7 @@ class Pdf implements IWriter /** * {@inheritdoc} */ - public function save($pFilename = null) + public function save($pFilename) { $this->renderer->save($pFilename); } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Core.php b/src/PhpSpreadsheet/Writer/Pdf/Core.php index 6e429817..084b514c 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Core.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Core.php @@ -186,11 +186,11 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html /** * Set Paper Size. * - * @param string $pValue Paper size + * @param string $pValue Paper size see \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_* * * @return self */ - public function setPaperSize($pValue = \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER) + public function setPaperSize($pValue) { $this->paperSize = $pValue; @@ -210,11 +210,11 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html /** * Set Orientation. * - * @param string $pValue Page orientation + * @param string $pValue Page orientation see \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_* * * @return self */ - public function setOrientation($pValue = \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_DEFAULT) + public function setOrientation($pValue) { $this->orientation = $pValue; @@ -240,7 +240,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * * @return self */ - public function setTempDir($pValue = '') + public function setTempDir($pValue) { if (is_dir($pValue)) { $this->tempDir = $pValue; @@ -258,7 +258,7 @@ abstract class Core extends \PhpOffice\PhpSpreadsheet\Writer\Html * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - protected function prepareForSave($pFilename = null) + protected function prepareForSave($pFilename) { // garbage collect $this->spreadsheet->garbageCollect(); diff --git a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php index 2fa219c8..2ddba79e 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/DomPDF.php @@ -33,7 +33,7 @@ class DomPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Pdf/MPDF.php b/src/PhpSpreadsheet/Writer/Pdf/MPDF.php index 14feb1ff..06cb83e1 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/MPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/MPDF.php @@ -34,7 +34,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception */ - public function save($pFilename = null) + public function save($pFilename) { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php index 678a5591..858ff27e 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php +++ b/src/PhpSpreadsheet/Writer/Pdf/TcPDF.php @@ -33,7 +33,7 @@ class TcPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { $fileHandle = parent::prepareForSave($pFilename); diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 2e228ad2..30698647 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -108,7 +108,7 @@ class Xls extends BaseWriter implements IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { // garbage collect $this->spreadsheet->garbageCollect(); diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 38ac7b30..2f2056e1 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -422,7 +422,7 @@ class Workbook extends BIFFwriter * * @return string Binary data for workbook stream */ - public function writeWorkbook($pWorksheetSizes = null) + public function writeWorkbook(array $pWorksheetSizes) { $this->worksheetSizes = $pWorksheetSizes; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 006d1b22..464df8c3 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -539,7 +539,7 @@ class Worksheet extends BIFFwriter * * @return string Binary data */ - private function writeBIFF8CellRangeAddressFixed($range = 'A1') + private function writeBIFF8CellRangeAddressFixed($range) { $explodes = explode(':', $range); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index ff5f808f..0885f927 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -156,7 +156,7 @@ class Xlsx extends BaseWriter implements IWriter * * @return \PhpOffice\PhpSpreadsheet\Writer\Xlsx\WriterPart */ - public function getWriterPart($pPartName = '') + public function getWriterPart($pPartName) { if ($pPartName != '' && isset($this->writerParts[strtolower($pPartName)])) { return $this->writerParts[strtolower($pPartName)]; @@ -172,7 +172,7 @@ class Xlsx extends BaseWriter implements IWriter * * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception */ - public function save($pFilename = null) + public function save($pFilename) { if ($this->spreadSheet !== null) { // garbage collect @@ -515,7 +515,7 @@ class Xlsx extends BaseWriter implements IWriter * * @return Xlsx */ - public function setOffice2003Compatibility($pValue = false) + public function setOffice2003Compatibility($pValue) { $this->office2003compatibility = $pValue; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index ca6211f8..a600d39f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -165,8 +165,8 @@ class ContentTypes extends WriterPart } $sheetCount = $spreadsheet->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { - if (count($spreadsheet->getSheet()->getHeaderFooter()->getImages()) > 0) { - foreach ($spreadsheet->getSheet()->getHeaderFooter()->getImages() as $image) { + if (count($spreadsheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) { + foreach ($spreadsheet->getSheet($i)->getHeaderFooter()->getImages() as $image) { if (!isset($aMediaContentTypes[strtolower($image->getExtension())])) { $aMediaContentTypes[strtolower($image->getExtension())] = $this->getImageMimeType($image->getPath()); @@ -191,7 +191,7 @@ class ContentTypes extends WriterPart * * @return string Mime Type */ - private function getImageMimeType($pFile = '') + private function getImageMimeType($pFile) { if (\PhpOffice\PhpSpreadsheet\Shared\File::fileExists($pFile)) { $image = getimagesize($pFile); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 7a03dc66..195572f3 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -85,7 +85,7 @@ class StringTable extends WriterPart * * @return string XML Output */ - public function writeStringTable($pStringTable = null) + public function writeStringTable(array $pStringTable = null) { if ($pStringTable !== null) { // Create XML writer @@ -286,7 +286,7 @@ class StringTable extends WriterPart * * @return array */ - public function flipStringTable($stringTable = []) + public function flipStringTable(array $stringTable) { // Return value $returnValue = []; diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php index d1416b2d..7a943642 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilterTest.php @@ -83,7 +83,7 @@ class AutoFilterTest extends \PHPUnit_Framework_TestCase $expectedResult = ''; // Setters return the instance to implement the fluent interface - $result = $this->testAutoFilterObject->setRange(); + $result = $this->testAutoFilterObject->setRange(''); $this->assertInstanceOf(AutoFilter::class, $result); // Result should be a clear range @@ -268,7 +268,7 @@ class AutoFilterTest extends \PHPUnit_Framework_TestCase public function testGetColumnWithoutRangeSet() { // Clear the range - $result = $this->testAutoFilterObject->setRange(); + $result = $this->testAutoFilterObject->setRange(''); $result = $this->testAutoFilterObject->getColumn('A'); } @@ -282,7 +282,7 @@ class AutoFilterTest extends \PHPUnit_Framework_TestCase } // Setters return the instance to implement the fluent interface - $result = $this->testAutoFilterObject->setRange(); + $result = $this->testAutoFilterObject->setRange(''); $this->assertInstanceOf(AutoFilter::class, $result); // Range should be cleared