Merge pull request #2858 from PHPOffice/PhpStan-Cleanups

Declare a few return datatypes
This commit is contained in:
Mark Baker 2022-05-26 15:28:07 +02:00 committed by GitHub
commit daffce00d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 34 deletions

View File

@ -2265,11 +2265,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:boolean\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:boolean\\(\\) has parameter \\$value with no type specified\\.$#"
count: 1
@ -2340,11 +2335,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:dirAdd\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:dirAdd\\(\\) has parameter \\$add with no type specified\\.$#"
count: 1
@ -2405,21 +2395,11 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:stripWhiteSpaceFromStyleString\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:stripWhiteSpaceFromStyleString\\(\\) has parameter \\$string with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:toCSSArray\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\Xlsx\\:\\:toCSSArray\\(\\) has parameter \\$style with no type specified\\.$#"
count: 1
@ -4885,8 +4865,3 @@ parameters:
count: 2
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Xlfn\\:\\:addXlfn\\(\\) should return string but returns string\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php

View File

@ -14,7 +14,7 @@ class Trim
* @param mixed $stringValue String Value to check
* Or can be an array of values
*
* @return null|array|string
* @return array|string
* If an array of values is passed as the argument, then the returned result will also be an array
* with the same dimensions
*/
@ -26,7 +26,7 @@ class Trim
$stringValue = Helpers::extractString($stringValue);
return preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
return (string) preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
}
/**

View File

@ -1461,7 +1461,7 @@ class Xlsx extends BaseReader
}
// unparsed drawing AlternateContent
$xmlAltDrawing = $this->loadZip($fileDrawing, Namespaces::COMPATIBILITY);
$xmlAltDrawing = $this->loadZip((string) $fileDrawing, Namespaces::COMPATIBILITY);
if ($xmlAltDrawing->AlternateContent) {
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
@ -1821,12 +1821,12 @@ class Xlsx extends BaseReader
return $array[$key] ?? null;
}
private static function dirAdd($base, $add)
private static function dirAdd($base, $add): string
{
return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
return (string) preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
}
private static function toCSSArray($style)
private static function toCSSArray($style): array
{
$style = self::stripWhiteSpaceFromStyleString($style);
@ -1857,12 +1857,12 @@ class Xlsx extends BaseReader
return $style;
}
public static function stripWhiteSpaceFromStyleString($string)
public static function stripWhiteSpaceFromStyleString($string): string
{
return trim(str_replace(["\r", "\n", ' '], '', $string), ';');
}
private static function boolean($value)
private static function boolean($value): bool
{
if (is_object($value)) {
$value = (string) $value;

View File

@ -152,7 +152,7 @@ class Xlfn
*/
public static function addXlfn(string $funcstring): string
{
return preg_replace(self::XLFNREGEXP, '_xlfn.$1', $funcstring);
return (string) preg_replace(self::XLFNREGEXP, '_xlfn.$1', $funcstring);
}
/**