From 779a081aa00e1c4f6bad792285d269564529cceb Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Thu, 16 Jun 2016 11:45:57 +0900 Subject: [PATCH] Remove references except where they're actually used --- Spreadsheet/Excel/Writer/Validator.php | 2 +- Spreadsheet/Excel/Writer/Workbook.php | 16 +++++------ Spreadsheet/Excel/Writer/Worksheet.php | 37 +++++++++++++++----------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Spreadsheet/Excel/Writer/Validator.php b/Spreadsheet/Excel/Writer/Validator.php index 6612315..e2bd4cf 100644 --- a/Spreadsheet/Excel/Writer/Validator.php +++ b/Spreadsheet/Excel/Writer/Validator.php @@ -67,7 +67,7 @@ class Spreadsheet_Excel_Writer_Validator */ public $_parser; - public function __construct(&$parser) + public function __construct($parser) { $this->_parser = $parser; $this->_type = 0x01; // FIXME: add method for setting datatype diff --git a/Spreadsheet/Excel/Writer/Workbook.php b/Spreadsheet/Excel/Writer/Workbook.php index 7b5da14..5948472 100644 --- a/Spreadsheet/Excel/Writer/Workbook.php +++ b/Spreadsheet/Excel/Writer/Workbook.php @@ -207,7 +207,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_string_sizeinfo = 3; // Add the default format for hyperlinks - $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1)); + $this->_url_format = $this->addFormat(array('color' => 'blue', 'underline' => 1)); $this->_str_total = 0; $this->_str_unique = 0; $this->_str_table = array(); @@ -320,7 +320,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * @return mixed reference to a worksheet object on success, PEAR_Error * on failure */ - public function &addWorksheet($name = '') + public function addWorksheet($name = '') { $index = count($this->_worksheets); $sheetname = $this->_sheetname; @@ -356,7 +356,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri $this->_str_table, $this->_url_format, $this->_parser, $this->_tmp_dir); - $this->_worksheets[$index] = &$worksheet; // Store ref for iterator + $this->_worksheets[$index] = $worksheet; // Store ref for iterator $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser return $worksheet; @@ -368,13 +368,13 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * * @access public * @param array $properties array with properties for initializing the format. - * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format + * @return Spreadsheet_Excel_Writer_Format */ - public function &addFormat($properties = array()) + public function addFormat($properties = array()) { $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); $this->_xf_index += 1; - $this->_formats[] = &$format; + $this->_formats[] = $format; return $format; } @@ -382,9 +382,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri * Create new validator. * * @access public - * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator + * @return Spreadsheet_Excel_Writer_Validator */ - public function &addValidator() + public function addValidator() { if (!class_exists('Spreadsheet_Excel_Writer_Validator')) { include_once 'Spreadsheet/Excel/Writer/Validator.php'; diff --git a/Spreadsheet/Excel/Writer/Worksheet.php b/Spreadsheet/Excel/Writer/Worksheet.php index 0d73ca5..4997477 100644 --- a/Spreadsheet/Excel/Writer/Worksheet.php +++ b/Spreadsheet/Excel/Writer/Worksheet.php @@ -380,18 +380,21 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * * @param string $name The name of the new worksheet * @param integer $index The index of the new worksheet - * @param mixed &$activesheet The current activesheet of the workbook we belong to - * @param mixed &$firstsheet The first worksheet in the workbook we belong to - * @param mixed &$url_format The default format for hyperlinks - * @param mixed &$parser The formula parser created for the Workbook + * @param mixed $activesheet The current activesheet of the workbook we belong to + * @param mixed $firstsheet The first worksheet in the workbook we belong to + * @param int &$str_total Reference to the total number of strings in the workbook + * @param int &$str_unique Reference to the number of unique strings in the workbook + * @param array &$str_table Reference to the array containing all the unique strings in the workbook + * @param mixed $url_format The default format for hyperlinks + * @param mixed $parser The formula parser created for the Workbook * @param string $tmp_dir The path to the directory for temporary files * @access private */ public function __construct($BIFF_version, $name, - $index, &$activesheet, - &$firstsheet, &$str_total, + $index, $activesheet, + $firstsheet, &$str_total, &$str_unique, &$str_table, - &$url_format, &$parser, + $url_format, $parser, $tmp_dir) { // It needs to call its parent's constructor explicitly @@ -402,13 +405,15 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr $this->name = $name; $this->index = $index; - $this->activesheet = &$activesheet; - $this->firstsheet = &$firstsheet; + $this->activesheet = $activesheet; + $this->firstsheet = $firstsheet; + // _str_total _str_unique _str_table - are actual references + // everything breaks if they're not $this->_str_total = &$str_total; $this->_str_unique = &$str_unique; $this->_str_table = &$str_table; - $this->_url_format = &$url_format; - $this->_parser = &$parser; + $this->_url_format = $url_format; + $this->_parser = $parser; //$this->ext_sheets = array(); $this->_filehandle = ''; @@ -804,7 +809,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr // if the new range lies WITHIN the existing range if ($lastcol < $existing_end) { // split the existing range by adding a range after our new range - $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], &$colinfo[3], $colinfo[4], $colinfo[5]); + $this->_colinfo[] = array($lastcol+1, $existing_end, $colinfo[2], /* format */ $colinfo[3], $colinfo[4], $colinfo[5]); } } // if the new range ends inside an existing range elseif ($lastcol > $existing_start && $lastcol < $existing_end) @@ -818,7 +823,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr } // added by Dan Lynn _colinfo = array_values($this->_colinfo); - $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); + $this->_colinfo[] = array($firstcol, $lastcol, $width, $format, $hidden, $level); // Set width to zero if column is hidden $width = ($hidden) ? 0 : $width; for ($col = $firstcol; $col <= $lastcol; $col++) @@ -1309,10 +1314,10 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr * Returns an index to the XF record in the workbook * * @access private - * @param mixed &$format The optional XF format + * @param mixed $format The optional XF format * @return integer The XF record index */ - protected function _XF(&$format) + protected function _XF($format) { if ($format) { return($format->getXfIndex()); @@ -3566,7 +3571,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr /** * FIXME: add comments */ - public function setValidation($row1, $col1, $row2, $col2, &$validator) + public function setValidation($row1, $col1, $row2, $col2, $validator) { $this->_dv[] = $validator->_getData() . pack("vvvvv", 1, $row1, $row2, $col1, $col2);