From 6a41381c1d562d9dd48973d0a49c303531ca2ee3 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 26 Jul 2020 13:51:13 +0900 Subject: [PATCH] PSR12 code style --- samples/Basic/13_Calculation.php | 6 +- .../Basic/13_CalculationCyclicFormulae.php | 6 +- .../Basic/45_Quadratic_equation_solver.php | 1 + .../Calculation/Calculation.php | 57 ++++++++----- src/PhpSpreadsheet/Calculation/DateTime.php | 6 +- .../Calculation/Engineering.php | 9 +- src/PhpSpreadsheet/Calculation/Financial.php | 42 ++++++---- .../Calculation/FormulaParser.php | 36 +++++--- src/PhpSpreadsheet/Calculation/Functions.php | 6 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 33 +++++--- src/PhpSpreadsheet/Calculation/MathTrig.php | 48 +++++++---- .../Calculation/Statistical.php | 84 ++++++++++++------- src/PhpSpreadsheet/Document/Properties.php | 13 +-- src/PhpSpreadsheet/Reader/Gnumeric.php | 6 +- src/PhpSpreadsheet/Reader/Ods.php | 9 +- src/PhpSpreadsheet/Reader/Xls.php | 30 ++++--- src/PhpSpreadsheet/Reader/Xlsx.php | 24 ++++-- .../Reader/Xlsx/ColumnAndRowAttributes.php | 12 ++- .../Reader/Xlsx/ConditionalStyles.php | 6 +- src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php | 30 ++++--- .../Reader/Xlsx/SheetViewOptions.php | 30 ++++--- src/PhpSpreadsheet/Reader/Xml.php | 6 +- src/PhpSpreadsheet/ReferenceHelper.php | 12 ++- src/PhpSpreadsheet/Shared/Date.php | 12 ++- .../Shared/JAMA/EigenvalueDecomposition.php | 6 +- .../Shared/JAMA/utils/Maths.php | 1 + src/PhpSpreadsheet/Shared/OLE.php | 68 +++++++-------- .../Shared/OLE/ChainedBlockStream.php | 4 +- src/PhpSpreadsheet/Shared/OLE/PPS.php | 12 +-- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 28 +++---- src/PhpSpreadsheet/Shared/OLERead.php | 6 +- src/PhpSpreadsheet/Spreadsheet.php | 12 ++- src/PhpSpreadsheet/Style/Alignment.php | 6 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 42 ++++++---- .../Worksheet/AutoFilter/Column/Rule.php | 12 ++- .../Worksheet/ColumnCellIterator.php | 24 ++++-- src/PhpSpreadsheet/Worksheet/Worksheet.php | 18 ++-- src/PhpSpreadsheet/Writer/Html.php | 3 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 24 ++++-- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 18 ++-- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 6 +- .../Writer/Xlsx/StringTable.php | 12 ++- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 24 ++++-- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 18 ++-- .../Functional/ReadFilterTest.php | 10 ++- .../Reader/Html/HtmlTest.php | 1 + 46 files changed, 566 insertions(+), 313 deletions(-) diff --git a/samples/Basic/13_Calculation.php b/samples/Basic/13_Calculation.php index 087b443f..ed2e1dcc 100644 --- a/samples/Basic/13_Calculation.php +++ b/samples/Basic/13_Calculation.php @@ -157,8 +157,10 @@ $spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:') $helper->log('Calculated data'); for ($col = 'B'; $col != 'G'; ++$col) { for ($row = 14; $row <= 41; ++$row) { - if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && - ($formula[0] == '=')) { + if ( + (($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && + ($formula[0] == '=') + ) { $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); } } diff --git a/samples/Basic/13_CalculationCyclicFormulae.php b/samples/Basic/13_CalculationCyclicFormulae.php index a446e56e..b7c6a511 100644 --- a/samples/Basic/13_CalculationCyclicFormulae.php +++ b/samples/Basic/13_CalculationCyclicFormulae.php @@ -22,8 +22,10 @@ Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 15; $helper->log('Calculated data'); for ($row = 1; $row <= 2; ++$row) { for ($col = 'A'; $col != 'C'; ++$col) { - if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && - ($formula[0] == '=')) { + if ( + (($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && + ($formula[0] == '=') + ) { $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); } } diff --git a/samples/Basic/45_Quadratic_equation_solver.php b/samples/Basic/45_Quadratic_equation_solver.php index a59a0ceb..84c126aa 100644 --- a/samples/Basic/45_Quadratic_equation_solver.php +++ b/samples/Basic/45_Quadratic_equation_solver.php @@ -1,4 +1,5 @@ raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression } elseif ((isset(self::$operators[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? - while ($stack->count() > 0 && + while ( + $stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && - @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { + @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']]) + ) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } @@ -3960,7 +3964,8 @@ class Calculation } ++$index; } elseif ($opCharacter == ',') { // Is this the separator for function arguments? - if (!empty($pendingStoreKey) && + if ( + !empty($pendingStoreKey) && $parenthesisDepthMap[$pendingStoreKey] == 0 ) { // We must go to the IF next argument @@ -4088,14 +4093,18 @@ class Calculation if ($pCellParent !== null && $rangeSheetRef !== $pCellParent->getTitle()) { $refSheet = $pCellParent->getParent()->getSheetByName($rangeSheetRef); } - if ((is_int($startRowColRef)) && (ctype_digit($val)) && - ($startRowColRef <= 1048576) && ($val <= 1048576)) { + if ( + (is_int($startRowColRef)) && (ctype_digit($val)) && + ($startRowColRef <= 1048576) && ($val <= 1048576) + ) { // Row range $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 $output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef; $val = $rangeWS2 . $endRowColRef . $val; - } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && - (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { + } elseif ( + (ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && + (strlen($startRowColRef) <= 3) && (strlen($val) <= 3) + ) { // Column range $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 $output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1'; @@ -4168,16 +4177,20 @@ class Calculation } // If we're expecting an operator, but only have a space between the previous and next operands (and both are // Cell References) then we have an INTERSECTION operator - if (($expectingOperator) && + if ( + ($expectingOperator) && ((preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && ($output[count($output) - 1]['type'] == 'Cell Reference') || (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/miu', substr($formula, $index), $match)) && ($output[count($output) - 1]['type'] == 'Named Range' || $output[count($output) - 1]['type'] == 'Value') - )) { - while ($stack->count() > 0 && + ) + ) { + while ( + $stack->count() > 0 && ($o2 = $stack->last()) && isset(self::$operators[$o2['value']]) && - @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { + @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']]) + ) { $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack @@ -4252,7 +4265,8 @@ class Calculation $storeValue = end($wrappedItem); } - if (isset($storeValue) + if ( + isset($storeValue) && ( !$storeValueAsBool || Functions::isError($storeValue) @@ -4286,7 +4300,8 @@ class Calculation $wrappedItem = end($storeValue); $storeValue = end($wrappedItem); } - if (isset($storeValue) + if ( + isset($storeValue) && ( $storeValueAsBool || Functions::isError($storeValue) @@ -4623,9 +4638,11 @@ class Calculation for ($i = 0; $i < $argCount; ++$i) { $arg = $stack->pop(); $a = $argCount - $i - 1; - if (($passByReference) && + if ( + ($passByReference) && (isset(self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) && - (self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) { + (self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a]) + ) { if ($arg['reference'] === null) { $args[] = $cellID; if ($functionName != 'MKMATRIX') { @@ -4949,9 +4966,11 @@ class Calculation $result = '#VALUE!'; } } else { - if ((Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) && + if ( + (Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) && ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) || - (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0))) { + (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0)) + ) { $result = Functions::VALUE(); } else { // If we're dealing with non-matrix operations, execute the necessary operation diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 19860794..bfce2a02 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -274,9 +274,11 @@ class DateTime $year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0; $month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0; $day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0; - if ((!is_numeric($year)) || + if ( + (!is_numeric($year)) || (!is_numeric($month)) || - (!is_numeric($day))) { + (!is_numeric($day)) + ) { return Functions::VALUE(); } $year = (int) $year; diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index dcbd5394..1256dd90 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -1674,7 +1674,8 @@ class Engineering $imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary); $suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix); - if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && + if ( + ((is_numeric($realNumber)) && (is_numeric($imaginary))) && (($suffix == 'i') || ($suffix == 'j') || ($suffix == '')) ) { $complex = new Complex($realNumber, $imaginary, $suffix); @@ -2729,11 +2730,13 @@ class Engineering } return $value; - } elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) && + } elseif ( + (($fromUOM == 'K') || ($fromUOM == 'kel')) && (($toUOM == 'K') || ($toUOM == 'kel')) ) { return $value; - } elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) && + } elseif ( + (($fromUOM == 'C') || ($fromUOM == 'cel')) && (($toUOM == 'C') || ($toUOM == 'cel')) ) { return $value; diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 073e7c48..5a908aa5 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -395,9 +395,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -452,9 +454,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -520,9 +524,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -574,9 +580,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -625,9 +633,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -678,9 +688,11 @@ class Financial return Functions::VALUE(); } - if (($settlement >= $maturity) || + if ( + ($settlement >= $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } @@ -1619,9 +1631,11 @@ class Financial $frequency = (int) $frequency; $basis = (int) $basis; - if (($settlement > $maturity) || + if ( + ($settlement > $maturity) || (!self::isValidFrequency($frequency)) || - (($basis < 0) || ($basis > 4))) { + (($basis < 0) || ($basis > 4)) + ) { return Functions::NAN(); } diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index f6c88b26..c11af834 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -490,11 +490,13 @@ class FormulaParser continue; } - if (!( + if ( + !( (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) - )) { + ) + ) { continue; } @@ -502,11 +504,13 @@ class FormulaParser continue; } - if (!( + if ( + !( (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) || (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) || ($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) - )) { + ) + ) { continue; } @@ -538,12 +542,14 @@ class FormulaParser if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') { if ($i == 0) { $token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX); - } elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && + } elseif ( + (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || - ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) { + ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) + ) { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH); } else { $token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX); @@ -557,12 +563,14 @@ class FormulaParser if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') { if ($i == 0) { continue; - } elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && + } elseif ( + (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || - ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) { + ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) + ) { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH); } else { continue; @@ -573,8 +581,10 @@ class FormulaParser continue; } - if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && - $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) { + if ( + $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && + $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING + ) { if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL); } elseif ($token->getValue() == '&') { @@ -588,8 +598,10 @@ class FormulaParser continue; } - if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND && - $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) { + if ( + $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND && + $token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING + ) { if (!is_numeric($token->getValue())) { if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') { $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL); diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 148d75b3..2a4e6f40 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -67,7 +67,8 @@ class Functions */ public static function setCompatibilityMode($compatibilityMode) { - if (($compatibilityMode == self::COMPATIBILITY_EXCEL) || + if ( + ($compatibilityMode == self::COMPATIBILITY_EXCEL) || ($compatibilityMode == self::COMPATIBILITY_GNUMERIC) || ($compatibilityMode == self::COMPATIBILITY_OPENOFFICE) ) { @@ -106,7 +107,8 @@ class Functions */ public static function setReturnDateType($returnDateType) { - if (($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) || + if ( + ($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) || ($returnDateType == self::RETURNDATE_PHP_DATETIME_OBJECT) || ($returnDateType == self::RETURNDATE_EXCEL) ) { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 6e817006..7c00ca32 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -286,8 +286,10 @@ class LookupRef [$cellAddress1, $cellAddress2] = explode(':', $cellAddress); } - if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || - (($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) { + if ( + (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || + (($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches))) + ) { if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) { return Functions::REF(); } @@ -495,7 +497,8 @@ class LookupRef // Lookup_array should contain only number, text, or logical values, or empty (null) cells foreach ($lookupArray as $i => $lookupArrayValue) { // check the type of the value - if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && + if ( + (!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null) ) { return Functions::NA(); @@ -750,18 +753,23 @@ class LookupRef $firstLower = StringHelper::strToLower($rowData[$firstColumn]); // break if we have passed possible keys - if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || - (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))) { + if ( + (is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || + (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower)) + ) { break; } // remember the last key, but only if datatypes match - if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) || - (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))) { + if ( + (is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) || + (!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn])) + ) { if ($not_exact_match) { $rowNumber = $rowKey; continue; - } elseif (($firstLower == $lookupLower) + } elseif ( + ($firstLower == $lookupLower) // Spreadsheets software returns first exact match, // we have sorted and we might have broken key orders // we want the first one (by its initial index) @@ -823,10 +831,12 @@ class LookupRef $lookupLower = StringHelper::strToLower($lookup_value); $rowDataLower = StringHelper::strToLower($rowData); - if ($not_exact_match && ( + if ( + $not_exact_match && ( ($bothNumeric && $rowData > $lookup_value) || ($bothNotNumeric && $rowDataLower > $lookupLower) - )) { + ) + ) { break; } @@ -836,7 +846,8 @@ class LookupRef $rowNumber = $rowKey; continue; - } elseif ($rowDataLower === $lookupLower + } elseif ( + $rowDataLower === $lookupLower && ($rowNumber === null || $rowKey < $rowNumber) ) { $rowNumber = $rowKey; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 85f94cc2..fa4c74d3 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -147,8 +147,10 @@ class MathTrig $xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0; $yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0; - if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) && - ((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) { + if ( + ((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) && + ((is_numeric($yCoordinate))) || (is_bool($yCoordinate)) + ) { $xCoordinate = (float) $xCoordinate; $yCoordinate = (float) $yCoordinate; @@ -224,8 +226,10 @@ class MathTrig $number = Functions::flattenSingleValue($number); $significance = Functions::flattenSingleValue($significance); - if (($significance === null) && - (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { + if ( + ($significance === null) && + (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) + ) { $significance = $number / abs($number); } @@ -331,8 +335,10 @@ class MathTrig return Functions::NAN(); } $factLoop = floor($factVal); - if ((Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) && - ($factVal > $factLoop)) { + if ( + (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) && + ($factVal > $factLoop) + ) { return Functions::NAN(); } @@ -398,8 +404,10 @@ class MathTrig $number = Functions::flattenSingleValue($number); $significance = Functions::flattenSingleValue($significance); - if (($significance === null) && - (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { + if ( + ($significance === null) && + (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) + ) { $significance = $number / abs($number); } @@ -1381,8 +1389,10 @@ class MathTrig $testCondition = '=' . $arg . $condition; $sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0; - if (is_numeric($sumValue) && - Calculation::getInstance()->_calculateFormulaValue($testCondition)) { + if ( + is_numeric($sumValue) && + Calculation::getInstance()->_calculateFormulaValue($testCondition) + ) { // Is it a value within our criteria and only numeric can be added to the result $returnValue += $sumValue; } @@ -1532,8 +1542,10 @@ class MathTrig $result = 0; for ($i = 0; $i < $count; ++$i) { - if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && - ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { + if ( + ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && + ((is_numeric($array2[$i])) && (!is_string($array2[$i]))) + ) { $result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]); } } @@ -1557,8 +1569,10 @@ class MathTrig $result = 0; for ($i = 0; $i < $count; ++$i) { - if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && - ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { + if ( + ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && + ((is_numeric($array2[$i])) && (!is_string($array2[$i]))) + ) { $result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]); } } @@ -1582,8 +1596,10 @@ class MathTrig $result = 0; for ($i = 0; $i < $count; ++$i) { - if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && - ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { + if ( + ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && + ((is_numeric($array2[$i])) && (!is_string($array2[$i]))) + ) { $result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]); } } diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index b44e6c6f..524438ea 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -530,9 +530,11 @@ class Statistical */ private static function testAcceptedBoolean($arg, $k) { - if ((is_bool($arg)) && + if ( + (is_bool($arg)) && ((!Functions::isCellValue($k) && (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_EXCEL)) || - (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE))) { + (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE)) + ) { $arg = (int) $arg; } @@ -547,9 +549,11 @@ class Statistical */ private static function isAcceptedCountable($arg, $k) { - if (((is_numeric($arg)) && (!is_string($arg))) || + if ( + ((is_numeric($arg)) && (!is_string($arg))) || ((is_numeric($arg)) && (!Functions::isCellValue($k)) && - (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC))) { + (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC)) + ) { return true; } @@ -664,8 +668,10 @@ class Statistical $aCount = 0; // Loop through arguments foreach (Functions::flattenArrayIndexed($args) as $k => $arg) { - if ((is_bool($arg)) && - (!Functions::isMatrixValue($k))) { + if ( + (is_bool($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) { if (is_bool($arg)) { @@ -1414,9 +1420,11 @@ class Statistical $aCount = -1; foreach ($aArgs as $k => $arg) { // Is it a numeric value? - if ((is_bool($arg)) && + if ( + (is_bool($arg)) && ((!Functions::isCellValue($k)) || - (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { + (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE)) + ) { $arg = (int) $arg; } if ((is_numeric($arg)) && (!is_string($arg))) { @@ -1968,8 +1976,10 @@ class Statistical $count = $summer = 0; // Loop through arguments foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - (!Functions::isMatrixValue($k))) { + if ( + (is_bool($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { @@ -3084,8 +3094,10 @@ class Statistical $count = $summer = 0; // Loop through arguments foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - (!Functions::isMatrixValue($k))) { + if ( + (is_bool($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) && (!is_string($arg))) { @@ -3224,8 +3236,10 @@ class Statistical if ($aMean !== null) { $aCount = -1; foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { + if ( + (is_bool($arg)) && + ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE)) + ) { $arg = (int) $arg; } // Is it a numeric value? @@ -3270,8 +3284,10 @@ class Statistical if ($aMean !== null) { $aCount = -1; foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - (!Functions::isMatrixValue($k))) { + if ( + (is_bool($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { @@ -3320,8 +3336,10 @@ class Statistical if ($aMean !== null) { $aCount = 0; foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { + if ( + (is_bool($arg)) && + ((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE)) + ) { $arg = (int) $arg; } // Is it a numeric value? @@ -3365,8 +3383,10 @@ class Statistical if ($aMean !== null) { $aCount = 0; foreach ($aArgs as $k => $arg) { - if ((is_bool($arg)) && - (!Functions::isMatrixValue($k))) { + if ( + (is_bool($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { @@ -3686,11 +3706,15 @@ class Statistical $aArgs = Functions::flattenArrayIndexed($args); $aCount = 0; foreach ($aArgs as $k => $arg) { - if ((is_string($arg)) && - (Functions::isValue($k))) { + if ( + (is_string($arg)) && + (Functions::isValue($k)) + ) { return Functions::VALUE(); - } elseif ((is_string($arg)) && - (!Functions::isMatrixValue($k))) { + } elseif ( + (is_string($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { @@ -3780,11 +3804,15 @@ class Statistical $aArgs = Functions::flattenArrayIndexed($args); $aCount = 0; foreach ($aArgs as $k => $arg) { - if ((is_string($arg)) && - (Functions::isValue($k))) { + if ( + (is_string($arg)) && + (Functions::isValue($k)) + ) { return Functions::VALUE(); - } elseif ((is_string($arg)) && - (!Functions::isMatrixValue($k))) { + } elseif ( + (is_string($arg)) && + (!Functions::isMatrixValue($k)) + ) { } else { // Is it a numeric value? if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index cbaae2db..0876a9ed 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -457,11 +457,14 @@ class Properties */ public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) { - if (($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER, - self::PROPERTY_TYPE_FLOAT, - self::PROPERTY_TYPE_STRING, - self::PROPERTY_TYPE_DATE, - self::PROPERTY_TYPE_BOOLEAN, ]))) { + if ( + ($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER, + self::PROPERTY_TYPE_FLOAT, + self::PROPERTY_TYPE_STRING, + self::PROPERTY_TYPE_DATE, + self::PROPERTY_TYPE_BOOLEAN, + ])) + ) { if ($propertyValue === null) { $propertyType = self::PROPERTY_TYPE_STRING; } elseif (is_float($propertyValue)) { diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index a29a2b9d..77c9bdf7 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -534,8 +534,10 @@ class Gnumeric extends BaseReader foreach ($sheet->Styles->StyleRegion as $styleRegion) { $styleAttributes = $styleRegion->attributes(); - if (($styleAttributes['startRow'] <= $maxRow) && - ($styleAttributes['startCol'] <= $maxCol)) { + if ( + ($styleAttributes['startRow'] <= $maxRow) && + ($styleAttributes['startCol'] <= $maxCol) + ) { $startColumn = Coordinate::stringFromColumnIndex((int) $styleAttributes['startCol'] + 1); $startRow = $styleAttributes['startRow'] + 1; diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index b2a6a759..74d65db8 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -317,9 +317,11 @@ class Ods extends BaseReader $worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name'); // Check loadSheetsOnly - if (isset($this->loadSheetsOnly) + if ( + isset($this->loadSheetsOnly) && $worksheetName - && !in_array($worksheetName, $this->loadSheetsOnly)) { + && !in_array($worksheetName, $this->loadSheetsOnly) + ) { continue; } @@ -624,7 +626,8 @@ class Ods extends BaseReader } // Merged cells - if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned') + if ( + $cellData->hasAttributeNS($tableNs, 'number-columns-spanned') || $cellData->hasAttributeNS($tableNs, 'number-rows-spanned') ) { if (($type !== DataType::TYPE_NULL) || (!$this->readDataOnly)) { diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index cdac07d0..81cc5b2e 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1275,8 +1275,10 @@ class Xls extends BaseReader // Extract range if (strpos($definedName['formula'], '!') !== false) { $explodes = Worksheet::extractSheetTitle($definedName['formula'], true); - if (($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) || - ($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'")))) { + if ( + ($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) || + ($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'"))) + ) { $extractedRange = $explodes[1]; $extractedRange = str_replace('$', '', $extractedRange); @@ -3999,21 +4001,27 @@ class Xls extends BaseReader // read STRING record $value = $this->readString(); - } elseif ((ord($recordData[6]) == 1) + } elseif ( + (ord($recordData[6]) == 1) && (ord($recordData[12]) == 255) - && (ord($recordData[13]) == 255)) { + && (ord($recordData[13]) == 255) + ) { // Boolean formula. Result is in +2; 0=false, 1=true $dataType = DataType::TYPE_BOOL; $value = (bool) ord($recordData[8]); - } elseif ((ord($recordData[6]) == 2) + } elseif ( + (ord($recordData[6]) == 2) && (ord($recordData[12]) == 255) - && (ord($recordData[13]) == 255)) { + && (ord($recordData[13]) == 255) + ) { // Error formula. Error code is in +2 $dataType = DataType::TYPE_ERROR; $value = Xls\ErrorCode::lookup(ord($recordData[8])); - } elseif ((ord($recordData[6]) == 3) + } elseif ( + (ord($recordData[6]) == 3) && (ord($recordData[12]) == 255) - && (ord($recordData[13]) == 255)) { + && (ord($recordData[13]) == 255) + ) { // Formula result is a null string $dataType = DataType::TYPE_NULL; $value = ''; @@ -4599,8 +4607,10 @@ class Xls extends BaseReader if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) { $cellRangeAddressList = $this->readBIFF8CellRangeAddressList($recordData); foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { - if ((strpos($cellRangeAddress, ':') !== false) && - ($this->includeCellRangeFiltered($cellRangeAddress))) { + if ( + (strpos($cellRangeAddress, ':') !== false) && + ($this->includeCellRangeFiltered($cellRangeAddress)) + ) { $this->phpSheet->mergeCells($cellRangeAddress); } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index fb7f0645..381f107e 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -502,8 +502,10 @@ class Xlsx extends BaseReader // We shouldn't override any of the built-in MS Excel values (values below id 164) // But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used // So we make allowance for them rather than lose formatting masks - if ((int) $xf['numFmtId'] < 164 && - NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== '') { + if ( + (int) $xf['numFmtId'] < 164 && + NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== '' + ) { $numFmt = NumberFormat::builtInFormatCode((int) $xf['numFmtId']); } } @@ -1720,12 +1722,16 @@ class Xlsx extends BaseReader if (isset($run->rPr->color)) { $objText->getFont()->setColor(new Color(self::readColor($run->rPr->color))); } - if ((isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) || - (isset($run->rPr->b) && !isset($run->rPr->b['val']))) { + if ( + (isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) || + (isset($run->rPr->b) && !isset($run->rPr->b['val'])) + ) { $objText->getFont()->setBold(true); } - if ((isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) || - (isset($run->rPr->i) && !isset($run->rPr->i['val']))) { + if ( + (isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) || + (isset($run->rPr->i) && !isset($run->rPr->i['val'])) + ) { $objText->getFont()->setItalic(true); } if (isset($run->rPr->vertAlign, $run->rPr->vertAlign['val'])) { @@ -1742,8 +1748,10 @@ class Xlsx extends BaseReader } elseif (isset($run->rPr->u, $run->rPr->u['val'])) { $objText->getFont()->setUnderline((string) $run->rPr->u['val']); } - if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) || - (isset($run->rPr->strike) && !isset($run->rPr->strike['val']))) { + if ( + (isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) || + (isset($run->rPr->strike) && !isset($run->rPr->strike['val'])) + ) { $objText->getFont()->setStrikethrough(true); } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php index 339c0584..4134b2f1 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php @@ -94,8 +94,10 @@ class ColumnAndRowAttributes extends BaseParserClass // set columns/rows attributes $columnsAttributesAreSet = []; foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { - if ($readFilter === null || - !$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)) { + if ( + $readFilter === null || + !$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes) + ) { if (!isset($columnsAttributesAreSet[$columnCoordinate])) { $this->setColumnAttributes($columnCoordinate, $columnAttributes); $columnsAttributesAreSet[$columnCoordinate] = true; @@ -105,8 +107,10 @@ class ColumnAndRowAttributes extends BaseParserClass $rowsAttributesAreSet = []; foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { - if ($readFilter === null || - !$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)) { + if ( + $readFilter === null || + !$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes) + ) { if (!isset($rowsAttributesAreSet[$rowCoordinate])) { $this->setRowAttributes($rowCoordinate, $rowAttributes); $rowsAttributesAreSet[$rowCoordinate] = true; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php index 668bfd18..4aa48e17 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -34,13 +34,15 @@ class ConditionalStyles $conditionals = []; foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($conditional->cfRule as $cfRule) { - if (((string) $cfRule['type'] == Conditional::CONDITION_NONE + if ( + ((string) $cfRule['type'] == Conditional::CONDITION_NONE || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSBLANKS || (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSBLANKS || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) - && isset($this->dxfs[(int) ($cfRule['dxfId'])])) { + && isset($this->dxfs[(int) ($cfRule['dxfId'])]) + ) { $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; } } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php index b556703c..536c8948 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -65,8 +65,10 @@ class PageSetup extends BaseParserClass if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); } - if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && - self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { + if ( + isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && + self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber']) + ) { $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); } if (isset($xmlSheet->pageSetup['pageOrder'])) { @@ -87,26 +89,34 @@ class PageSetup extends BaseParserClass if ($xmlSheet->headerFooter) { $docHeaderFooter = $worksheet->getHeaderFooter(); - if (isset($xmlSheet->headerFooter['differentOddEven']) && - self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { + if ( + isset($xmlSheet->headerFooter['differentOddEven']) && + self::boolean((string) $xmlSheet->headerFooter['differentOddEven']) + ) { $docHeaderFooter->setDifferentOddEven(true); } else { $docHeaderFooter->setDifferentOddEven(false); } - if (isset($xmlSheet->headerFooter['differentFirst']) && - self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { + if ( + isset($xmlSheet->headerFooter['differentFirst']) && + self::boolean((string) $xmlSheet->headerFooter['differentFirst']) + ) { $docHeaderFooter->setDifferentFirst(true); } else { $docHeaderFooter->setDifferentFirst(false); } - if (isset($xmlSheet->headerFooter['scaleWithDoc']) && - !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { + if ( + isset($xmlSheet->headerFooter['scaleWithDoc']) && + !self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc']) + ) { $docHeaderFooter->setScaleWithDocument(false); } else { $docHeaderFooter->setScaleWithDocument(true); } - if (isset($xmlSheet->headerFooter['alignWithMargins']) && - !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { + if ( + isset($xmlSheet->headerFooter['alignWithMargins']) && + !self::boolean((string) $xmlSheet->headerFooter['alignWithMargins']) + ) { $docHeaderFooter->setAlignWithMargins(false); } else { $docHeaderFooter->setAlignWithMargins(true); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php index b3bee899..12358818 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php @@ -59,15 +59,19 @@ class SheetViewOptions extends BaseParserClass private function outlines(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->outlinePr)) { - if (isset($sheetPr->outlinePr['summaryRight']) && - !self::boolean((string) $sheetPr->outlinePr['summaryRight'])) { + if ( + isset($sheetPr->outlinePr['summaryRight']) && + !self::boolean((string) $sheetPr->outlinePr['summaryRight']) + ) { $this->worksheet->setShowSummaryRight(false); } else { $this->worksheet->setShowSummaryRight(true); } - if (isset($sheetPr->outlinePr['summaryBelow']) && - !self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) { + if ( + isset($sheetPr->outlinePr['summaryBelow']) && + !self::boolean((string) $sheetPr->outlinePr['summaryBelow']) + ) { $this->worksheet->setShowSummaryBelow(false); } else { $this->worksheet->setShowSummaryBelow(true); @@ -78,8 +82,10 @@ class SheetViewOptions extends BaseParserClass private function pageSetup(SimpleXMLElement $sheetPr): void { if (isset($sheetPr->pageSetUpPr)) { - if (isset($sheetPr->pageSetUpPr['fitToPage']) && - !self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) { + if ( + isset($sheetPr->pageSetUpPr['fitToPage']) && + !self::boolean((string) $sheetPr->pageSetUpPr['fitToPage']) + ) { $this->worksheet->getPageSetup()->setFitToPage(false); } else { $this->worksheet->getPageSetup()->setFitToPage(true); @@ -89,9 +95,11 @@ class SheetViewOptions extends BaseParserClass private function sheetFormat(SimpleXMLElement $sheetFormatPr): void { - if (isset($sheetFormatPr['customHeight']) && + if ( + isset($sheetFormatPr['customHeight']) && self::boolean((string) $sheetFormatPr['customHeight']) && - isset($sheetFormatPr['defaultRowHeight'])) { + isset($sheetFormatPr['defaultRowHeight']) + ) { $this->worksheet->getDefaultRowDimension() ->setRowHeight((float) $sheetFormatPr['defaultRowHeight']); } @@ -101,8 +109,10 @@ class SheetViewOptions extends BaseParserClass ->setWidth((float) $sheetFormatPr['defaultColWidth']); } - if (isset($sheetFormatPr['zeroHeight']) && - ((string) $sheetFormatPr['zeroHeight'] === '1')) { + if ( + isset($sheetFormatPr['zeroHeight']) && + ((string) $sheetFormatPr['zeroHeight'] === '1') + ) { $this->worksheet->getDefaultRowDimension()->setZeroHeight(true); } } diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index fc2f5108..5bf18465 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -400,8 +400,10 @@ class Xml extends BaseReader foreach ($xml_ss->Worksheet as $worksheet) { $worksheet_ss = $worksheet->attributes($namespaces['ss']); - if ((isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && - (!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))) { + if ( + (isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && + (!in_array($worksheet_ss['Name'], $this->loadSheetsOnly)) + ) { continue; } diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 0b0f6dd3..5809e3d4 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -129,13 +129,17 @@ class ReferenceHelper [$cellColumn, $cellRow] = Coordinate::coordinateFromString($cellAddress); $cellColumnIndex = Coordinate::columnIndexFromString($cellColumn); // Is cell within the range of rows/columns if we're deleting - if ($pNumRows < 0 && + if ( + $pNumRows < 0 && ($cellRow >= ($beforeRow + $pNumRows)) && - ($cellRow < $beforeRow)) { + ($cellRow < $beforeRow) + ) { return true; - } elseif ($pNumCols < 0 && + } elseif ( + $pNumCols < 0 && ($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) && - ($cellColumnIndex < $beforeColumnIndex)) { + ($cellColumnIndex < $beforeColumnIndex) + ) { return true; } diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index cb37515d..180a7159 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -71,8 +71,10 @@ class Date */ public static function setExcelCalendar($baseDate) { - if (($baseDate == self::CALENDAR_WINDOWS_1900) || - ($baseDate == self::CALENDAR_MAC_1904)) { + if ( + ($baseDate == self::CALENDAR_WINDOWS_1900) || + ($baseDate == self::CALENDAR_MAC_1904) + ) { self::$excelCalendar = $baseDate; return true; @@ -400,8 +402,10 @@ class Date $segMatcher = false; foreach (explode('"', $pFormatCode) as $subVal) { // Only test in alternate array entries (the non-quoted blocks) - if (($segMatcher = !$segMatcher) && - (preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal))) { + if ( + ($segMatcher = !$segMatcher) && + (preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal)) + ) { return true; } } diff --git a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php index f6fbccb8..4c67c3a9 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php +++ b/src/PhpSpreadsheet/Shared/JAMA/EigenvalueDecomposition.php @@ -553,8 +553,10 @@ class EigenvalueDecomposition if ($m == $l) { break; } - if (abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) < - $eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1])))) { + if ( + abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) < + $eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1]))) + ) { break; } --$m; diff --git a/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php b/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php index 68c38649..49877b23 100644 --- a/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php +++ b/src/PhpSpreadsheet/Shared/JAMA/utils/Maths.php @@ -1,4 +1,5 @@ bigBlockSize = 2 ** self::_readInt2($fh); - $this->smallBlockSize = 2 ** self::_readInt2($fh); + $this->bigBlockSize = 2 ** self::readInt2($fh); + $this->smallBlockSize = 2 ** self::readInt2($fh); // Skip UID, revision number and version number fseek($fh, 44); // Number of blocks in Big Block Allocation Table - $bbatBlockCount = self::_readInt4($fh); + $bbatBlockCount = self::readInt4($fh); // Root chain 1st block - $directoryFirstBlockId = self::_readInt4($fh); + $directoryFirstBlockId = self::readInt4($fh); // Skip unused bytes fseek($fh, 56); // Streams shorter than this are stored using small blocks - $this->bigBlockThreshold = self::_readInt4($fh); + $this->bigBlockThreshold = self::readInt4($fh); // Block id of first sector in Short Block Allocation Table - $sbatFirstBlockId = self::_readInt4($fh); + $sbatFirstBlockId = self::readInt4($fh); // Number of blocks in Short Block Allocation Table - $sbbatBlockCount = self::_readInt4($fh); + $sbbatBlockCount = self::readInt4($fh); // Block id of first sector in Master Block Allocation Table - $mbatFirstBlockId = self::_readInt4($fh); + $mbatFirstBlockId = self::readInt4($fh); // Number of blocks in Master Block Allocation Table - $mbbatBlockCount = self::_readInt4($fh); + $mbbatBlockCount = self::readInt4($fh); $this->bbat = []; // Remaining 4 * 109 bytes of current block is beginning of Master // Block Allocation Table $mbatBlocks = []; for ($i = 0; $i < 109; ++$i) { - $mbatBlocks[] = self::_readInt4($fh); + $mbatBlocks[] = self::readInt4($fh); } // Read rest of Master Block Allocation Table (if any is left) - $pos = $this->_getBlockOffset($mbatFirstBlockId); + $pos = $this->getBlockOffset($mbatFirstBlockId); for ($i = 0; $i < $mbbatBlockCount; ++$i) { fseek($fh, $pos); for ($j = 0; $j < $this->bigBlockSize / 4 - 1; ++$j) { - $mbatBlocks[] = self::_readInt4($fh); + $mbatBlocks[] = self::readInt4($fh); } // Last block id in each block points to next block - $pos = $this->_getBlockOffset(self::_readInt4($fh)); + $pos = $this->getBlockOffset(self::readInt4($fh)); } // Read Big Block Allocation Table according to chain specified by $mbatBlocks for ($i = 0; $i < $bbatBlockCount; ++$i) { - $pos = $this->_getBlockOffset($mbatBlocks[$i]); + $pos = $this->getBlockOffset($mbatBlocks[$i]); fseek($fh, $pos); for ($j = 0; $j < $this->bigBlockSize / 4; ++$j) { - $this->bbat[] = self::_readInt4($fh); + $this->bbat[] = self::readInt4($fh); } } @@ -188,11 +188,11 @@ class OLE $shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4; $sbatFh = $this->getStream($sbatFirstBlockId); for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) { - $this->sbat[$blockId] = self::_readInt4($sbatFh); + $this->sbat[$blockId] = self::readInt4($sbatFh); } fclose($sbatFh); - $this->_readPpsWks($directoryFirstBlockId); + $this->readPpsWks($directoryFirstBlockId); return true; } @@ -202,7 +202,7 @@ class OLE * * @return int */ - public function _getBlockOffset($blockId) + public function getBlockOffset($blockId) { return 512 + $blockId * $this->bigBlockSize; } @@ -247,7 +247,7 @@ class OLE * * @return int */ - private static function _readInt1($fh) + private static function readInt1($fh) { [, $tmp] = unpack('c', fread($fh, 1)); @@ -261,7 +261,7 @@ class OLE * * @return int */ - private static function _readInt2($fh) + private static function readInt2($fh) { [, $tmp] = unpack('v', fread($fh, 2)); @@ -275,7 +275,7 @@ class OLE * * @return int */ - private static function _readInt4($fh) + private static function readInt4($fh) { [, $tmp] = unpack('V', fread($fh, 4)); @@ -290,17 +290,17 @@ class OLE * * @return bool true on success, PEAR_Error on failure */ - public function _readPpsWks($blockId) + public function readPpsWks($blockId) { $fh = $this->getStream($blockId); for ($pos = 0; true; $pos += 128) { fseek($fh, $pos, SEEK_SET); $nameUtf16 = fread($fh, 64); - $nameLength = self::_readInt2($fh); + $nameLength = self::readInt2($fh); $nameUtf16 = substr($nameUtf16, 0, $nameLength - 2); // Simple conversion from UTF-16LE to ISO-8859-1 $name = str_replace("\x00", '', $nameUtf16); - $type = self::_readInt1($fh); + $type = self::readInt1($fh); switch ($type) { case self::OLE_PPS_TYPE_ROOT: $pps = new OLE\PPS\Root(null, null, []); @@ -321,19 +321,19 @@ class OLE fseek($fh, 1, SEEK_CUR); $pps->Type = $type; $pps->Name = $name; - $pps->PrevPps = self::_readInt4($fh); - $pps->NextPps = self::_readInt4($fh); - $pps->DirPps = self::_readInt4($fh); + $pps->PrevPps = self::readInt4($fh); + $pps->NextPps = self::readInt4($fh); + $pps->DirPps = self::readInt4($fh); fseek($fh, 20, SEEK_CUR); $pps->Time1st = self::OLE2LocalDate(fread($fh, 8)); $pps->Time2nd = self::OLE2LocalDate(fread($fh, 8)); - $pps->startBlock = self::_readInt4($fh); - $pps->Size = self::_readInt4($fh); + $pps->startBlock = self::readInt4($fh); + $pps->Size = self::readInt4($fh); $pps->No = count($this->_list); $this->_list[] = $pps; // check if the PPS tree (starting from root) is complete - if (isset($this->root) && $this->_ppsTreeComplete($this->root->No)) { + if (isset($this->root) && $this->ppsTreeComplete($this->root->No)) { break; } } @@ -367,16 +367,16 @@ class OLE * * @return bool Whether the PPS tree for the given PPS is complete */ - public function _ppsTreeComplete($index) + private function ppsTreeComplete($index) { return isset($this->_list[$index]) && ($pps = $this->_list[$index]) && ($pps->PrevPps == -1 || - $this->_ppsTreeComplete($pps->PrevPps)) && + $this->ppsTreeComplete($pps->PrevPps)) && ($pps->NextPps == -1 || - $this->_ppsTreeComplete($pps->NextPps)) && + $this->ppsTreeComplete($pps->NextPps)) && ($pps->DirPps == -1 || - $this->_ppsTreeComplete($pps->DirPps)); + $this->ppsTreeComplete($pps->DirPps)); } /** diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index ecaa97ed..cee5cd99 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -71,7 +71,7 @@ class ChainedBlockStream $this->data = ''; if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->startBlock) { // Block id refers to small blocks - $rootPos = $this->ole->_getBlockOffset($this->ole->root->startBlock); + $rootPos = $this->ole->getBlockOffset($this->ole->root->startBlock); while ($blockId != -2) { $pos = $rootPos + $blockId * $this->ole->bigBlockSize; $blockId = $this->ole->sbat[$blockId]; @@ -81,7 +81,7 @@ class ChainedBlockStream } else { // Block id refers to big blocks while ($blockId != -2) { - $pos = $this->ole->_getBlockOffset($blockId); + $pos = $this->ole->getBlockOffset($blockId); fseek($this->ole->_file_handle, $pos); $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize); $blockId = $this->ole->bbat[$blockId]; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 7aa42a14..cf764d0b 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -172,7 +172,7 @@ class PPS * * @return string The binary string */ - public function _getPpsWk() + public function getPpsWk() { $ret = str_pad($this->Name, 64, "\x00"); @@ -207,7 +207,7 @@ class PPS * * @return int The index for this PPS */ - public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0) + public static function savePpsSetPnt(&$raList, $to_save, $depth = 0) { if (!is_array($to_save) || (empty($to_save))) { return 0xFFFFFFFF; @@ -218,7 +218,7 @@ class PPS $raList[$cnt]->No = $cnt; $raList[$cnt]->PrevPps = 0xFFFFFFFF; $raList[$cnt]->NextPps = 0xFFFFFFFF; - $raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); + $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); } else { $iPos = floor(count($to_save) / 2); $aPrev = array_slice($to_save, 0, $iPos); @@ -227,9 +227,9 @@ class PPS // If the first entry, it's the root... Don't clone it! $raList[$cnt] = ($depth == 0) ? $to_save[$iPos] : clone $to_save[$iPos]; $raList[$cnt]->No = $cnt; - $raList[$cnt]->PrevPps = self::_savePpsSetPnt($raList, $aPrev, $depth++); - $raList[$cnt]->NextPps = self::_savePpsSetPnt($raList, $aNext, $depth++); - $raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); + $raList[$cnt]->PrevPps = self::savePpsSetPnt($raList, $aPrev, $depth++); + $raList[$cnt]->NextPps = self::savePpsSetPnt($raList, $aNext, $depth++); + $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); } return $cnt; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 11655c65..5466d2bc 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -80,21 +80,21 @@ class Root extends PPS // Make an array of PPS's (for Save) $aList = []; - PPS::_savePpsSetPnt($aList, [$this]); + PPS::savePpsSetPnt($aList, [$this]); // calculate values for header - [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo); + [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->calcSize($aList); //, $rhInfo); // Save Header - $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); + $this->saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); // Make Small Data string (write SBD) - $this->_data = $this->_makeSmallData($aList); + $this->_data = $this->makeSmallData($aList); // Write BB - $this->_saveBigData($iSBDcnt, $aList); + $this->saveBigData($iSBDcnt, $aList); // Write PPS - $this->_savePps($aList); + $this->savePps($aList); // Write Big Block Depot and BDList and Adding Header informations - $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); + $this->saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); return true; } @@ -106,7 +106,7 @@ class Root extends PPS * * @return float[] The array of numbers */ - public function _calcSize(&$raList) + private function calcSize(&$raList) { // Calculate Basic Setting [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0]; @@ -160,7 +160,7 @@ class Root extends PPS * @param int $iBBcnt * @param int $iPPScnt */ - public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void + private function saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void { $FILE = $this->fileHandle; @@ -239,7 +239,7 @@ class Root extends PPS * @param int $iStBlk * @param array &$raList Reference to array of PPS's */ - public function _saveBigData($iStBlk, &$raList): void + private function saveBigData($iStBlk, &$raList): void { $FILE = $this->fileHandle; @@ -271,7 +271,7 @@ class Root extends PPS * * @return string */ - public function _makeSmallData(&$raList) + private function makeSmallData(&$raList) { $sRes = ''; $FILE = $this->fileHandle; @@ -321,12 +321,12 @@ class Root extends PPS * * @param array $raList Reference to an array with all PPS's */ - public function _savePps(&$raList): void + private function savePps(&$raList): void { // Save each PPS WK $iC = count($raList); for ($i = 0; $i < $iC; ++$i) { - fwrite($this->fileHandle, $raList[$i]->_getPpsWk()); + fwrite($this->fileHandle, $raList[$i]->getPpsWk()); } // Adjust for Block $iCnt = count($raList); @@ -343,7 +343,7 @@ class Root extends PPS * @param int $iBsize * @param int $iPpsCnt */ - public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt): void + private function saveBbd($iSbdSize, $iBsize, $iPpsCnt): void { $FILE = $this->fileHandle; // Calculate Basic Setting diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index b6d5422c..7112b090 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -180,7 +180,7 @@ class OLERead // read the directory stream $block = $this->rootStartBlock; - $this->entry = $this->_readData($block); + $this->entry = $this->readData($block); $this->readPropertySets(); } @@ -201,7 +201,7 @@ class OLERead $streamData = ''; if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) { - $rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']); + $rootdata = $this->readData($this->props[$this->rootentry]['startBlock']); $block = $this->props[$stream]['startBlock']; @@ -241,7 +241,7 @@ class OLERead * * @return string Data for standard stream */ - private function _readData($bl) + private function readData($bl) { $block = $bl; $data = ''; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 322d5f7c..46e97852 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -396,8 +396,10 @@ class Spreadsheet break; case 'types': - if (is_array($this->ribbonBinObjects) && - isset($this->ribbonBinObjects['data']) && is_array($this->ribbonBinObjects['data'])) { + if ( + is_array($this->ribbonBinObjects) && + isset($this->ribbonBinObjects['data']) && is_array($this->ribbonBinObjects['data']) + ) { $tmpTypes = array_keys($this->ribbonBinObjects['data']); $ReturnData = array_unique(array_map([$this, 'getExtensionOnly'], $tmpTypes)); } else { @@ -657,8 +659,10 @@ class Spreadsheet array_splice($this->workSheetCollection, $pIndex, 1); // Adjust active sheet index if necessary - if (($this->activeSheetIndex >= $pIndex) && - ($pIndex > count($this->workSheetCollection) - 1)) { + if ( + ($this->activeSheetIndex >= $pIndex) && + ($pIndex > count($this->workSheetCollection) - 1) + ) { --$this->activeSheetIndex; } } diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index e54fa2a1..4d97dd2c 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -385,9 +385,11 @@ class Alignment extends Supervisor public function setIndent($pValue) { if ($pValue > 0) { - if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && + if ( + $this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && - $this->getHorizontal() != self::HORIZONTAL_RIGHT) { + $this->getHorizontal() != self::HORIZONTAL_RIGHT + ) { $pValue = 0; // indent not supported } } diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index c085b596..c2ded195 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -643,28 +643,40 @@ class AutoFilter ]; foreach ($ruleDataSet as $ruleValue) { $date = $time = ''; - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '') + ) { $date .= sprintf('%04d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); } - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '') + ) { $date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); } - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '') + ) { $date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); } - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '') + ) { $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); } - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '') + ) { $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); } - if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && - ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) { + if ( + (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && + ($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '') + ) { $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); } $dateTime = $date . $time; @@ -712,8 +724,10 @@ class AutoFilter foreach ($rules as $rule) { // We should only ever have one Dynamic Filter Rule anyway $dynamicRuleType = $rule->getGrouping(); - if (($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || - ($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE)) { + if ( + ($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || + ($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE) + ) { // Number (Average) based // Calculate the average $averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')'; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index c0a15a7c..1aacb0cb 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -337,8 +337,10 @@ class Rule if (empty($pOperator)) { $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL; } - if ((!in_array($pOperator, self::$operators)) && - (!in_array($pOperator, self::$topTenValue))) { + if ( + (!in_array($pOperator, self::$operators)) && + (!in_array($pOperator, self::$topTenValue)) + ) { throw new PhpSpreadsheetException('Invalid operator for column AutoFilter Rule.'); } $this->operator = $pOperator; @@ -365,10 +367,12 @@ class Rule */ public function setGrouping($pGrouping) { - if (($pGrouping !== null) && + if ( + ($pGrouping !== null) && (!in_array($pGrouping, self::$dateTimeGroups)) && (!in_array($pGrouping, self::$dynamicTypes)) && - (!in_array($pGrouping, self::$topTenType))) { + (!in_array($pGrouping, self::$topTenType)) + ) { throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.'); } $this->grouping = $pGrouping; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index ec16fbe5..12420d77 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -137,9 +137,11 @@ class ColumnCellIterator extends CellIterator { do { ++$this->currentRow; - } while (($this->onlyExistingCells) && + } while ( + ($this->onlyExistingCells) && (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) && - ($this->currentRow <= $this->endRow)); + ($this->currentRow <= $this->endRow) + ); } /** @@ -149,9 +151,11 @@ class ColumnCellIterator extends CellIterator { do { --$this->currentRow; - } while (($this->onlyExistingCells) && + } while ( + ($this->onlyExistingCells) && (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) && - ($this->currentRow >= $this->startRow)); + ($this->currentRow >= $this->startRow) + ); } /** @@ -170,15 +174,19 @@ class ColumnCellIterator extends CellIterator protected function adjustForExistingOnlyRange(): void { if ($this->onlyExistingCells) { - while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) && - ($this->startRow <= $this->endRow)) { + while ( + (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) && + ($this->startRow <= $this->endRow) + ) { ++$this->startRow; } if ($this->startRow > $this->endRow) { throw new PhpSpreadsheetException('No cells exist within the specified range'); } - while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) && - ($this->endRow >= $this->startRow)) { + while ( + (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) && + ($this->endRow >= $this->startRow) + ) { --$this->endRow; } if ($this->endRow < $this->startRow) { diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index e2b0dd87..3acab637 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -433,9 +433,11 @@ class Worksheet implements IComparable throw new Exception('Sheet code name cannot be empty.'); } // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'" - if ((str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) || + if ( + (str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) || (Shared\StringHelper::substring($pValue, -1, 1) == '\'') || - (Shared\StringHelper::substring($pValue, 0, 1) == '\'')) { + (Shared\StringHelper::substring($pValue, 0, 1) == '\'') + ) { throw new Exception('Invalid character found in sheet code name'); } @@ -1188,8 +1190,10 @@ class Worksheet implements IComparable } // Named range? - if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && - (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) { + if ( + (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && + (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches)) + ) { $namedRange = NamedRange::resolveRange($pCoordinate, $this); if ($namedRange !== null) { $pCoordinate = $namedRange->getRange(); @@ -1286,8 +1290,10 @@ class Worksheet implements IComparable } // Named range? - if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && - (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) { + if ( + (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && + (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches)) + ) { $namedRange = NamedRange::resolveRange($pCoordinate, $this); if ($namedRange !== null) { $pCoordinate = $namedRange->getRange(); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index ec8fec7d..5c21b3a9 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1368,7 +1368,8 @@ class Html extends BaseWriter // General horizontal alignment: Actual horizontal alignment depends on dataType $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex()); - if ($sharedStyle->getAlignment()->getHorizontal() == Alignment::HORIZONTAL_GENERAL + if ( + $sharedStyle->getAlignment()->getHorizontal() == Alignment::HORIZONTAL_GENERAL && isset($this->cssStyles['.' . $cell->getDataType()]['text-align']) ) { $cssClass['text-align'] = $this->cssStyles['.' . $cell->getDataType()]['text-align']; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 621853c0..e3b01260 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -1172,9 +1172,11 @@ class Parser return $this->createTree('ptgUplus', $result2, ''); } $result = $this->term(); - while (($this->currentToken == '+') || + while ( + ($this->currentToken == '+') || ($this->currentToken == '-') || - ($this->currentToken == '^')) { + ($this->currentToken == '^') + ) { if ($this->currentToken == '+') { $this->advance(); $result2 = $this->term(); @@ -1215,8 +1217,10 @@ class Parser private function term() { $result = $this->fact(); - while (($this->currentToken == '*') || - ($this->currentToken == '/')) { + while ( + ($this->currentToken == '*') || + ($this->currentToken == '/') + ) { if ($this->currentToken == '*') { $this->advance(); $result2 = $this->fact(); @@ -1271,8 +1275,10 @@ class Parser $this->advance(); return $result; - } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) || - preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken)) { + } elseif ( + preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) || + preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) + ) { // if it's a range A1:B2 or $A$1:$B$2 // must be an error? $result = $this->createTree($this->currentToken, '', ''); @@ -1419,11 +1425,13 @@ class Parser $polish .= $converted_tree; } // if it's a function convert it here (so we can set it's arguments) - if (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) && + if ( + preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) && !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) && !preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) && !is_numeric($tree['value']) && - !isset($this->ptg[$tree['value']])) { + !isset($this->ptg[$tree['value']]) + ) { // left subtree for a function is always an array. if ($tree['left'] != '') { $left_tree = $this->toReversePolish($tree['left']); diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index eb6b479d..a1c485c2 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -544,8 +544,10 @@ class Worksheet extends BIFFwriter // Write ConditionalFormattingTable records foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) { foreach ($conditionalStyles as $conditional) { - if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION - || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { + if ( + $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == Conditional::CONDITION_CELLIS + ) { if (!isset($arrConditional[$conditional->getHashCode()])) { // This hash code has been handled $arrConditional[$conditional->getHashCode()] = true; @@ -3086,7 +3088,8 @@ class Worksheet extends BIFFwriter $bFormatFill = 0; } // Font - if ($conditional->getStyle()->getFont()->getName() != null + if ( + $conditional->getStyle()->getFont()->getName() != null || $conditional->getStyle()->getFont()->getSize() != null || $conditional->getStyle()->getFont()->getBold() != null || $conditional->getStyle()->getFont()->getItalic() != null @@ -3094,7 +3097,8 @@ class Worksheet extends BIFFwriter || $conditional->getStyle()->getFont()->getSubscript() != null || $conditional->getStyle()->getFont()->getUnderline() != null || $conditional->getStyle()->getFont()->getStrikethrough() != null - || $conditional->getStyle()->getFont()->getColor()->getARGB() != null) { + || $conditional->getStyle()->getFont()->getColor()->getARGB() != null + ) { $bFormatFont = 1; } else { $bFormatFont = 0; @@ -4447,8 +4451,10 @@ class Worksheet extends BIFFwriter $arrConditional = []; foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($conditionalStyles as $conditional) { - if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION - || $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { + if ( + $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION + || $conditional->getConditionType() == Conditional::CONDITION_CELLIS + ) { if (!in_array($conditional->getHashCode(), $arrConditional)) { $arrConditional[] = $conditional->getHashCode(); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index a4e5769e..79841404 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -317,8 +317,10 @@ class Rels extends WriterPart $i = 1; $iterator = $pWorksheet->getDrawingCollection()->getIterator(); while ($iterator->valid()) { - if ($iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing - || $iterator->current() instanceof MemoryDrawing) { + if ( + $iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing + || $iterator->current() instanceof MemoryDrawing + ) { // Write relationship for image drawing /** @var \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $drawing */ $drawing = $iterator->current(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 872d0343..b0f7d6d4 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -38,16 +38,20 @@ class StringTable extends WriterPart foreach ($pSheet->getCoordinates() as $coordinate) { $cell = $pSheet->getCell($coordinate); $cellValue = $cell->getValue(); - if (!is_object($cellValue) && + if ( + !is_object($cellValue) && ($cellValue !== null) && $cellValue !== '' && !isset($aFlippedStringTable[$cellValue]) && - ($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL)) { + ($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL) + ) { $aStringTable[] = $cellValue; $aFlippedStringTable[$cellValue] = true; - } elseif ($cellValue instanceof RichText && + } elseif ( + $cellValue instanceof RichText && ($cellValue !== null) && - !isset($aFlippedStringTable[$cellValue->getHashCode()])) { + !isset($aFlippedStringTable[$cellValue->getHashCode()]) + ) { $aStringTable[] = $cellValue; $aFlippedStringTable[$cellValue->getHashCode()] = true; } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index 74300a9c..0c43fbf4 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -152,8 +152,10 @@ class Style extends WriterPart private function writeFill(XMLWriter $objWriter, Fill $pFill): void { // Check if this is a pattern type or gradient type - if ($pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR || - $pFill->getFillType() === Fill::FILL_GRADIENT_PATH) { + if ( + $pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR || + $pFill->getFillType() === Fill::FILL_GRADIENT_PATH + ) { // Gradient fill $this->writeGradientFill($objWriter, $pFill); } elseif ($pFill->getFillType() !== null) { @@ -479,15 +481,21 @@ class Style extends WriterPart // protection if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) { - if ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT || - $pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT) { + if ( + $pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT || + $pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT + ) { $objWriter->startElement('protection'); - if (($pStyle->getProtection()->getLocked() !== null) && - ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)) { + if ( + ($pStyle->getProtection()->getLocked() !== null) && + ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT) + ) { $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } - if (($pStyle->getProtection()->getHidden() !== null) && - ($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)) { + if ( + ($pStyle->getProtection()->getHidden() !== null) && + ($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT) + ) { $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); } $objWriter->endElement(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 759d9611..b6a6fc39 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -314,8 +314,10 @@ class Worksheet extends WriterPart } // Set Zero Height row - if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' || - strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') { + if ( + (string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' || + strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true' + ) { $objWriter->writeAttribute('zeroHeight', '1'); } @@ -466,9 +468,11 @@ class Worksheet extends WriterPart private static function writeOtherCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void { - if ($conditional->getConditionType() == Conditional::CONDITION_CELLIS + if ( + $conditional->getConditionType() == Conditional::CONDITION_CELLIS || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT - || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { + || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION + ) { foreach ($conditional->getConditions() as $formula) { // Formula $objWriter->writeElement('formula', Xlfn::addXlfn($formula)); @@ -791,9 +795,11 @@ class Worksheet extends WriterPart } foreach ($rules as $rule) { - if (($column->getFilterType() === Column::AUTOFILTER_FILTERTYPE_FILTER) && + if ( + ($column->getFilterType() === Column::AUTOFILTER_FILTERTYPE_FILTER) && ($rule->getOperator() === Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && - ($rule->getValue() === '')) { + ($rule->getValue() === '') + ) { // Filter rule for Blanks $objWriter->writeAttribute('blank', 1); } elseif ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php index efca228c..9ab86baa 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php @@ -90,13 +90,13 @@ class ReadFilterTest extends AbstractFunctional } /** - * @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell() - * * @param string $column Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name * * @return bool + * + * @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell() */ public function readFilterReadCell($column, $row, $worksheetName = '') { @@ -112,8 +112,10 @@ class ReadFilterTest extends AbstractFunctional } $col = sprintf('%04s', $column); - if ($col > sprintf('%04s', $columnMax) || - $col < sprintf('%04s', $columnMin)) { + if ( + $col > sprintf('%04s', $columnMax) || + $col < sprintf('%04s', $columnMin) + ) { return false; } diff --git a/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php index 2f584029..14bdb39a 100644 --- a/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Html/HtmlTest.php @@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader\Html; use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Reader\Html; use PhpOffice\PhpSpreadsheet\Style\Alignment; +use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Font; use PHPUnit\Framework\TestCase;