From 24a9eb285c8293163641b0659dcb82e6b15f3f58 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 16 Jan 2012 12:34:22 +0000 Subject: [PATCH] Use of empty() rather than count() to test if arrays are empty or not - simple performance tweak... empty() is over twice as fast as count() git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85344 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel.php | 2 +- .../PHPExcel/CachedObjectStorage/CacheBase.php | 2 +- Classes/PHPExcel/Calculation/DateTime.php | 2 +- Classes/PHPExcel/Calculation/Functions.php | 2 +- Classes/PHPExcel/Calculation/LookupRef.php | 2 +- Classes/PHPExcel/Calculation/MathTrig.php | 4 ++-- Classes/PHPExcel/Calculation/Statistical.php | 12 ++++++------ Classes/PHPExcel/Cell.php | 2 +- Classes/PHPExcel/Reader/Excel2003XML.php | 4 ++-- Classes/PHPExcel/Reader/Excel2007.php | 2 +- Classes/PHPExcel/Reader/Excel5.php | 4 ++-- Classes/PHPExcel/Reader/SYLK.php | 2 +- Classes/PHPExcel/ReferenceHelper.php | 6 +++--- Classes/PHPExcel/Shared/OLE/PPS.php | 2 +- Classes/PHPExcel/Writer/Excel2007.php | 4 ++-- .../PHPExcel/Writer/Excel2007/ContentTypes.php | 6 +++--- Classes/PHPExcel/Writer/Excel2007/DocProps.php | 2 +- Classes/PHPExcel/Writer/Excel2007/Rels.php | 6 +++--- Classes/PHPExcel/Writer/Excel2007/Workbook.php | 2 +- .../PHPExcel/Writer/Excel2007/Worksheet.php | 18 +++++++++--------- Classes/PHPExcel/Writer/Excel5.php | 6 +++--- Classes/PHPExcel/Writer/Excel5/Workbook.php | 2 +- Classes/PHPExcel/Writer/Excel5/Worksheet.php | 18 +++++++++--------- 23 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Classes/PHPExcel.php b/Classes/PHPExcel.php index df111d47..188ed258 100644 --- a/Classes/PHPExcel.php +++ b/Classes/PHPExcel.php @@ -767,7 +767,7 @@ class PHPExcel } // make sure there is always at least one cellXf (there should be) - if (count($this->_cellXfCollection) == 0) { + if (empty($this->_cellXfCollection)) { $this->_cellXfCollection[] = new PHPExcel_Style(); } diff --git a/Classes/PHPExcel/CachedObjectStorage/CacheBase.php b/Classes/PHPExcel/CachedObjectStorage/CacheBase.php index ccfc0c1d..28353387 100644 --- a/Classes/PHPExcel/CachedObjectStorage/CacheBase.php +++ b/Classes/PHPExcel/CachedObjectStorage/CacheBase.php @@ -171,7 +171,7 @@ class PHPExcel_CachedObjectStorage_CacheBase { $row[$r] = $r; $col[$c] = strlen($c).$c; } - if (count($row) > 0) { + if (!empty($row)) { // Determine highest column and row $highestRow = max($row); $highestColumn = substr(max($col),1); diff --git a/Classes/PHPExcel/Calculation/DateTime.php b/Classes/PHPExcel/Calculation/DateTime.php index f348c319..6b30a7a5 100644 --- a/Classes/PHPExcel/Calculation/DateTime.php +++ b/Classes/PHPExcel/Calculation/DateTime.php @@ -789,7 +789,7 @@ class PHPExcel_Calculation_DateTime { } // Test any extra holiday parameters - if (count($dateArgs) > 0) { + if (!empty($dateArgs)) { $holidayCountedArray = $holidayDates = array(); foreach ($dateArgs as $holidayDate) { if ((!is_null($holidayDate)) && (trim($holidayDate) > '')) { diff --git a/Classes/PHPExcel/Calculation/Functions.php b/Classes/PHPExcel/Calculation/Functions.php index a81705ef..1cb48ead 100644 --- a/Classes/PHPExcel/Calculation/Functions.php +++ b/Classes/PHPExcel/Calculation/Functions.php @@ -555,7 +555,7 @@ class PHPExcel_Calculation_Functions { } elseif (self::isMatrixValue($a)) { return 64; } - } elseif(count($value) == 0) { + } elseif(empty($value)) { // Empty Cell return 1; } diff --git a/Classes/PHPExcel/Calculation/LookupRef.php b/Classes/PHPExcel/Calculation/LookupRef.php index e305cc8b..b9d8c5f6 100644 --- a/Classes/PHPExcel/Calculation/LookupRef.php +++ b/Classes/PHPExcel/Calculation/LookupRef.php @@ -697,7 +697,7 @@ class PHPExcel_Calculation_LookupRef { } // index_number must be less than or equal to the number of columns in lookup_array - if ((!is_array($lookup_array)) || (count($lookup_array) < 1)) { + if ((!is_array($lookup_array)) || (empty($lookup_array))) { return PHPExcel_Calculation_Functions::REF(); } else { $f = array_keys($lookup_array); diff --git a/Classes/PHPExcel/Calculation/MathTrig.php b/Classes/PHPExcel/Calculation/MathTrig.php index ef1e767b..a20122e6 100644 --- a/Classes/PHPExcel/Calculation/MathTrig.php +++ b/Classes/PHPExcel/Calculation/MathTrig.php @@ -61,7 +61,7 @@ class PHPExcel_Calculation_MathTrig { } } } - if (count($factorArray) > 0) { + if (!empty($factorArray)) { rsort($factorArray); return $factorArray; } else { @@ -1040,7 +1040,7 @@ class PHPExcel_Calculation_MathTrig { $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); - if (count($sumArgs) == 0) { + if (empty($sumArgs)) { $sumArgs = $aArgs; } $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); diff --git a/Classes/PHPExcel/Calculation/Statistical.php b/Classes/PHPExcel/Calculation/Statistical.php index 923d9d58..a5c0c71b 100644 --- a/Classes/PHPExcel/Calculation/Statistical.php +++ b/Classes/PHPExcel/Calculation/Statistical.php @@ -841,7 +841,7 @@ class PHPExcel_Calculation_Statistical { $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $averageArgs = PHPExcel_Calculation_Functions::flattenArray($averageArgs); - if (count($averageArgs) == 0) { + if (empty($averageArgs)) { $averageArgs = $aArgs; } $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); @@ -1734,7 +1734,7 @@ class PHPExcel_Calculation_Statistical { $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); $bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const); - if (count($newValues) == 0) { + if (empty($newValues)) { $newValues = $bestFitExponential->getXValues(); } @@ -2202,7 +2202,7 @@ class PHPExcel_Calculation_Statistical { $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); - if (count($sumArgs) == 0) { + if (empty($sumArgs)) { $sumArgs = $aArgs; } $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); @@ -2364,7 +2364,7 @@ class PHPExcel_Calculation_Statistical { $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs); $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs); - if (count($sumArgs) == 0) { + if (empty($sumArgs)) { $sumArgs = $aArgs; } $condition = PHPExcel_Calculation_Functions::_ifCondition($condition); @@ -2446,7 +2446,7 @@ class PHPExcel_Calculation_Statistical { } } - if (count($mArgs) > 0) { + if (!empty($mArgs)) { return self::_modeCalc($mArgs); } @@ -3332,7 +3332,7 @@ class PHPExcel_Calculation_Statistical { $const = (is_null($const)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($const); $bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const); - if (count($newValues) == 0) { + if (empty($newValues)) { $newValues = $bestFitLinear->getXValues(); } diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 87b5f02e..1617ecfd 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -581,7 +581,7 @@ class PHPExcel_Cell public static function buildRange($pRange) { // Verify range - if (!is_array($pRange) || count($pRange) == 0 || !is_array($pRange[0])) { + if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) { throw new Exception('Range does not contain any information.'); } diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php index 2a64a13f..5151b4f2 100644 --- a/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/Classes/PHPExcel/Reader/Excel2003XML.php @@ -482,7 +482,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader break; } } - if (count($thisBorder) > 0) { + if (!empty($thisBorder)) { if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) { $this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder; } @@ -767,7 +767,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader if (($cellIsSet) && (isset($cell_ss['StyleID']))) { $style = (string) $cell_ss['StyleID']; // echo 'Cell style for '.$columnID.$rowID.' is '.$style.'
'; - if ((isset($this->_styles[$style])) && (count($this->_styles[$style]) > 0)) { + if ((isset($this->_styles[$style])) && (!empty($this->_styles[$style]))) { // echo 'Cell '.$columnID.$rowID.'
'; // print_r($this->_styles[$style]); // echo '
'; diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index 27aeedff..baf29f60 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -1186,7 +1186,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader $row = null; $clientData = $shape->xpath('.//x:ClientData'); - if (is_array($clientData) && count($clientData) > 0) { + if (is_array($clientData) && !empty($clientData)) { $clientData = $clientData[0]; if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 4e2c8dc0..c33bd49d 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -949,7 +949,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader } } - if (count($this->_cellNotes) > 0) { + if (!empty($this->_cellNotes)) { foreach($this->_cellNotes as $note => $noteDetails) { // echo 'Cell annotation ',$note,'
'; // var_dump($noteDetails); @@ -4903,7 +4903,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader private function _createFormulaFromTokens($tokens, $additionalData) { // empty formula? - if (count($tokens) == 0) { + if (empty($tokens)) { return ''; } diff --git a/Classes/PHPExcel/Reader/SYLK.php b/Classes/PHPExcel/Reader/SYLK.php index e2ce8dac..97d98506 100644 --- a/Classes/PHPExcel/Reader/SYLK.php +++ b/Classes/PHPExcel/Reader/SYLK.php @@ -354,7 +354,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]); } - if ((count($styleData) > 0) && ($column > '') && ($row > '')) { + if ((!empty($styleData)) && ($column > '') && ($row > '')) { $columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1); $objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData); } diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 206ad9e8..8f006d47 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -214,7 +214,7 @@ class PHPExcel_ReferenceHelper // Update worksheet: column dimensions $aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true); - if (count($aColumnDimensions) > 0) { + if (!empty($aColumnDimensions)) { foreach ($aColumnDimensions as $objColumnDimension) { $newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows); list($newReference) = PHPExcel_Cell::coordinateFromString($newReference); @@ -228,7 +228,7 @@ class PHPExcel_ReferenceHelper // Update worksheet: row dimensions $aRowDimensions = array_reverse($pSheet->getRowDimensions(), true); - if (count($aRowDimensions) > 0) { + if (!empty($aRowDimensions)) { foreach ($aRowDimensions as $objRowDimension) { $newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows); list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference); @@ -340,7 +340,7 @@ class PHPExcel_ReferenceHelper // Update workbook: named ranges - if (count($pSheet->getParent()->getNamedRanges()) > 0) { + if (!empty($pSheet->getParent()->getNamedRanges())) { foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) { if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) { $namedRange->setRange( diff --git a/Classes/PHPExcel/Shared/OLE/PPS.php b/Classes/PHPExcel/Shared/OLE/PPS.php index 60b815a0..4db0ae4e 100644 --- a/Classes/PHPExcel/Shared/OLE/PPS.php +++ b/Classes/PHPExcel/Shared/OLE/PPS.php @@ -202,7 +202,7 @@ class PHPExcel_Shared_OLE_PPS */ public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0) { - if ( !is_array($to_save) || (count($to_save) == 0) ) { + if ( !is_array($to_save) || (empty($to_save)) ) { return 0xFFFFFFFF; } elseif( count($to_save) == 1 ) { $cnt = count($raList); diff --git a/Classes/PHPExcel/Writer/Excel2007.php b/Classes/PHPExcel/Writer/Excel2007.php index 7823d0f3..f18cbbcd 100644 --- a/Classes/PHPExcel/Writer/Excel2007.php +++ b/Classes/PHPExcel/Writer/Excel2007.php @@ -288,7 +288,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } // Add comment relationship parts - if (count($this->_spreadSheet->getSheet($i)->getComments()) > 0) { + if (!empty($this->_spreadSheet->getSheet($i)->getComments())) { // VML Comments $objZip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->_spreadSheet->getSheet($i))); @@ -297,7 +297,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter } // Add header/footer relationship parts - if (count($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) { + if (!empty($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages())) { // VML Drawings $objZip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->_spreadSheet->getSheet($i))); diff --git a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php index 3beca974..5fae5b89 100644 --- a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php +++ b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php @@ -99,7 +99,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W ); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); - if (count($customPropertyList) > 0) { + if (!empty($customPropertyList)) { $this->_writeOverrideContentType( $objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml' ); @@ -129,7 +129,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W // Comments for ($i = 0; $i < $sheetCount; ++$i) { - if (count($pPHPExcel->getSheet($i)->getComments()) > 0) { + if (!empty($pPHPExcel->getSheet($i)->getComments())) { $this->_writeOverrideContentType( $objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml' ); @@ -165,7 +165,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W $sheetCount = $pPHPExcel->getSheetCount(); for ($i = 0; $i < $sheetCount; ++$i) { - if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) { + if (!empty($pPHPExcel->getSheet()->getHeaderFooter()->getImages())) { foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) { if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) { $aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() ); diff --git a/Classes/PHPExcel/Writer/Excel2007/DocProps.php b/Classes/PHPExcel/Writer/Excel2007/DocProps.php index 944f6264..b9b6d286 100644 --- a/Classes/PHPExcel/Writer/Excel2007/DocProps.php +++ b/Classes/PHPExcel/Writer/Excel2007/DocProps.php @@ -209,7 +209,7 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write public function writeDocPropsCustom(PHPExcel $pPHPExcel = null) { $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); - if (count($customPropertyList) == 0) { + if (empty($customPropertyList)) { return; } diff --git a/Classes/PHPExcel/Writer/Excel2007/Rels.php b/Classes/PHPExcel/Writer/Excel2007/Rels.php index 42ae7d21..8c4bc20a 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Rels.php +++ b/Classes/PHPExcel/Writer/Excel2007/Rels.php @@ -60,7 +60,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); - if (count($customPropertyList) > 0) { + if (!empty($customPropertyList)) { // Relationship docProps/app.xml $this->_writeRelationship( $objWriter, @@ -223,7 +223,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar // Write comments relationship? $i = 1; - if (count($pWorksheet->getComments()) > 0) { + if (!empty($pWorksheet->getComments())) { $this->_writeRelationship( $objWriter, '_comments_vml' . $i, @@ -241,7 +241,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar // Write header/footer relationship? $i = 1; - if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) { + if (!empty($pWorksheet->getHeaderFooter()->getImages())) { $this->_writeRelationship( $objWriter, '_headerfooter_vml' . $i, diff --git a/Classes/PHPExcel/Writer/Excel2007/Workbook.php b/Classes/PHPExcel/Writer/Excel2007/Workbook.php index af3fa9c3..244d9e5c 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Workbook.php +++ b/Classes/PHPExcel/Writer/Excel2007/Workbook.php @@ -265,7 +265,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write $objWriter->startElement('definedNames'); // Named ranges - if (count($pPHPExcel->getNamedRanges()) > 0) { + if (!empty($pPHPExcel->getNamedRanges())) { // Named ranges $this->_writeNamedRanges($objWriter, $pPHPExcel); } diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 73cb5ca5..a548ae44 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -342,7 +342,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ private function _writeCols(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { // cols - if (count($pSheet->getColumnDimensions()) > 0) { + if (!empty($pSheet->getColumnDimensions())) { $objWriter->startElement('cols'); $pSheet->calculateColumnWidths(); @@ -521,7 +521,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $dataValidationCollection = $pSheet->getDataValidationCollection(); // Write data validations? - if (count($dataValidationCollection) > 0) { + if (!empty($dataValidationCollection)) { $objWriter->startElement('dataValidations'); $objWriter->writeAttribute('count', count($dataValidationCollection)); @@ -590,7 +590,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $relationId = 1; // Write hyperlinks? - if (count($hyperlinkCollection) > 0) { + if (!empty($hyperlinkCollection)) { $objWriter->startElement('hyperlinks'); foreach ($hyperlinkCollection as $coordinate => $hyperlink) { @@ -624,7 +624,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ */ private function _writeProtectedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { - if (count($pSheet->getProtectedCells()) > 0) { + if (!empty($pSheet->getProtectedCells())) { // protectedRanges $objWriter->startElement('protectedRanges'); @@ -651,7 +651,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ */ private function _writeMergeCells(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { - if (count($pSheet->getMergeCells()) > 0) { + if (!empty($pSheet->getMergeCells())) { // mergeCells $objWriter->startElement('mergeCells'); @@ -811,7 +811,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ } // rowBreaks - if (count($aRowBreaks) > 0) { + if (!empty($aRowBreaks)) { $objWriter->startElement('rowBreaks'); $objWriter->writeAttribute('count', count($aRowBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aRowBreaks)); @@ -829,7 +829,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ } // Second, write column breaks - if (count($aColumnBreaks) > 0) { + if (!empty($aColumnBreaks)) { $objWriter->startElement('colBreaks'); $objWriter->writeAttribute('count', count($aColumnBreaks)); $objWriter->writeAttribute('manualBreakCount', count($aColumnBreaks)); @@ -1093,7 +1093,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ private function _writeLegacyDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { // If sheet contains comments, add the relationships - if (count($pSheet->getComments()) > 0) { + if (!empty($pSheet->getComments())) { $objWriter->startElement('legacyDrawing'); $objWriter->writeAttribute('r:id', 'rId_comments_vml1'); $objWriter->endElement(); @@ -1110,7 +1110,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ private function _writeLegacyDrawingHF(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null) { // If sheet contains comments, add the relationships - if (count($pSheet->getHeaderFooter()->getImages()) > 0) { + if (!empty($pSheet->getHeaderFooter()->getImages())) { $objWriter->startElement('legacyDrawingHF'); $objWriter->writeAttribute('r:id', 'rId_headerfooter_vml1'); $objWriter->endElement(); diff --git a/Classes/PHPExcel/Writer/Excel5.php b/Classes/PHPExcel/Writer/Excel5.php index 1f1e650e..20b094a0 100644 --- a/Classes/PHPExcel/Writer/Excel5.php +++ b/Classes/PHPExcel/Writer/Excel5.php @@ -223,7 +223,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter $escher = null; // check if there are any shapes for this sheet - if (count($sheet->getDrawingCollection()) == 0) { + if (empty($sheet->getDrawingCollection())) { continue; } @@ -319,7 +319,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter // any drawings in this workbook? $found = false; foreach ($this->_phpExcel->getAllSheets() as $sheet) { - if (count($sheet->getDrawingCollection()) > 0) { + if (!empty($sheet->getDrawingCollection())) { $found = true; break; } @@ -348,7 +348,7 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter foreach ($this->_phpExcel->getAllsheets() as $sheet) { $sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet - if (count($sheet->getDrawingCollection()) > 0) { + if (!empty($sheet->getDrawingCollection())) { ++$countDrawings; foreach ($sheet->getDrawingCollection() as $drawing) { diff --git a/Classes/PHPExcel/Writer/Excel5/Workbook.php b/Classes/PHPExcel/Writer/Excel5/Workbook.php index f8599d58..304ed233 100644 --- a/Classes/PHPExcel/Writer/Excel5/Workbook.php +++ b/Classes/PHPExcel/Writer/Excel5/Workbook.php @@ -643,7 +643,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter $chunk = ''; // Named ranges - if (count($this->_phpExcel->getNamedRanges()) > 0) { + if (!empty($this->_phpExcel->getNamedRanges())) { // Loop named ranges $namedRanges = $this->_phpExcel->getNamedRanges(); foreach ($namedRanges as $namedRange) { diff --git a/Classes/PHPExcel/Writer/Excel5/Worksheet.php b/Classes/PHPExcel/Writer/Excel5/Worksheet.php index baa72a4a..1c46a408 100644 --- a/Classes/PHPExcel/Writer/Excel5/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel5/Worksheet.php @@ -2104,7 +2104,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } //horizontal page breaks - if (count($hbreaks) > 0) { + if (!empty($hbreaks)) { // Sort and filter array of page breaks sort($hbreaks, SORT_NUMERIC); @@ -2128,7 +2128,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter } // vertical page breaks - if (count($vbreaks) > 0) { + if (!empty($vbreaks)) { // 1000 vertical pagebreaks appears to be an internal Excel 5 limit. // It is slightly higher in Excel 97/200, approx. 1026 @@ -2691,21 +2691,21 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter $dataValidationCollection = $this->_phpSheet->getDataValidationCollection(); // Write data validations? - if (count($dataValidationCollection) > 0) { + if (!empty($dataValidationCollection)) { // DATAVALIDATIONS record $record = 0x01B2; // Record identifier - $length = 0x0012; // Bytes to follow + $length = 0x0012; // Bytes to follow $grbit = 0x0000; // Prompt box at cell, no cached validity data at DV records - $horPos = 0x00000000; // Horizontal position of prompt box, if fixed position - $verPos = 0x00000000; // Vertical position of prompt box, if fixed position + $horPos = 0x00000000; // Horizontal position of prompt box, if fixed position + $verPos = 0x00000000; // Vertical position of prompt box, if fixed position $objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible - $header = pack('vv', $record, $length); - $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, + $header = pack('vv', $record, $length); + $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection)); - $this->_append($header.$data); + $this->_append($header.$data); // DATAVALIDATION records $record = 0x01BE; // Record identifier