Lock our deps with our minimum PHP 7.2, instead of PHP 7.3

This commit is contained in:
Adrien Crivelli 2021-10-30 12:54:26 +09:00 committed by GitHub
parent 11f758e412
commit e550528c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 401 additions and 408 deletions

497
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -35,11 +35,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
-
message: "#^Binary operation \"\\-\" between 0 and string\\|false results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:\\$spreadsheet \\(PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\|null\\.$#" message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:\\$spreadsheet \\(PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\|null\\.$#"
count: 1 count: 1
@ -425,11 +420,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/Erf.php path: src/PhpSpreadsheet/Calculation/Engineering/Erf.php
-
message: "#^Binary operation \"\\-\" between 1 and float\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/Erf.php
- -
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engineering\\\\ErfC\\:\\:\\$oneSqrtPi has no typehint specified\\.$#" message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engineering\\\\ErfC\\:\\:\\$oneSqrtPi has no typehint specified\\.$#"
count: 1 count: 1
@ -445,11 +435,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php
-
message: "#^Binary operation \"\\-\" between 2 and float\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php
- -
message: "#^Parameter \\#1 \\$callback of function set_error_handler expects \\(callable\\(int, string, string, int, array\\)\\: bool\\)\\|null, array\\('PhpOffice\\\\\\\\PhpSpreadsheet\\\\\\\\Calculation\\\\\\\\Exception', 'errorHandlerCallback'\\) given\\.$#" message: "#^Parameter \\#1 \\$callback of function set_error_handler expects \\(callable\\(int, string, string, int, array\\)\\: bool\\)\\|null, array\\('PhpOffice\\\\\\\\PhpSpreadsheet\\\\\\\\Calculation\\\\\\\\Exception', 'errorHandlerCallback'\\) given\\.$#"
count: 1 count: 1
@ -675,11 +660,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/Address.php path: src/PhpSpreadsheet/Calculation/LookupRef/Address.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\ExcelMatch\\:\\:MATCH\\(\\) should return int\\|string but returns float\\|int\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\ExcelMatch\\:\\:matchFirstValue\\(\\) has no return typehint specified\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\LookupRef\\\\ExcelMatch\\:\\:matchFirstValue\\(\\) has no return typehint specified\\.$#"
count: 1 count: 1
@ -1005,11 +985,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php
-
message: "#^Binary operation \"\\-\" between 1 and float\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Distributions\\\\ChiSquared\\:\\:pchisq\\(\\) has no return typehint specified\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Statistical\\\\Distributions\\\\ChiSquared\\:\\:pchisq\\(\\) has no return typehint specified\\.$#"
count: 1 count: 1
@ -1130,11 +1105,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php
-
message: "#^Binary operation \"\\-\" between 1 and float\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php
- -
message: "#^Binary operation \"\\-\" between float\\|string and float\\|int\\|\\(string&numeric\\) results in an error\\.$#" message: "#^Binary operation \"\\-\" between float\\|string and float\\|int\\|\\(string&numeric\\) results in an error\\.$#"
count: 1 count: 1
@ -2355,16 +2325,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\BaseDrawing\\:\\:setOffsetX\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\BaseDrawing\\:\\:setOffsetY\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
- -
message: "#^Parameter \\#2 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\IReadFilter\\:\\:readCell\\(\\) expects int, string given\\.$#" message: "#^Parameter \\#2 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\IReadFilter\\:\\:readCell\\(\\) expects int, string given\\.$#"
count: 1 count: 1
@ -2400,21 +2360,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#2 \\$pos of static method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xls\\:\\:getUInt2d\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#2 \\$pos of static method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xls\\:\\:getInt4d\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Parameter \\#2 \\$start of function substr expects int, float\\|int given\\.$#"
count: 5
path: src/PhpSpreadsheet/Reader/Xls.php
- -
message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryBelow\\(\\) expects bool, int given\\.$#" message: "#^Parameter \\#1 \\$pValue of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryBelow\\(\\) expects bool, int given\\.$#"
count: 1 count: 1
@ -2610,11 +2555,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Parameter \\#1 \\$is of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:parseRichText\\(\\) expects SimpleXMLElement\\|null, object given\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
- -
message: "#^Negated boolean expression is always true\\.$#" message: "#^Negated boolean expression is always true\\.$#"
count: 1 count: 1
@ -3336,12 +3276,12 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xml.php path: src/PhpSpreadsheet/Reader/Xml.php
- -
message: "#^Parameter \\#2 \\$cmp_function of function uksort expects callable\\(mixed, mixed\\)\\: int, array\\('self', 'cellReverseSort'\\) given\\.$#" message: "#^Parameter \\#2 \\$cmp_function of function uksort expects callable\\(\\(int\\|string\\), \\(int\\|string\\)\\)\\: int, array\\('self', 'cellReverseSort'\\) given\\.$#"
count: 4 count: 4
path: src/PhpSpreadsheet/ReferenceHelper.php path: src/PhpSpreadsheet/ReferenceHelper.php
- -
message: "#^Parameter \\#2 \\$cmp_function of function uksort expects callable\\(mixed, mixed\\)\\: int, array\\('self', 'cellSort'\\) given\\.$#" message: "#^Parameter \\#2 \\$cmp_function of function uksort expects callable\\(\\(int\\|string\\), \\(int\\|string\\)\\)\\: int, array\\('self', 'cellSort'\\) given\\.$#"
count: 4 count: 4
path: src/PhpSpreadsheet/ReferenceHelper.php path: src/PhpSpreadsheet/ReferenceHelper.php
@ -3350,11 +3290,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php path: src/PhpSpreadsheet/ReferenceHelper.php
-
message: "#^Parameter \\#1 \\$columnIndex of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:stringFromColumnIndex\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/ReferenceHelper.php
- -
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#" message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
count: 1 count: 1
@ -5330,11 +5265,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
-
message: "#^Parameter \\#2 \\$pad_length of function str_pad expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xls.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\BIFFwriter\\:\\:writeEof\\(\\) has no return typehint specified\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xls\\\\BIFFwriter\\:\\:writeEof\\(\\) has no return typehint specified\\.$#"
count: 1 count: 1
@ -5870,16 +5800,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php
-
message: "#^Parameter \\#2 \\$pId of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeRelationship\\(\\) expects int, float\\|int given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeDrawingHyperLink\\(\\) should return int but returns float\\|int\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Rels.php
- -
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int\\<0, max\\> given\\.$#" message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int\\<0, max\\> given\\.$#"
count: 1 count: 1
@ -6380,16 +6300,6 @@ parameters:
count: 2 count: 2
path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
-
message: "#^Cannot access property \\$workbookProtection on SimpleXMLElement\\|false\\.$#"
count: 3
path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
-
message: "#^Cannot access property \\$sheets on SimpleXMLElement\\|false\\.$#"
count: 2
path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
- -
message: "#^Cannot access property \\$pageSetup on SimpleXMLElement\\|false\\.$#" message: "#^Cannot access property \\$pageSetup on SimpleXMLElement\\|false\\.$#"
count: 1 count: 1
@ -6400,3 +6310,53 @@ parameters:
count: 5 count: 5
path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php path: tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php
-
message: "#^Argument of an invalid type SimpleXMLElement\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xml/Properties.php
-
message: "#^Argument of an invalid type SimpleXMLElement\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xml/Style.php
-
message: "#^Binary operation \"/\" between int\\|string and 360 results in an error\\.$#"
count: 3
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php
-
message: "#^Binary operation \"/\" between int\\|string and 365 results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php
-
message: "#^Binary operation \"/\" between int\\|string and \\(float\\|int\\) results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php
-
message: "#^Binary operation \"/\" between float\\|string and float\\|string results in an error\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
-
message: "#^Binary operation \"/\" between float\\|int\\|string and float\\|int\\|string results in an error\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php
-
message: "#^Binary operation \"/\" between float\\|int\\|string and float\\|int results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php
-
message: "#^Binary operation \"/\" between float\\|int\\|string and float\\|int\\|string results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Permutations.php
-
message: "#^Offset '(percentage|value)' does not exist on SimpleXMLElement|null\\.$#"
count: 3
path: src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php

View File

@ -3161,9 +3161,9 @@ class Calculation
return $formula; return $formula;
} }
private static $functionReplaceFromExcel = null; private static $functionReplaceFromExcel;
private static $functionReplaceToLocale = null; private static $functionReplaceToLocale;
public function _translateFormulaToLocale($formula) public function _translateFormulaToLocale($formula)
{ {
@ -3190,9 +3190,9 @@ class Calculation
return self::translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$localeArgumentSeparator); return self::translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$localeArgumentSeparator);
} }
private static $functionReplaceFromLocale = null; private static $functionReplaceFromLocale;
private static $functionReplaceToExcel = null; private static $functionReplaceToExcel;
public function _translateFormulaToEnglish($formula) public function _translateFormulaToEnglish($formula)
{ {
@ -5405,7 +5405,7 @@ class Calculation
// Apply any defaults for empty argument values // Apply any defaults for empty argument values
foreach ($emptyArguments as $argumentId => $isArgumentEmpty) { foreach ($emptyArguments as $argumentId => $isArgumentEmpty) {
if ($isArgumentEmpty === true) { if ($isArgumentEmpty === true) {
$reflectedArgumentId = count($args) - $argumentId - 1; $reflectedArgumentId = count($args) - (int) $argumentId - 1;
if ( if (
!array_key_exists($reflectedArgumentId, $methodArguments) || !array_key_exists($reflectedArgumentId, $methodArguments) ||
$methodArguments[$reflectedArgumentId]->isVariadic() $methodArguments[$reflectedArgumentId]->isVariadic()

View File

@ -103,7 +103,7 @@ class Deviations
* *
* @param array ...$args Data Series * @param array ...$args Data Series
* *
* @return float|string The result, or a string containing an error * @return float|int|string The result, or a string containing an error
*/ */
public static function skew(...$args) public static function skew(...$args)
{ {

View File

@ -209,7 +209,7 @@ class Gnumeric extends BaseReader
foreach ($sheet->Objects->children(self::NAMESPACE_GNM) as $key => $comment) { foreach ($sheet->Objects->children(self::NAMESPACE_GNM) as $key => $comment) {
$commentAttributes = $comment->attributes(); $commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment // Only comment objects are handled at the moment
if ($commentAttributes->Text) { if ($commentAttributes && $commentAttributes->Text) {
$this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound) $this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)
->setAuthor((string) $commentAttributes->Author) ->setAuthor((string) $commentAttributes->Author)
->setText($this->parseRichText((string) $commentAttributes->Text)); ->setText($this->parseRichText((string) $commentAttributes->Text));

View File

@ -24,6 +24,10 @@ class PageSetup
{ {
if (isset($sheet->PrintInformation)) { if (isset($sheet->PrintInformation)) {
$printInformation = $sheet->PrintInformation[0]; $printInformation = $sheet->PrintInformation[0];
if (!$printInformation) {
return $this;
}
$scale = (string) $printInformation->Scale->attributes()['percentage']; $scale = (string) $printInformation->Scale->attributes()['percentage'];
$pageOrder = (string) $printInformation->order; $pageOrder = (string) $printInformation->order;
$orientation = (string) $printInformation->orientation; $orientation = (string) $printInformation->orientation;

View File

@ -113,8 +113,10 @@ class Properties
break; break;
case 'user-defined': case 'user-defined':
[, $attrName] = explode(':', $attributes['name']); if ($attributes) {
$this->userDefinedProperties($attrName, $propertyValue); [, $attrName] = explode(':', (string) $attributes['name']);
$this->userDefinedProperties($attrName, $propertyValue);
}
break; break;
} }

View File

@ -101,10 +101,6 @@ class Styles
private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $maxCol): void private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $maxCol): void
{ {
foreach ($styleRegion as $style) { foreach ($styleRegion as $style) {
if ($style === null) {
continue;
}
$styleAttributes = $style->attributes(); $styleAttributes = $style->attributes();
if ($styleAttributes !== null && ($styleAttributes['startRow'] <= $maxRow) && ($styleAttributes['startCol'] <= $maxCol)) { if ($styleAttributes !== null && ($styleAttributes['startRow'] <= $maxRow) && ($styleAttributes['startCol'] <= $maxCol)) {
$cellRange = $this->readStyleRange($styleAttributes, $maxCol, $maxRow); $cellRange = $this->readStyleRange($styleAttributes, $maxCol, $maxRow);
@ -114,8 +110,8 @@ class Styles
$styleArray = []; $styleArray = [];
// We still set the number format mask for date/time values, even if readDataOnly is true // We still set the number format mask for date/time values, even if readDataOnly is true
// so that we can identify whether a float is a float or a date value // so that we can identify whether a float is a float or a date value
$formatCode = (string) $styleAttributes['Format']; $formatCode = $styleAttributes ? (string) $styleAttributes['Format'] : null;
if (Date::isDateTimeFormatCode($formatCode)) { if ($formatCode && Date::isDateTimeFormatCode($formatCode)) {
$styleArray['numberFormat']['formatCode'] = $formatCode; $styleArray['numberFormat']['formatCode'] = $formatCode;
} }
if ($this->readDataOnly === false && $styleAttributes !== null) { if ($this->readDataOnly === false && $styleAttributes !== null) {
@ -183,7 +179,7 @@ class Styles
$styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']); $styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']);
} }
self::addStyle($styleArray, 'borderStyle', $borderAttributes['Style']); self::addStyle($styleArray, 'borderStyle', (string) $borderAttributes['Style']);
} }
return $styleArray; return $styleArray;
@ -201,12 +197,12 @@ class Styles
private function addColors(array &$styleArray, SimpleXMLElement $styleAttributes): void private function addColors(array &$styleArray, SimpleXMLElement $styleAttributes): void
{ {
$RGB = self::parseGnumericColour($styleAttributes['Fore']); $RGB = self::parseGnumericColour((string) $styleAttributes['Fore']);
$styleArray['font']['color']['rgb'] = $RGB; $styleArray['font']['color']['rgb'] = $RGB;
$RGB = self::parseGnumericColour($styleAttributes['Back']); $RGB = self::parseGnumericColour((string) $styleAttributes['Back']);
$shade = (string) $styleAttributes['Shade']; $shade = (string) $styleAttributes['Shade'];
if (($RGB !== '000000') || ($shade !== '0')) { if (($RGB !== '000000') || ($shade !== '0')) {
$RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']); $RGB2 = self::parseGnumericColour((string) $styleAttributes['PatternColor']);
if ($shade === '1') { if ($shade === '1') {
$styleArray['fill']['startColor']['rgb'] = $RGB; $styleArray['fill']['startColor']['rgb'] = $RGB;
$styleArray['fill']['endColor']['rgb'] = $RGB2; $styleArray['fill']['endColor']['rgb'] = $RGB2;
@ -234,8 +230,8 @@ class Styles
private function readStyle(array $styleArray, SimpleXMLElement $styleAttributes, SimpleXMLElement $style): array private function readStyle(array $styleArray, SimpleXMLElement $styleAttributes, SimpleXMLElement $style): array
{ {
self::addStyle2($styleArray, 'alignment', 'horizontal', $styleAttributes['HAlign']); self::addStyle2($styleArray, 'alignment', 'horizontal', (string) $styleAttributes['HAlign']);
self::addStyle2($styleArray, 'alignment', 'vertical', $styleAttributes['VAlign']); self::addStyle2($styleArray, 'alignment', 'vertical', (string) $styleAttributes['VAlign']);
$styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1'; $styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1';
$styleArray['alignment']['textRotation'] = $this->calcRotation($styleAttributes); $styleArray['alignment']['textRotation'] = $this->calcRotation($styleAttributes);
$styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1'; $styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1';
@ -250,7 +246,7 @@ class Styles
$styleArray['font']['bold'] = $fontAttributes['Bold'] == '1'; $styleArray['font']['bold'] = $fontAttributes['Bold'] == '1';
$styleArray['font']['italic'] = $fontAttributes['Italic'] == '1'; $styleArray['font']['italic'] = $fontAttributes['Italic'] == '1';
$styleArray['font']['strikethrough'] = $fontAttributes['StrikeThrough'] == '1'; $styleArray['font']['strikethrough'] = $fontAttributes['StrikeThrough'] == '1';
self::addStyle2($styleArray, 'font', 'underline', $fontAttributes['Underline']); self::addStyle2($styleArray, 'font', 'underline', (string) $fontAttributes['Underline']);
switch ($fontAttributes['Script']) { switch ($fontAttributes['Script']) {
case '1': case '1':

View File

@ -65,7 +65,7 @@ class Ods extends BaseReader
$manifest = $xml->children($namespacesContent['manifest']); $manifest = $xml->children($namespacesContent['manifest']);
foreach ($manifest as $manifestDataSet) { foreach ($manifest as $manifestDataSet) {
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') { if ($manifestAttributes && $manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'}; $mimeType = (string) $manifestAttributes->{'media-type'};
break; break;
@ -357,7 +357,7 @@ class Ods extends BaseReader
break; break;
case 'table-row': case 'table-row':
if ($childNode->hasAttributeNS($tableNs, 'number-rows-repeated')) { if ($childNode->hasAttributeNS($tableNs, 'number-rows-repeated')) {
$rowRepeats = $childNode->getAttributeNS($tableNs, 'number-rows-repeated'); $rowRepeats = (int) $childNode->getAttributeNS($tableNs, 'number-rows-repeated');
} else { } else {
$rowRepeats = 1; $rowRepeats = 1;
} }
@ -514,7 +514,7 @@ class Ods extends BaseReader
$dataValue = Date::PHPToExcel( $dataValue = Date::PHPToExcel(
strtotime( strtotime(
'01-01-1970 ' . implode(':', sscanf($timeValue, 'PT%dH%dM%dS')) '01-01-1970 ' . implode(':', sscanf($timeValue, 'PT%dH%dM%dS') ?? [])
) )
); );
$formatting = NumberFormat::FORMAT_DATE_TIME4; $formatting = NumberFormat::FORMAT_DATE_TIME4;
@ -632,6 +632,7 @@ class Ods extends BaseReader
if ($zip->locateName('settings.xml') !== false) { if ($zip->locateName('settings.xml') !== false) {
$this->processSettings($zip, $spreadsheet); $this->processSettings($zip, $spreadsheet);
} }
// Return // Return
return $spreadsheet; return $spreadsheet;
} }

View File

@ -26,7 +26,7 @@ class Properties
$this->setCoreProperties($docProps, $officePropertiesDC); $this->setCoreProperties($docProps, $officePropertiesDC);
} }
$officePropertyMeta = (object) []; $officePropertyMeta = [];
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
} }

View File

@ -55,7 +55,7 @@ class Xlsx extends BaseReader
* *
* @var Xlsx\Theme * @var Xlsx\Theme
*/ */
private static $theme = null; private static $theme;
/** /**
* @var ZipArchive * @var ZipArchive
@ -182,7 +182,7 @@ class Xlsx extends BaseReader
$relType = (string) $rel['Type']; $relType = (string) $rel['Type'];
$mainNS = self::REL_TO_MAIN[$relType] ?? Namespaces::MAIN; $mainNS = self::REL_TO_MAIN[$relType] ?? Namespaces::MAIN;
if ($mainNS !== '') { if ($mainNS !== '') {
$xmlWorkbook = $this->loadZip($rel['Target'], $mainNS); $xmlWorkbook = $this->loadZip((string) $rel['Target'], $mainNS);
if ($xmlWorkbook->sheets) { if ($xmlWorkbook->sheets) {
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
@ -246,7 +246,7 @@ class Xlsx extends BaseReader
'totalColumns' => 0, 'totalColumns' => 0,
]; ];
$fileWorksheet = $worksheets[(string) self::getArrayItem(self::getAttributes($eleSheet, $namespace), 'id')]; $fileWorksheet = (string) $worksheets[(string) self::getArrayItem(self::getAttributes($eleSheet, $namespace), 'id')];
$fileWorksheetPath = strpos($fileWorksheet, '/') === 0 ? substr($fileWorksheet, 1) : "$dir/$fileWorksheet"; $fileWorksheetPath = strpos($fileWorksheet, '/') === 0 ? substr($fileWorksheet, 1) : "$dir/$fileWorksheet";
$xml = new XMLReader(); $xml = new XMLReader();
@ -408,13 +408,14 @@ class Xlsx extends BaseReader
$wbRels = $this->loadZip("xl/_rels/${workbookBasename}.rels", Namespaces::RELATIONSHIPS); $wbRels = $this->loadZip("xl/_rels/${workbookBasename}.rels", Namespaces::RELATIONSHIPS);
foreach ($wbRels->Relationship as $relx) { foreach ($wbRels->Relationship as $relx) {
$rel = self::getAttributes($relx); $rel = self::getAttributes($relx);
$relTarget = (string) $rel['Target'];
switch ($rel['Type']) { switch ($rel['Type']) {
case "$xmlNamespaceBase/theme": case "$xmlNamespaceBase/theme":
$themeOrderArray = ['lt1', 'dk1', 'lt2', 'dk2']; $themeOrderArray = ['lt1', 'dk1', 'lt2', 'dk2'];
$themeOrderAdditional = count($themeOrderArray); $themeOrderAdditional = count($themeOrderArray);
$drawingNS = self::REL_TO_DRAWING[$xmlNamespaceBase] ?? Namespaces::DRAWINGML; $drawingNS = self::REL_TO_DRAWING[$xmlNamespaceBase] ?? Namespaces::DRAWINGML;
$xmlTheme = $this->loadZip("xl/{$rel['Target']}", $drawingNS); $xmlTheme = $this->loadZip("xl/{$relTarget}", $drawingNS);
$xmlThemeName = self::getAttributes($xmlTheme); $xmlThemeName = self::getAttributes($xmlTheme);
$xmlTheme = $xmlTheme->children($drawingNS); $xmlTheme = $xmlTheme->children($drawingNS);
$themeName = (string) $xmlThemeName['name']; $themeName = (string) $xmlThemeName['name'];
@ -431,10 +432,10 @@ class Xlsx extends BaseReader
} }
if (isset($xmlColour->sysClr)) { if (isset($xmlColour->sysClr)) {
$xmlColourData = self::getAttributes($xmlColour->sysClr); $xmlColourData = self::getAttributes($xmlColour->sysClr);
$themeColours[$themePos] = $xmlColourData['lastClr']; $themeColours[$themePos] = (string) $xmlColourData['lastClr'];
} elseif (isset($xmlColour->srgbClr)) { } elseif (isset($xmlColour->srgbClr)) {
$xmlColourData = self::getAttributes($xmlColour->srgbClr); $xmlColourData = self::getAttributes($xmlColour->srgbClr);
$themeColours[$themePos] = $xmlColourData['val']; $themeColours[$themePos] = (string) $xmlColourData['val'];
} }
} }
self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours); self::$theme = new Xlsx\Theme($themeName, $colourSchemeName, $themeColours);
@ -448,34 +449,35 @@ class Xlsx extends BaseReader
$propertyReader = new PropertyReader($this->securityScanner, $excel->getProperties()); $propertyReader = new PropertyReader($this->securityScanner, $excel->getProperties());
foreach ($rels->Relationship as $relx) { foreach ($rels->Relationship as $relx) {
$rel = self::getAttributes($relx); $rel = self::getAttributes($relx);
$relTarget = (string) $rel['Target'];
$relType = (string) $rel['Type']; $relType = (string) $rel['Type'];
$mainNS = self::REL_TO_MAIN[$relType] ?? Namespaces::MAIN; $mainNS = self::REL_TO_MAIN[$relType] ?? Namespaces::MAIN;
switch ($relType) { switch ($relType) {
case Namespaces::CORE_PROPERTIES: case Namespaces::CORE_PROPERTIES:
$propertyReader->readCoreProperties($this->getFromZipArchive($zip, $rel['Target'])); $propertyReader->readCoreProperties($this->getFromZipArchive($zip, $relTarget));
break; break;
case "$xmlNamespaceBase/extended-properties": case "$xmlNamespaceBase/extended-properties":
$propertyReader->readExtendedProperties($this->getFromZipArchive($zip, $rel['Target'])); $propertyReader->readExtendedProperties($this->getFromZipArchive($zip, $relTarget));
break; break;
case "$xmlNamespaceBase/custom-properties": case "$xmlNamespaceBase/custom-properties":
$propertyReader->readCustomProperties($this->getFromZipArchive($zip, $rel['Target'])); $propertyReader->readCustomProperties($this->getFromZipArchive($zip, $relTarget));
break; break;
//Ribbon //Ribbon
case Namespaces::EXTENSIBILITY: case Namespaces::EXTENSIBILITY:
$customUI = $rel['Target']; $customUI = $relTarget;
if ($customUI !== null) { if ($customUI) {
$this->readRibbon($excel, $customUI, $zip); $this->readRibbon($excel, $customUI, $zip);
} }
break; break;
case "$xmlNamespaceBase/officeDocument": case "$xmlNamespaceBase/officeDocument":
$dir = dirname($rel['Target']); $dir = dirname($relTarget);
// Do not specify namespace in next stmt - do it in Xpath // Do not specify namespace in next stmt - do it in Xpath
$relsWorkbook = $this->loadZip("$dir/_rels/" . basename($rel['Target']) . '.rels', ''); $relsWorkbook = $this->loadZip("$dir/_rels/" . basename($relTarget) . '.rels', '');
$relsWorkbook->registerXPathNamespace('rel', Namespaces::RELATIONSHIPS); $relsWorkbook->registerXPathNamespace('rel', Namespaces::RELATIONSHIPS);
$sharedStrings = []; $sharedStrings = [];
@ -645,8 +647,8 @@ class Xlsx extends BaseReader
$dxfs = $styleReader->dxfs($this->readDataOnly); $dxfs = $styleReader->dxfs($this->readDataOnly);
$styles = $styleReader->styles(); $styles = $styleReader->styles();
$xmlWorkbook = $this->loadZipNoNamespace($rel['Target'], $mainNS); $xmlWorkbook = $this->loadZipNoNamespace($relTarget, $mainNS);
$xmlWorkbookNS = $this->loadZip($rel['Target'], $mainNS); $xmlWorkbookNS = $this->loadZip($relTarget, $mainNS);
// Set base date // Set base date
if ($xmlWorkbookNS->workbookPr) { if ($xmlWorkbookNS->workbookPr) {
@ -694,7 +696,7 @@ class Xlsx extends BaseReader
// and we're simply bringing the worksheet name in line with the formula, not the // and we're simply bringing the worksheet name in line with the formula, not the
// reverse // reverse
$docSheet->setTitle((string) $eleSheetAttr['name'], false, false); $docSheet->setTitle((string) $eleSheetAttr['name'], false, false);
$fileWorksheet = $worksheets[(string) self::getArrayItem(self::getAttributes($eleSheet, $xmlNamespaceBase), 'id')]; $fileWorksheet = (string) $worksheets[(string) self::getArrayItem(self::getAttributes($eleSheet, $xmlNamespaceBase), 'id')];
$xmlSheet = $this->loadZipNoNamespace("$dir/$fileWorksheet", $mainNS); $xmlSheet = $this->loadZipNoNamespace("$dir/$fileWorksheet", $mainNS);
$xmlSheetNS = $this->loadZip("$dir/$fileWorksheet", $mainNS); $xmlSheetNS = $this->loadZip("$dir/$fileWorksheet", $mainNS);
@ -881,7 +883,7 @@ class Xlsx extends BaseReader
foreach ($xmlSheet->extLst->ext->children('x14', true)->dataValidations->dataValidation as $item) { foreach ($xmlSheet->extLst->ext->children('x14', true)->dataValidations->dataValidation as $item) {
$node = $xmlSheet->dataValidations->addChild('dataValidation'); $node = $xmlSheet->dataValidations->addChild('dataValidation');
foreach ($item->attributes() as $attr) { foreach ($item->attributes() ?? [] as $attr) {
$node->addAttribute($attr->getName(), $attr); $node->addAttribute($attr->getName(), $attr);
} }
$node->addAttribute('sqref', $item->children('xm', true)->sqref); $node->addAttribute('sqref', $item->children('xm', true)->sqref);
@ -1580,7 +1582,7 @@ class Xlsx extends BaseReader
switch ($contentType['ContentType']) { switch ($contentType['ContentType']) {
case 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml': case 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml':
if ($this->includeCharts) { if ($this->includeCharts) {
$chartEntryRef = ltrim($contentType['PartName'], '/'); $chartEntryRef = ltrim((string) $contentType['PartName'], '/');
$chartElements = $this->loadZip($chartEntryRef); $chartElements = $this->loadZip($chartEntryRef);
$objChart = Chart::readChart($chartElements, basename($chartEntryRef, '.xml')); $objChart = Chart::readChart($chartElements, basename($chartEntryRef, '.xml'));
@ -1656,8 +1658,6 @@ class Xlsx extends BaseReader
} }
/** /**
* @param SimpleXMLElement | null $is
*
* @return RichText * @return RichText
*/ */
private function parseRichText(?SimpleXMLElement $is) private function parseRichText(?SimpleXMLElement $is)
@ -1742,11 +1742,7 @@ class Xlsx extends BaseReader
return $value; return $value;
} }
/** private function readRibbon(Spreadsheet $excel, string $customUITarget, ZipArchive $zip): void
* @param mixed $customUITarget
* @param mixed $zip
*/
private function readRibbon(Spreadsheet $excel, $customUITarget, $zip): void
{ {
$baseDir = dirname($customUITarget); $baseDir = dirname($customUITarget);
$nameCustomUI = basename($customUITarget); $nameCustomUI = basename($customUITarget);
@ -1990,11 +1986,12 @@ class Xlsx extends BaseReader
$rels = $this->loadZip(self::INITIAL_FILE); $rels = $this->loadZip(self::INITIAL_FILE);
foreach ($rels->children(Namespaces::RELATIONSHIPS)->Relationship as $rel) { foreach ($rels->children(Namespaces::RELATIONSHIPS)->Relationship as $rel) {
$rel = self::getAttributes($rel); $rel = self::getAttributes($rel);
switch ($rel['Type']) { $type = (string) $rel['Type'];
switch ($type) {
case Namespaces::OFFICE_DOCUMENT: case Namespaces::OFFICE_DOCUMENT:
case Namespaces::PURL_OFFICE_DOCUMENT: case Namespaces::PURL_OFFICE_DOCUMENT:
$basename = basename($rel['Target']); $basename = basename((string) $rel['Target']);
$xmlNamespaceBase = dirname($rel['Type']); $xmlNamespaceBase = dirname($type);
if (preg_match('/workbook.*\.xml/', $basename)) { if (preg_match('/workbook.*\.xml/', $basename)) {
$workbookBasename = $basename; $workbookBasename = $basename;
} }

View File

@ -89,7 +89,7 @@ class AutoFilter
$customFilters = $filterColumn->customFilters; $customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join; // Custom filters can an AND or an OR join;
// and there should only ever be one or two entries // and there should only ever be one or two entries
if ((isset($customFilters['and'])) && ($customFilters['and'] == 1)) { if ((isset($customFilters['and'])) && ((string) $customFilters['and'] === '1')) {
$column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND); $column->setJoin(Column::AUTOFILTER_COLUMN_JOIN_AND);
} }
foreach ($customFilters->customFilter as $filterRule) { foreach ($customFilters->customFilter as $filterRule) {
@ -130,12 +130,12 @@ class AutoFilter
// We should only ever have one top10 filter // We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) { foreach ($filterColumn->top10 as $filterRule) {
$column->createRule()->setRule( $column->createRule()->setRule(
(((isset($filterRule['percent'])) && ($filterRule['percent'] == 1)) (((isset($filterRule['percent'])) && ((string) $filterRule['percent'] === '1'))
? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
: Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
), ),
(string) $filterRule['val'], (string) $filterRule['val'],
(((isset($filterRule['top'])) && ($filterRule['top'] == 1)) (((isset($filterRule['top'])) && ((string) $filterRule['top'] === '1'))
? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP ? Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
: Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM : Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
) )

View File

@ -31,7 +31,9 @@ class Chart
} elseif ($format == 'integer') { } elseif ($format == 'integer') {
return (int) $attributes[$name]; return (int) $attributes[$name];
} elseif ($format == 'boolean') { } elseif ($format == 'boolean') {
return (bool) ($attributes[$name] === '0' || $attributes[$name] !== 'true') ? false : true; $value = (string) $attributes[$name];
return $value === 'true' || $value === '1';
} }
return (float) $attributes[$name]; return (float) $attributes[$name];
@ -482,7 +484,7 @@ class Chart
} }
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer')); $fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if ($fontSize !== null) { if (is_int($fontSize)) {
$objText->getFont()->setSize(floor($fontSize / 100)); $objText->getFont()->setSize(floor($fontSize / 100));
} }

View File

@ -21,7 +21,7 @@ class Styles extends BaseParserClass
* *
* @var Theme * @var Theme
*/ */
private static $theme = null; private static $theme;
private $styles = []; private $styles = [];

View File

@ -361,7 +361,7 @@ class Xml extends BaseReader
$columnTo = $columnID; $columnTo = $columnID;
if (isset($cell_ss['MergeAcross'])) { if (isset($cell_ss['MergeAcross'])) {
$additionalMergedCells += (int) $cell_ss['MergeAcross']; $additionalMergedCells += (int) $cell_ss['MergeAcross'];
$columnTo = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($columnID) + $cell_ss['MergeAcross']); $columnTo = Coordinate::stringFromColumnIndex((int) (Coordinate::columnIndexFromString($columnID) + $cell_ss['MergeAcross']));
} }
$rowTo = $rowID; $rowTo = $rowID;
if (isset($cell_ss['MergeDown'])) { if (isset($cell_ss['MergeDown'])) {

View File

@ -62,6 +62,10 @@ class PageSettings
foreach ($xmlX->WorksheetOptions->PageSetup as $pageSetupData) { foreach ($xmlX->WorksheetOptions->PageSetup as $pageSetupData) {
foreach ($pageSetupData as $pageSetupKey => $pageSetupValue) { foreach ($pageSetupData as $pageSetupKey => $pageSetupValue) {
$pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']); $pageSetupAttributes = $pageSetupValue->attributes($namespaces['x']);
if (!$pageSetupAttributes) {
continue;
}
switch ($pageSetupKey) { switch ($pageSetupKey) {
case 'Layout': case 'Layout':
$this->setLayout($printDefaults, $pageSetupAttributes); $this->setLayout($printDefaults, $pageSetupAttributes);

View File

@ -35,9 +35,12 @@ class Style
foreach ($style as $styleType => $styleDatax) { foreach ($style as $styleType => $styleDatax) {
$styleData = $styleDatax ?? new SimpleXMLElement('<xml></xml>'); $styleData = $styleDatax ?? new SimpleXMLElement('<xml></xml>');
$styleAttributes = $styleData->attributes($namespaces['ss']); $styleAttributes = $styleData->attributes($namespaces['ss']);
switch ($styleType) { switch ($styleType) {
case 'Alignment': case 'Alignment':
$alignment = $alignmentStyleParser->parseStyle($styleAttributes); if ($styleAttributes) {
$alignment = $alignmentStyleParser->parseStyle($styleAttributes);
}
break; break;
case 'Borders': case 'Borders':
@ -45,15 +48,21 @@ class Style
break; break;
case 'Font': case 'Font':
$font = $fontStyleParser->parseStyle($styleAttributes); if ($styleAttributes) {
$font = $fontStyleParser->parseStyle($styleAttributes);
}
break; break;
case 'Interior': case 'Interior':
$fill = $fillStyleParser->parseStyle($styleAttributes); if ($styleAttributes) {
$fill = $fillStyleParser->parseStyle($styleAttributes);
}
break; break;
case 'NumberFormat': case 'NumberFormat':
$numberFormat = $numberFormatStyleParser->parseStyle($styleAttributes); if ($styleAttributes) {
$numberFormat = $numberFormatStyleParser->parseStyle($styleAttributes);
}
break; break;
} }

View File

@ -24,7 +24,7 @@ class Settings
* *
* @var int * @var int
*/ */
private static $libXmlLoaderOptions = null; private static $libXmlLoaderOptions;
/** /**
* Allow/disallow libxml_disable_entity_loader() call when not thread safe. * Allow/disallow libxml_disable_entity_loader() call when not thread safe.

View File

@ -112,7 +112,7 @@ class Font
* *
* @var string * @var string
*/ */
private static $trueTypeFontPath = null; private static $trueTypeFontPath;
/** /**
* How wide is a default column for a given default font and size? * How wide is a default column for a given default font and size?

View File

@ -263,7 +263,7 @@ class Conditional implements IComparable
/** /**
* get DataBar. * get DataBar.
* *
* @return ConditionalDataBar | null * @return null|ConditionalDataBar
*/ */
public function getDataBar() public function getDataBar()
{ {

View File

@ -70,11 +70,12 @@ class ConditionalFormattingRuleExtension
foreach ($extFormattingsXml->children($ns['x14']) as $extFormattingXml) { foreach ($extFormattingsXml->children($ns['x14']) as $extFormattingXml) {
$extCfRuleXml = $extFormattingXml->cfRule; $extCfRuleXml = $extFormattingXml->cfRule;
if (((string) $extCfRuleXml->attributes()->type) !== Conditional::CONDITION_DATABAR) { $attributes = $extCfRuleXml->attributes();
if (!$attributes || ((string) $attributes->type) !== Conditional::CONDITION_DATABAR) {
continue; continue;
} }
$extFormattingRuleObj = new self((string) $extCfRuleXml->attributes()->id); $extFormattingRuleObj = new self((string) $attributes->id);
$extFormattingRuleObj->setSqref((string) $extFormattingXml->children($ns['xm'])->sqref); $extFormattingRuleObj->setSqref((string) $extFormattingXml->children($ns['xm'])->sqref);
$conditionalFormattingRuleExtensions[$extFormattingRuleObj->getId()] = $extFormattingRuleObj; $conditionalFormattingRuleExtensions[$extFormattingRuleObj->getId()] = $extFormattingRuleObj;
@ -136,11 +137,16 @@ class ConditionalFormattingRuleExtension
$cfvoIndex = 0; $cfvoIndex = 0;
foreach ($dataBarXml->cfvo as $cfvo) { foreach ($dataBarXml->cfvo as $cfvo) {
$f = (string) $cfvo->children($ns['xm'])->f; $f = (string) $cfvo->children($ns['xm'])->f;
$attributes = $cfvo->attributes();
if (!($attributes)) {
continue;
}
if ($cfvoIndex === 0) { if ($cfvoIndex === 0) {
$extDataBarObj->setMinimumConditionalFormatValueObject(new ConditionalFormatValueObject((string) $cfvo->attributes()['type'], null, (empty($f) ? null : $f))); $extDataBarObj->setMinimumConditionalFormatValueObject(new ConditionalFormatValueObject((string) $attributes['type'], null, (empty($f) ? null : $f)));
} }
if ($cfvoIndex === 1) { if ($cfvoIndex === 1) {
$extDataBarObj->setMaximumConditionalFormatValueObject(new ConditionalFormatValueObject((string) $cfvo->attributes()['type'], null, (empty($f) ? null : $f))); $extDataBarObj->setMaximumConditionalFormatValueObject(new ConditionalFormatValueObject((string) $attributes['type'], null, (empty($f) ? null : $f)));
} }
++$cfvoIndex; ++$cfvoIndex;
} }

View File

@ -65,13 +65,16 @@ class UnparsedDataTest extends TestCase
// xl/workbook.xml // xl/workbook.xml
$xmlWorkbook = simplexml_load_string($resultWorkbookRaw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); $xmlWorkbook = simplexml_load_string($resultWorkbookRaw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
self::assertNotFalse($xmlWorkbook);
if (!$xmlWorkbook->workbookProtection) { if (!$xmlWorkbook->workbookProtection) {
self::fail('workbook.xml/workbookProtection not found!'); self::fail('workbook.xml/workbookProtection not found!');
} else { } else {
self::assertEquals($xmlWorkbook->workbookProtection['workbookPassword'], 'CBEB', 'workbook.xml/workbookProtection[workbookPassword] is wrong!'); self::assertEquals($xmlWorkbook->workbookProtection['workbookPassword'], 'CBEB', 'workbook.xml/workbookProtection[workbookPassword] is wrong!');
self::assertEquals($xmlWorkbook->workbookProtection['lockStructure'], 'true', 'workbook.xml/workbookProtection[lockStructure] is wrong!'); self::assertEquals($xmlWorkbook->workbookProtection['lockStructure'], 'true', 'workbook.xml/workbookProtection[lockStructure] is wrong!');
self::assertNotNull($xmlWorkbook->sheets->sheet[0]);
self::assertEquals($xmlWorkbook->sheets->sheet[0]['state'], '', 'workbook.xml/sheets/sheet[0][state] is wrong!'); self::assertEquals($xmlWorkbook->sheets->sheet[0]['state'], '', 'workbook.xml/sheets/sheet[0][state] is wrong!');
self::assertNotNull($xmlWorkbook->sheets->sheet[1]);
self::assertEquals($xmlWorkbook->sheets->sheet[1]['state'], 'hidden', 'workbook.xml/sheets/sheet[1][state] is wrong!'); self::assertEquals($xmlWorkbook->sheets->sheet[1]['state'], 'hidden', 'workbook.xml/sheets/sheet[1][state] is wrong!');
} }
unset($xmlWorkbook); unset($xmlWorkbook);