Fix Scrutinizer issues

This commit is contained in:
Adrien Crivelli 2017-10-29 23:34:00 +09:00
parent 557e80dc03
commit 8d23bda3dd
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
11 changed files with 118 additions and 125 deletions

View File

@ -6,7 +6,8 @@ use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Collection\Cells; use PhpOffice\PhpSpreadsheet\Collection\Cells;
use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Exception;
use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheet\RichText\RichText;
use PhpOffice\PhpSpreadsheet\Style; use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Style\Style;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class Cell class Cell
@ -167,7 +168,7 @@ class Cell
*/ */
public function getFormattedValue() public function getFormattedValue()
{ {
return (string) Style\NumberFormat::toFormattedString( return (string) NumberFormat::toFormattedString(
$this->getCalculatedValue(), $this->getCalculatedValue(),
$this->getStyle() $this->getStyle()
->getNumberFormat()->getFormatCode() ->getNumberFormat()->getFormatCode()

View File

@ -1343,7 +1343,7 @@ class Worksheet implements IComparable
* Get row dimension at a specific row. * Get row dimension at a specific row.
* *
* @param int $pRow Numeric index of the row * @param int $pRow Numeric index of the row
* @param mixed $create * @param bool $create
* *
* @return RowDimension * @return RowDimension
*/ */
@ -1369,7 +1369,7 @@ class Worksheet implements IComparable
* Get column dimension at a specific column. * Get column dimension at a specific column.
* *
* @param string $pColumn String index of the column eg: 'A' * @param string $pColumn String index of the column eg: 'A'
* @param mixed $create * @param bool $create
* *
* @return ColumnDimension * @return ColumnDimension
*/ */
@ -1910,7 +1910,7 @@ class Worksheet implements IComparable
/** /**
* Set AutoFilter. * Set AutoFilter.
* *
* @param string|Worksheet\AutoFilter $pValue * @param AutoFilter|string $pValue
* A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility * A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility
* *
* @throws Exception * @throws Exception
@ -1919,7 +1919,6 @@ class Worksheet implements IComparable
*/ */
public function setAutoFilter($pValue) public function setAutoFilter($pValue)
{ {
$pValue = strtoupper($pValue);
if (is_string($pValue)) { if (is_string($pValue)) {
$this->autoFilter->setRange($pValue); $this->autoFilter->setRange($pValue);
} elseif (is_object($pValue) && ($pValue instanceof AutoFilter)) { } elseif (is_object($pValue) && ($pValue instanceof AutoFilter)) {

View File

@ -1164,7 +1164,7 @@ class Html extends BaseWriter implements IWriter
* @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet * @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
* @param array $pValues Array containing cells in a row * @param array $pValues Array containing cells in a row
* @param int $pRow Row number (0-based) * @param int $pRow Row number (0-based)
* @param mixed $cellType eg: 'td' * @param string $cellType eg: 'td'
* *
* @throws WriterException * @throws WriterException
* *

View File

@ -3,7 +3,6 @@
namespace PhpOffice\PhpSpreadsheet\Writer\Ods; namespace PhpOffice\PhpSpreadsheet\Writer\Ods;
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
class MetaInf extends WriterPart class MetaInf extends WriterPart
{ {

View File

@ -224,8 +224,8 @@ class Workbook extends BIFFwriter
* *
* @param Style * @param Style
* @param bool Is it a style XF? * @param bool Is it a style XF?
* @param mixed $style * @param Style $style
* @param mixed $isStyleXf * @param bool $isStyleXf
* *
* @return int Index to XF record * @return int Index to XF record
*/ */
@ -683,7 +683,7 @@ class Workbook extends BIFFwriter
* *
* @param string $name The name in UTF-8 * @param string $name The name in UTF-8
* @param string $formulaData The binary formula data * @param string $formulaData The binary formula data
* @param string $sheetIndex 1-based sheet index the defined name applies to. 0 = global * @param int $sheetIndex 1-based sheet index the defined name applies to. 0 = global
* @param bool $isBuiltIn Built-in name? * @param bool $isBuiltIn Built-in name?
* *
* @return string Complete binary record data * @return string Complete binary record data

View File

@ -176,7 +176,7 @@ class Worksheet extends BIFFwriter
/** /**
* Sheet object. * Sheet object.
* *
* @var Worksheet * @var \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
*/ */
public $phpSheet; public $phpSheet;
@ -214,16 +214,15 @@ class Worksheet extends BIFFwriter
/** /**
* Constructor. * Constructor.
* *
* @param int &$str_total Total number of strings * @param int $str_total Total number of strings
* @param int &$str_unique Total number of unique strings * @param int $str_unique Total number of unique strings
* @param array &$str_table String Table * @param array &$str_table String Table
* @param array &$colors Colour Table * @param array &$colors Colour Table
* @param mixed $parser The formula parser created for the Workbook * @param Parser $parser The formula parser created for the Workbook
* @param bool $preCalculateFormulas Flag indicating whether formulas should be calculated or just written * @param bool $preCalculateFormulas Flag indicating whether formulas should be calculated or just written
* @param string $phpSheet The worksheet to write * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet The worksheet to write
* @param Worksheet $phpSheet
*/ */
public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, $parser, $preCalculateFormulas, $phpSheet) public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, Parser $parser, $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet)
{ {
// It needs to call its parent's constructor explicitly // It needs to call its parent's constructor explicitly
parent::__construct(); parent::__construct();

View File

@ -204,7 +204,7 @@ class Chart extends WriterPart
* Write Chart Plot Area. * Write Chart Plot Area.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param Worksheet $pSheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet
* @param PlotArea $plotArea * @param PlotArea $plotArea
* @param Title $xAxisLabel * @param Title $xAxisLabel
* @param Title $yAxisLabel * @param Title $yAxisLabel
@ -394,11 +394,11 @@ class Chart extends WriterPart
* @param string $id1 * @param string $id1
* @param string $id2 * @param string $id2
* @param bool $isMultiLevelSeries * @param bool $isMultiLevelSeries
* @param mixed $yAxis * @param Axis $yAxis
* *
* @throws WriterException * @throws WriterException
*/ */
private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, $yAxis) private function writeCategoryAxis($objWriter, $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis)
{ {
$objWriter->startElement('c:catAx'); $objWriter->startElement('c:catAx');
@ -515,13 +515,13 @@ class Chart extends WriterPart
* @param string $id1 * @param string $id1
* @param string $id2 * @param string $id2
* @param bool $isMultiLevelSeries * @param bool $isMultiLevelSeries
* @param mixed $xAxis * @param Axis $xAxis
* @param mixed $majorGridlines * @param GridLines $majorGridlines
* @param mixed $minorGridlines * @param GridLines $minorGridlines
* *
* @throws WriterException * @throws WriterException
*/ */
private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $majorGridlines, $minorGridlines) private function writeValueAxis($objWriter, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis, GridLines $majorGridlines, GridLines $minorGridlines)
{ {
$objWriter->startElement('c:valAx'); $objWriter->startElement('c:valAx');

View File

@ -11,7 +11,7 @@ class Comments extends WriterPart
/** /**
* Write comments to XML format. * Write comments to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* *
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* *
@ -94,7 +94,7 @@ class Comments extends WriterPart
/** /**
* Write VML comments to XML format. * Write VML comments to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* *
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* *

View File

@ -14,7 +14,7 @@ class Drawing extends WriterPart
/** /**
* Write drawings to XML format. * Write drawings to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* @param bool $includeCharts Flag indicating if we should include drawing details for charts * @param bool $includeCharts Flag indicating if we should include drawing details for charts
* *
* @throws WriterException * @throws WriterException
@ -271,7 +271,7 @@ class Drawing extends WriterPart
/** /**
* Write VML header/footer images to XML format. * Write VML header/footer images to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* *
* @throws WriterException * @throws WriterException
* *

View File

@ -168,7 +168,7 @@ class Rels extends WriterPart
* rId1 - Drawings * rId1 - Drawings
* rId_hyperlink_x - Hyperlinks * rId_hyperlink_x - Hyperlinks
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* @param int $pWorksheetId * @param int $pWorksheetId
* @param bool $includeCharts Flag indicating if we should write charts * @param bool $includeCharts Flag indicating if we should write charts
* *
@ -263,7 +263,7 @@ class Rels extends WriterPart
/** /**
* Write drawing relationships to XML format. * Write drawing relationships to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* @param int &$chartRef Chart ID * @param int &$chartRef Chart ID
* @param bool $includeCharts Flag indicating if we should write charts * @param bool $includeCharts Flag indicating if we should write charts
* *
@ -330,7 +330,7 @@ class Rels extends WriterPart
/** /**
* Write header/footer drawing relationships to XML format. * Write header/footer drawing relationships to XML format.
* *
* @param Worksheet $pWorksheet * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pWorksheet
* *
* @throws WriterException * @throws WriterException
* *

View File

@ -31,96 +31,92 @@ class Worksheet extends WriterPart
* *
* @return string XML Output * @return string XML Output
*/ */
public function writeWorksheet($pSheet = null, $pStringTable = null, $includeCharts = false) public function writeWorksheet(PhpspreadsheetWorksheet $pSheet, $pStringTable = null, $includeCharts = false)
{ {
if ($pSheet !== null) { // Create XML writer
// Create XML writer $objWriter = null;
$objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) {
if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
$objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else {
} else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
$objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Worksheet
$objWriter->startElement('worksheet');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
// sheetPr
$this->writeSheetPr($objWriter, $pSheet);
// Dimension
$this->writeDimension($objWriter, $pSheet);
// sheetViews
$this->writeSheetViews($objWriter, $pSheet);
// sheetFormatPr
$this->writeSheetFormatPr($objWriter, $pSheet);
// cols
$this->writeCols($objWriter, $pSheet);
// sheetData
$this->writeSheetData($objWriter, $pSheet, $pStringTable);
// sheetProtection
$this->writeSheetProtection($objWriter, $pSheet);
// protectedRanges
$this->writeProtectedRanges($objWriter, $pSheet);
// autoFilter
$this->writeAutoFilter($objWriter, $pSheet);
// mergeCells
$this->writeMergeCells($objWriter, $pSheet);
// conditionalFormatting
$this->writeConditionalFormatting($objWriter, $pSheet);
// dataValidations
$this->writeDataValidations($objWriter, $pSheet);
// hyperlinks
$this->writeHyperlinks($objWriter, $pSheet);
// Print options
$this->writePrintOptions($objWriter, $pSheet);
// Page margins
$this->writePageMargins($objWriter, $pSheet);
// Page setup
$this->writePageSetup($objWriter, $pSheet);
// Header / footer
$this->writeHeaderFooter($objWriter, $pSheet);
// Breaks
$this->writeBreaks($objWriter, $pSheet);
// Drawings and/or Charts
$this->writeDrawings($objWriter, $pSheet, $includeCharts);
// LegacyDrawing
$this->writeLegacyDrawing($objWriter, $pSheet);
// LegacyDrawingHF
$this->writeLegacyDrawingHF($objWriter, $pSheet);
$objWriter->endElement();
// Return
return $objWriter->getData();
} }
throw new WriterException('Invalid \\PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet object passed.'); // XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Worksheet
$objWriter->startElement('worksheet');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
// sheetPr
$this->writeSheetPr($objWriter, $pSheet);
// Dimension
$this->writeDimension($objWriter, $pSheet);
// sheetViews
$this->writeSheetViews($objWriter, $pSheet);
// sheetFormatPr
$this->writeSheetFormatPr($objWriter, $pSheet);
// cols
$this->writeCols($objWriter, $pSheet);
// sheetData
$this->writeSheetData($objWriter, $pSheet, $pStringTable);
// sheetProtection
$this->writeSheetProtection($objWriter, $pSheet);
// protectedRanges
$this->writeProtectedRanges($objWriter, $pSheet);
// autoFilter
$this->writeAutoFilter($objWriter, $pSheet);
// mergeCells
$this->writeMergeCells($objWriter, $pSheet);
// conditionalFormatting
$this->writeConditionalFormatting($objWriter, $pSheet);
// dataValidations
$this->writeDataValidations($objWriter, $pSheet);
// hyperlinks
$this->writeHyperlinks($objWriter, $pSheet);
// Print options
$this->writePrintOptions($objWriter, $pSheet);
// Page margins
$this->writePageMargins($objWriter, $pSheet);
// Page setup
$this->writePageSetup($objWriter, $pSheet);
// Header / footer
$this->writeHeaderFooter($objWriter, $pSheet);
// Breaks
$this->writeBreaks($objWriter, $pSheet);
// Drawings and/or Charts
$this->writeDrawings($objWriter, $pSheet, $includeCharts);
// LegacyDrawing
$this->writeLegacyDrawing($objWriter, $pSheet);
// LegacyDrawingHF
$this->writeLegacyDrawingHF($objWriter, $pSheet);
$objWriter->endElement();
// Return
return $objWriter->getData();
} }
/** /**
@ -531,7 +527,7 @@ class Worksheet extends WriterPart
* Write DataValidations. * Write DataValidations.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* *
* @throws WriterException * @throws WriterException
*/ */
@ -697,7 +693,7 @@ class Worksheet extends WriterPart
* Write PrintOptions. * Write PrintOptions.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* *
* @throws WriterException * @throws WriterException
*/ */
@ -724,7 +720,7 @@ class Worksheet extends WriterPart
* Write PageMargins. * Write PageMargins.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* *
* @throws WriterException * @throws WriterException
*/ */
@ -901,7 +897,7 @@ class Worksheet extends WriterPart
* Write Breaks. * Write Breaks.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* *
* @throws WriterException * @throws WriterException
*/ */
@ -1048,7 +1044,6 @@ class Worksheet extends WriterPart
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* @param Cell $pCellAddress Cell Address * @param Cell $pCellAddress Cell Address
* @param string[] $pStringTable String table
* @param string[] $pFlippedStringTable String table (flipped), for faster index searching * @param string[] $pFlippedStringTable String table (flipped), for faster index searching
* *
* @throws WriterException * @throws WriterException
@ -1167,7 +1162,7 @@ class Worksheet extends WriterPart
* Write Drawings. * Write Drawings.
* *
* @param XMLWriter $objWriter XML Writer * @param XMLWriter $objWriter XML Writer
* @param \PhpOffice\PhpSpreadsheet\Worksheet\PhpspreadsheetWorksheet $pSheet Worksheet * @param PhpspreadsheetWorksheet $pSheet Worksheet
* @param bool $includeCharts Flag indicating if we should include drawing details for charts * @param bool $includeCharts Flag indicating if we should include drawing details for charts
* *
* @throws WriterException * @throws WriterException