Rectorification (#1010)
* A few loose to strict comparisons * More loose to strict comparisons * Revert accidental composer hacks that shouldn't have been committed
This commit is contained in:
parent
5fd954d2c2
commit
71f3631cfb
|
@ -84,4 +84,4 @@
|
|||
"PhpOffice\\PhpSpreadsheetTests\\": "tests/PhpSpreadsheetTests"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3208,4 +3208,4 @@
|
|||
"ext-zlib": "*"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
}
|
|
@ -1009,7 +1009,7 @@ class Parser
|
|||
|
||||
break;
|
||||
case '>':
|
||||
if ($this->lookAhead == '=') { // it's a GE token
|
||||
if ($this->lookAhead === '=') { // it's a GE token
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1018,7 @@ class Parser
|
|||
break;
|
||||
case '<':
|
||||
// it's a LE or a NE token
|
||||
if (($this->lookAhead == '=') or ($this->lookAhead == '>')) {
|
||||
if (($this->lookAhead === '=') or ($this->lookAhead === '>')) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1027,12 +1027,12 @@ class Parser
|
|||
break;
|
||||
default:
|
||||
// if it's a reference A1 or $A$1 or $A1 or A$1
|
||||
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.') and ($this->lookAhead != '!')) {
|
||||
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?\d+$/', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.') and ($this->lookAhead !== '!')) {
|
||||
return $token;
|
||||
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
|
||||
} elseif (preg_match('/^' . self::REGEX_SHEET_TITLE_UNQUOTED . '(\\:' . self::REGEX_SHEET_TITLE_UNQUOTED . ')?\\!\$?[A-Ia-i]?[A-Za-z]\$?\\d+$/u', $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) {
|
||||
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
|
||||
return $token;
|
||||
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead != ':') and ($this->lookAhead != '.')) {
|
||||
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?[A-Ia-i]?[A-Za-z]\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead) and ($this->lookAhead !== ':') and ($this->lookAhead !== '.')) {
|
||||
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
|
||||
return $token;
|
||||
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $token) && !preg_match('/\d/', $this->lookAhead)) {
|
||||
|
@ -1044,19 +1044,19 @@ class Parser
|
|||
} elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . '(\\:' . self::REGEX_SHEET_TITLE_QUOTED . ")?'\\!\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+:\\$?([A-Ia-i]?[A-Za-z])?\\$?\\d+$/u", $token) and !preg_match('/\d/', $this->lookAhead)) {
|
||||
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
|
||||
return $token;
|
||||
} elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead != '!') and ($this->lookAhead != ':')) {
|
||||
} elseif (is_numeric($token) and (!is_numeric($token . $this->lookAhead) or ($this->lookAhead == '')) and ($this->lookAhead !== '!') and ($this->lookAhead !== ':')) {
|
||||
// If it's a number (check that it's not a sheet name or range)
|
||||
return $token;
|
||||
} elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead != '"' and (substr_count($token, '"') % 2 == 0)) {
|
||||
} elseif (preg_match('/"([^"]|""){0,255}"/', $token) and $this->lookAhead !== '"' and (substr_count($token, '"') % 2 == 0)) {
|
||||
// If it's a string (of maximum 255 characters)
|
||||
return $token;
|
||||
} elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token == '#N/A') {
|
||||
} elseif (preg_match('/^#[A-Z0\\/]{3,5}[!?]{1}$/', $token) or $token === '#N/A') {
|
||||
// If it's an error code
|
||||
return $token;
|
||||
} elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead == '(')) {
|
||||
} elseif (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/i", $token) and ($this->lookAhead === '(')) {
|
||||
// if it's a function call
|
||||
return $token;
|
||||
} elseif (substr($token, -1) == ')') {
|
||||
} elseif (substr($token, -1) === ')') {
|
||||
// It's an argument of some description (e.g. a named range),
|
||||
// precise nature yet to be determined
|
||||
return $token;
|
||||
|
@ -1078,8 +1078,7 @@ class Parser
|
|||
{
|
||||
$this->currentCharacter = 0;
|
||||
$this->formula = $formula;
|
||||
$this->lookAhead = isset($formula[1]) ? $formula[1]
|
||||
: '';
|
||||
$this->lookAhead = isset($formula[1]) ? $formula[1] : '';
|
||||
$this->advance();
|
||||
$this->parseTree = $this->condition();
|
||||
|
||||
|
@ -1248,10 +1247,10 @@ class Parser
|
|||
*/
|
||||
private function fact()
|
||||
{
|
||||
if ($this->currentToken == '(') {
|
||||
if ($this->currentToken === '(') {
|
||||
$this->advance(); // eat the "("
|
||||
$result = $this->parenthesizedExpression();
|
||||
if ($this->currentToken != ')') {
|
||||
if ($this->currentToken !== ')') {
|
||||
throw new WriterException("')' token expected.");
|
||||
}
|
||||
$this->advance(); // eat the ")"
|
||||
|
@ -1299,7 +1298,7 @@ class Parser
|
|||
return $result;
|
||||
} elseif (is_numeric($this->currentToken)) {
|
||||
// If it's a number or a percent
|
||||
if ($this->lookAhead == '%') {
|
||||
if ($this->lookAhead === '%') {
|
||||
$result = $this->createTree('ptgPercent', $this->currentToken, '');
|
||||
$this->advance(); // Skip the percentage operator once we've pre-built that tree
|
||||
} else {
|
||||
|
@ -1331,9 +1330,9 @@ class Parser
|
|||
$result = ''; // initialize result
|
||||
$this->advance();
|
||||
$this->advance(); // eat the "("
|
||||
while ($this->currentToken != ')') {
|
||||
while ($this->currentToken !== ')') {
|
||||
if ($num_args > 0) {
|
||||
if ($this->currentToken == ',' || $this->currentToken == ';') {
|
||||
if ($this->currentToken === ',' || $this->currentToken === ';') {
|
||||
$this->advance(); // eat the "," or ";"
|
||||
} else {
|
||||
throw new WriterException("Syntax error: comma expected in function $function, arg #{$num_args}");
|
||||
|
|
|
@ -267,9 +267,7 @@ class Workbook extends BIFFwriter
|
|||
|
||||
$this->xfWriters[] = $xfWriter;
|
||||
|
||||
$xfIndex = count($this->xfWriters) - 1;
|
||||
|
||||
return $xfIndex;
|
||||
return count($this->xfWriters) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,7 +317,7 @@ class Workbook extends BIFFwriter
|
|||
if ($colorIndex) {
|
||||
$this->colors[$rgb] = $colorIndex;
|
||||
} else {
|
||||
if (count($this->colors) == 0) {
|
||||
if (count($this->colors) === 0) {
|
||||
$lastColor = 7;
|
||||
} else {
|
||||
$lastColor = end($this->colors);
|
||||
|
@ -437,7 +435,7 @@ class Workbook extends BIFFwriter
|
|||
|
||||
// Prepare part 3 of the workbook global stream, what goes after the SHEET records
|
||||
$part3 = '';
|
||||
if ($this->countryCode != -1) {
|
||||
if ($this->countryCode !== -1) {
|
||||
$part3 .= $this->writeCountry();
|
||||
}
|
||||
$part3 .= $this->writeRecalcId();
|
||||
|
@ -918,7 +916,7 @@ class Workbook extends BIFFwriter
|
|||
$record = 0x0022; // Record identifier
|
||||
$length = 0x0002; // Bytes to follow
|
||||
|
||||
$f1904 = (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904)
|
||||
$f1904 = (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904)
|
||||
? 1
|
||||
: 0; // Flag for 1904 date system
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class Workbook extends WriterPart
|
|||
{
|
||||
$objWriter->startElement('workbookPr');
|
||||
|
||||
if (Date::getExcelCalendar() == Date::CALENDAR_MAC_1904) {
|
||||
if (Date::getExcelCalendar() === Date::CALENDAR_MAC_1904) {
|
||||
$objWriter->writeAttribute('date1904', '1');
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ class Workbook extends WriterPart
|
|||
$objWriter->startElement('sheet');
|
||||
$objWriter->writeAttribute('name', $pSheetname);
|
||||
$objWriter->writeAttribute('sheetId', $pSheetId);
|
||||
if ($sheetState != 'visible' && $sheetState != '') {
|
||||
if ($sheetState !== 'visible' && $sheetState != '') {
|
||||
$objWriter->writeAttribute('state', $sheetState);
|
||||
}
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
||||
|
|
|
@ -141,7 +141,7 @@ class Worksheet extends WriterPart
|
|||
$objWriter->startElement('sheetPr');
|
||||
if ($pSheet->getParent()->hasMacros()) {
|
||||
//if the workbook have macros, we need to have codeName for the sheet
|
||||
if ($pSheet->hasCodeName() == false) {
|
||||
if (!$pSheet->hasCodeName()) {
|
||||
$pSheet->setCodeName($pSheet->getTitle());
|
||||
}
|
||||
$objWriter->writeAttribute('codeName', $pSheet->getCodeName());
|
||||
|
@ -322,7 +322,7 @@ class Worksheet extends WriterPart
|
|||
}
|
||||
|
||||
// Set Zero Height row
|
||||
if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() == '1' ||
|
||||
if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' ||
|
||||
strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') {
|
||||
$objWriter->writeAttribute('zeroHeight', '1');
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ class Worksheet extends WriterPart
|
|||
// sheetProtection
|
||||
$objWriter->startElement('sheetProtection');
|
||||
|
||||
if ($pSheet->getProtection()->getPassword() != '') {
|
||||
if ($pSheet->getProtection()->getPassword() !== '') {
|
||||
$objWriter->writeAttribute('password', $pSheet->getProtection()->getPassword());
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,7 @@ class Worksheet extends WriterPart
|
|||
$objWriter->writeAttribute('location', str_replace('sheet://', '', $hyperlink->getUrl()));
|
||||
}
|
||||
|
||||
if ($hyperlink->getTooltip() != '') {
|
||||
if ($hyperlink->getTooltip() !== '') {
|
||||
$objWriter->writeAttribute('tooltip', $hyperlink->getTooltip());
|
||||
$objWriter->writeAttribute('display', $hyperlink->getTooltip());
|
||||
}
|
||||
|
@ -995,12 +995,12 @@ class Worksheet extends WriterPart
|
|||
}
|
||||
|
||||
// Row visibility
|
||||
if ($rowDimension->getVisible() == false) {
|
||||
if (!$rowDimension->getVisible()) {
|
||||
$objWriter->writeAttribute('hidden', 'true');
|
||||
}
|
||||
|
||||
// Collapsed
|
||||
if ($rowDimension->getCollapsed() == true) {
|
||||
if ($rowDimension->getCollapsed()) {
|
||||
$objWriter->writeAttribute('collapsed', 'true');
|
||||
}
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ class Worksheet extends WriterPart
|
|||
break;
|
||||
case 'f': // Formula
|
||||
$attributes = $pCell->getFormulaAttributes();
|
||||
if ($attributes['t'] == 'array') {
|
||||
if ($attributes['t'] === 'array') {
|
||||
$objWriter->startElement('f');
|
||||
$objWriter->writeAttribute('t', 'array');
|
||||
$objWriter->writeAttribute('ref', $pCellAddress);
|
||||
|
@ -1118,7 +1118,7 @@ class Worksheet extends WriterPart
|
|||
}
|
||||
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
||||
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
||||
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
|
||||
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) !== '#') {
|
||||
$objWriter->writeElement('v', StringHelper::formatNumber($calculatedValue));
|
||||
} else {
|
||||
$objWriter->writeElement('v', '0');
|
||||
|
@ -1139,7 +1139,7 @@ class Worksheet extends WriterPart
|
|||
|
||||
break;
|
||||
case 'e': // Error
|
||||
if (substr($cellValue, 0, 1) == '=') {
|
||||
if (substr($cellValue, 0, 1) === '=') {
|
||||
$objWriter->writeElement('f', substr($cellValue, 1));
|
||||
$objWriter->writeElement('v', substr($cellValue, 1));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue