Skip to content

Commit 8089c9b

Browse files
author
MarkBaker
committed
Declare a few return datatypes
1 parent dfd0432 commit 8089c9b

File tree

4 files changed

+9
-34
lines changed

4 files changed

+9
-34
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,11 +2265,6 @@ parameters:
22652265
count: 1
22662266
path: src/PhpSpreadsheet/Reader/Xlsx.php
22672267

2268-
-
2269-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:boolean\\(\\) has no return type specified\\.$#"
2270-
count: 1
2271-
path: src/PhpSpreadsheet/Reader/Xlsx.php
2272-
22732268
-
22742269
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:boolean\\(\\) has parameter \\$value with no type specified\\.$#"
22752270
count: 1
@@ -2340,11 +2335,6 @@ parameters:
23402335
count: 1
23412336
path: src/PhpSpreadsheet/Reader/Xlsx.php
23422337

2343-
-
2344-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:dirAdd\\(\\) has no return type specified\\.$#"
2345-
count: 1
2346-
path: src/PhpSpreadsheet/Reader/Xlsx.php
2347-
23482338
-
23492339
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:dirAdd\\(\\) has parameter \\$add with no type specified\\.$#"
23502340
count: 1
@@ -2405,21 +2395,11 @@ parameters:
24052395
count: 1
24062396
path: src/PhpSpreadsheet/Reader/Xlsx.php
24072397

2408-
-
2409-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:stripWhiteSpaceFromStyleString\\(\\) has no return type specified\\.$#"
2410-
count: 1
2411-
path: src/PhpSpreadsheet/Reader/Xlsx.php
2412-
24132398
-
24142399
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:stripWhiteSpaceFromStyleString\\(\\) has parameter \\$string with no type specified\\.$#"
24152400
count: 1
24162401
path: src/PhpSpreadsheet/Reader/Xlsx.php
24172402

2418-
-
2419-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:toCSSArray\\(\\) has no return type specified\\.$#"
2420-
count: 1
2421-
path: src/PhpSpreadsheet/Reader/Xlsx.php
2422-
24232403
-
24242404
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:toCSSArray\\(\\) has parameter \\$style with no type specified\\.$#"
24252405
count: 1
@@ -4885,8 +4865,3 @@ parameters:
48854865
count: 2
48864866
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
48874867

4888-
-
4889-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Xlfn\\:\\:addXlfn\\(\\) should return string but returns string\\|null\\.$#"
4890-
count: 1
4891-
path: src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php
4892-

src/PhpSpreadsheet/Calculation/TextData/Trim.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Trim
1414
* @param mixed $stringValue String Value to check
1515
* Or can be an array of values
1616
*
17-
* @return null|array|string
17+
* @return array|string
1818
* If an array of values is passed as the argument, then the returned result will also be an array
1919
* with the same dimensions
2020
*/
@@ -26,7 +26,7 @@ public static function nonPrintable($stringValue = '')
2626

2727
$stringValue = Helpers::extractString($stringValue);
2828

29-
return preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
29+
return (string) preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
3030
}
3131

3232
/**

src/PhpSpreadsheet/Reader/Xlsx.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
14611461
}
14621462

14631463
// unparsed drawing AlternateContent
1464-
$xmlAltDrawing = $this->loadZip($fileDrawing, Namespaces::COMPATIBILITY);
1464+
$xmlAltDrawing = $this->loadZip((string) $fileDrawing, Namespaces::COMPATIBILITY);
14651465

14661466
if ($xmlAltDrawing->AlternateContent) {
14671467
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
@@ -1821,12 +1821,12 @@ private static function getArrayItem($array, $key = 0)
18211821
return $array[$key] ?? null;
18221822
}
18231823

1824-
private static function dirAdd($base, $add)
1824+
private static function dirAdd($base, $add): string
18251825
{
1826-
return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
1826+
return (string) preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
18271827
}
18281828

1829-
private static function toCSSArray($style)
1829+
private static function toCSSArray($style): array
18301830
{
18311831
$style = self::stripWhiteSpaceFromStyleString($style);
18321832

@@ -1857,12 +1857,12 @@ private static function toCSSArray($style)
18571857
return $style;
18581858
}
18591859

1860-
public static function stripWhiteSpaceFromStyleString($string)
1860+
public static function stripWhiteSpaceFromStyleString($string): string
18611861
{
18621862
return trim(str_replace(["\r", "\n", ' '], '', $string), ';');
18631863
}
18641864

1865-
private static function boolean($value)
1865+
private static function boolean($value): bool
18661866
{
18671867
if (is_object($value)) {
18681868
$value = (string) $value;

src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Xlfn
152152
*/
153153
public static function addXlfn(string $funcstring): string
154154
{
155-
return preg_replace(self::XLFNREGEXP, '_xlfn.$1', $funcstring);
155+
return (string) preg_replace(self::XLFNREGEXP, '_xlfn.$1', $funcstring);
156156
}
157157

158158
/**

0 commit comments

Comments
 (0)