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
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\\.$#"
count: 1
@ -425,11 +420,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -445,11 +435,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -675,11 +660,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -1005,11 +985,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -1130,11 +1105,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -2355,16 +2325,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -2400,21 +2360,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -2610,11 +2555,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -3336,12 +3276,12 @@ parameters:
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
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
path: src/PhpSpreadsheet/ReferenceHelper.php
@ -3350,11 +3290,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -5330,11 +5265,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -5870,16 +5800,6 @@ parameters:
count: 1
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\\.$#"
count: 1
@ -6380,16 +6300,6 @@ parameters:
count: 2
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\\.$#"
count: 1
@ -6400,3 +6310,53 @@ parameters:
count: 5
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;
}
private static $functionReplaceFromExcel = null;
private static $functionReplaceFromExcel;
private static $functionReplaceToLocale = null;
private static $functionReplaceToLocale;
public function _translateFormulaToLocale($formula)
{
@ -3190,9 +3190,9 @@ class Calculation
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)
{
@ -5405,7 +5405,7 @@ class Calculation
// Apply any defaults for empty argument values
foreach ($emptyArguments as $argumentId => $isArgumentEmpty) {
if ($isArgumentEmpty === true) {
$reflectedArgumentId = count($args) - $argumentId - 1;
$reflectedArgumentId = count($args) - (int) $argumentId - 1;
if (
!array_key_exists($reflectedArgumentId, $methodArguments) ||
$methodArguments[$reflectedArgumentId]->isVariadic()

View File

@ -103,7 +103,7 @@ class Deviations
*
* @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)
{

View File

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

View File

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

View File

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

View File

@ -101,10 +101,6 @@ class Styles
private function readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $maxCol): void
{
foreach ($styleRegion as $style) {
if ($style === null) {
continue;
}
$styleAttributes = $style->attributes();
if ($styleAttributes !== null && ($styleAttributes['startRow'] <= $maxRow) && ($styleAttributes['startCol'] <= $maxCol)) {
$cellRange = $this->readStyleRange($styleAttributes, $maxCol, $maxRow);
@ -114,8 +110,8 @@ class Styles
$styleArray = [];
// 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
$formatCode = (string) $styleAttributes['Format'];
if (Date::isDateTimeFormatCode($formatCode)) {
$formatCode = $styleAttributes ? (string) $styleAttributes['Format'] : null;
if ($formatCode && Date::isDateTimeFormatCode($formatCode)) {
$styleArray['numberFormat']['formatCode'] = $formatCode;
}
if ($this->readDataOnly === false && $styleAttributes !== null) {
@ -183,7 +179,7 @@ class Styles
$styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes['Color']);
}
self::addStyle($styleArray, 'borderStyle', $borderAttributes['Style']);
self::addStyle($styleArray, 'borderStyle', (string) $borderAttributes['Style']);
}
return $styleArray;
@ -201,12 +197,12 @@ class Styles
private function addColors(array &$styleArray, SimpleXMLElement $styleAttributes): void
{
$RGB = self::parseGnumericColour($styleAttributes['Fore']);
$RGB = self::parseGnumericColour((string) $styleAttributes['Fore']);
$styleArray['font']['color']['rgb'] = $RGB;
$RGB = self::parseGnumericColour($styleAttributes['Back']);
$RGB = self::parseGnumericColour((string) $styleAttributes['Back']);
$shade = (string) $styleAttributes['Shade'];
if (($RGB !== '000000') || ($shade !== '0')) {
$RGB2 = self::parseGnumericColour($styleAttributes['PatternColor']);
$RGB2 = self::parseGnumericColour((string) $styleAttributes['PatternColor']);
if ($shade === '1') {
$styleArray['fill']['startColor']['rgb'] = $RGB;
$styleArray['fill']['endColor']['rgb'] = $RGB2;
@ -234,8 +230,8 @@ class Styles
private function readStyle(array $styleArray, SimpleXMLElement $styleAttributes, SimpleXMLElement $style): array
{
self::addStyle2($styleArray, 'alignment', 'horizontal', $styleAttributes['HAlign']);
self::addStyle2($styleArray, 'alignment', 'vertical', $styleAttributes['VAlign']);
self::addStyle2($styleArray, 'alignment', 'horizontal', (string) $styleAttributes['HAlign']);
self::addStyle2($styleArray, 'alignment', 'vertical', (string) $styleAttributes['VAlign']);
$styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1';
$styleArray['alignment']['textRotation'] = $this->calcRotation($styleAttributes);
$styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1';
@ -250,7 +246,7 @@ class Styles
$styleArray['font']['bold'] = $fontAttributes['Bold'] == '1';
$styleArray['font']['italic'] = $fontAttributes['Italic'] == '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']) {
case '1':

View File

@ -65,7 +65,7 @@ class Ods extends BaseReader
$manifest = $xml->children($namespacesContent['manifest']);
foreach ($manifest as $manifestDataSet) {
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') {
if ($manifestAttributes && $manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'};
break;
@ -357,7 +357,7 @@ class Ods extends BaseReader
break;
case 'table-row':
if ($childNode->hasAttributeNS($tableNs, 'number-rows-repeated')) {
$rowRepeats = $childNode->getAttributeNS($tableNs, 'number-rows-repeated');
$rowRepeats = (int) $childNode->getAttributeNS($tableNs, 'number-rows-repeated');
} else {
$rowRepeats = 1;
}
@ -514,7 +514,7 @@ class Ods extends BaseReader
$dataValue = Date::PHPToExcel(
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;
@ -632,6 +632,7 @@ class Ods extends BaseReader
if ($zip->locateName('settings.xml') !== false) {
$this->processSettings($zip, $spreadsheet);
}
// Return
return $spreadsheet;
}

View File

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

View File

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

View File

@ -89,7 +89,7 @@ class AutoFilter
$customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join;
// 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);
}
foreach ($customFilters->customFilter as $filterRule) {
@ -130,12 +130,12 @@ class AutoFilter
// We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) {
$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_BY_VALUE
),
(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_BOTTOM
)

View File

@ -31,7 +31,9 @@ class Chart
} elseif ($format == 'integer') {
return (int) $attributes[$name];
} 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];
@ -482,7 +484,7 @@ class Chart
}
$fontSize = (self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'));
if ($fontSize !== null) {
if (is_int($fontSize)) {
$objText->getFont()->setSize(floor($fontSize / 100));
}

View File

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

View File

@ -361,7 +361,7 @@ class Xml extends BaseReader
$columnTo = $columnID;
if (isset($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;
if (isset($cell_ss['MergeDown'])) {

View File

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

View File

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

View File

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

View File

@ -112,7 +112,7 @@ class Font
*
* @var string
*/
private static $trueTypeFontPath = null;
private static $trueTypeFontPath;
/**
* 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.
*
* @return ConditionalDataBar | null
* @return null|ConditionalDataBar
*/
public function getDataBar()
{

View File

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

View File

@ -65,13 +65,16 @@ class UnparsedDataTest extends TestCase
// xl/workbook.xml
$xmlWorkbook = simplexml_load_string($resultWorkbookRaw, 'SimpleXMLElement', Settings::getLibXmlLoaderOptions());
self::assertNotFalse($xmlWorkbook);
if (!$xmlWorkbook->workbookProtection) {
self::fail('workbook.xml/workbookProtection not found!');
} else {
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::assertNotNull($xmlWorkbook->sheets->sheet[0]);
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!');
}
unset($xmlWorkbook);