Fix for null value passed to extractSheetTitle()

This commit is contained in:
MarkBaker 2022-05-11 16:06:19 +02:00
parent 070bc68514
commit 153a3a6af6
2 changed files with 20 additions and 11 deletions

View File

@ -95,6 +95,11 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
-
message: "#^Negated boolean expression is always true\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Offset 'type' does not exist on array\\|null\\.$#" message: "#^Offset 'type' does not exist on array\\|null\\.$#"
count: 3 count: 3
@ -2290,6 +2295,11 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
-
message: "#^Right side of && is always true\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xls.php
- -
message: "#^Unreachable statement \\- code above always terminates\\.$#" message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 8 count: 8
@ -3000,6 +3010,11 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php path: src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php
-
message: "#^Right side of && is always true\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx/Styles.php
- -
message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given\\.$#" message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given\\.$#"
count: 1 count: 1
@ -4197,7 +4212,7 @@ parameters:
- -
message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#"
count: 1 count: 2
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
@ -5240,11 +5255,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
- -
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#" message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int\\|string given\\.$#"
count: 1 count: 1
@ -5285,11 +5295,6 @@ parameters:
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Strict comparison using \\=\\=\\= between false and true will always evaluate to false\\.$#"
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Xlfn\\:\\:addXlfn\\(\\) should return string but returns string\\|null\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Xlfn\\:\\:addXlfn\\(\\) should return string but returns string\\|null\\.$#"
count: 1 count: 1

View File

@ -3011,6 +3011,10 @@ class Worksheet implements IComparable
*/ */
public static function extractSheetTitle($range, $returnRange = false) public static function extractSheetTitle($range, $returnRange = false)
{ {
if ($range === null) {
return $returnRange ? [null, null] : null;
}
// Sheet title included? // Sheet title included?
if (($sep = strrpos($range, '!')) === false) { if (($sep = strrpos($range, '!')) === false) {
return $returnRange ? ['', $range] : ''; return $returnRange ? ['', $range] : '';