mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-16 13:06:31 +00:00
Catch Phpstan Up
Its last few updates have been irksome. I need to eliminate more of the new problems with annotations rather than code because I can't figure out what it's objecting to. Nevertheless, it provides a very valuable service, so ... Its latest release is flagging calling abs with a string, even when the string is defined as numeric-string in a doc block. Php generally allows it, though not with strict types. Changed to add 0 in those situations.
This commit is contained in:
Generated
+5
-5
@@ -1789,16 +1789,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.12.0",
|
||||
"version": "1.12.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "384af967d35b2162f69526c7276acadce534d0e1"
|
||||
"reference": "ceb937fb39a92deabc02d20709cf14b2c452502c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/384af967d35b2162f69526c7276acadce534d0e1",
|
||||
"reference": "384af967d35b2162f69526c7276acadce534d0e1",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/ceb937fb39a92deabc02d20709cf14b2c452502c",
|
||||
"reference": "ceb937fb39a92deabc02d20709cf14b2c452502c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1843,7 +1843,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-08-27T09:18:05+00:00"
|
||||
"time": "2024-11-10T17:10:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
|
||||
@@ -4149,9 +4149,9 @@ class Calculation
|
||||
$expectedArgumentCountString = null;
|
||||
if (is_numeric($expectedArgumentCount)) {
|
||||
if ($expectedArgumentCount < 0) {
|
||||
if ($argumentCount > abs($expectedArgumentCount)) {
|
||||
if ($argumentCount > abs($expectedArgumentCount + 0)) {
|
||||
$argumentCountError = true;
|
||||
$expectedArgumentCountString = 'no more than ' . abs($expectedArgumentCount);
|
||||
$expectedArgumentCountString = 'no more than ' . abs($expectedArgumentCount + 0);
|
||||
}
|
||||
} else {
|
||||
if ($argumentCount != $expectedArgumentCount) {
|
||||
@@ -4236,7 +4236,7 @@ class Calculation
|
||||
// do we now have a function/variable/number?
|
||||
$expectingOperator = true;
|
||||
$expectingOperand = false;
|
||||
$val = $match[1] ?? '';
|
||||
$val = $match[1] ?? ''; //* @phpstan-ignore-line
|
||||
$length = strlen($val);
|
||||
|
||||
if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $val, $matches)) {
|
||||
|
||||
@@ -221,7 +221,7 @@ class BitWise
|
||||
$value = self::nullFalseTrueToNumber($value);
|
||||
|
||||
if (is_numeric($value)) {
|
||||
if (abs($value) > 53) {
|
||||
if (abs($value + 0) > 53) {
|
||||
throw new Exception(ExcelError::NAN());
|
||||
}
|
||||
|
||||
|
||||
@@ -239,6 +239,7 @@ class NonPeriodic
|
||||
return $rslt;
|
||||
}
|
||||
|
||||
/** @param array<int,float|int|numeric-string> $values> */
|
||||
private static function xnpvOrdered(mixed $rate, mixed $values, mixed $dates, bool $ordered = true, bool $capAtNegative1 = false): float|string
|
||||
{
|
||||
$rate = Functions::flattenSingleValue($rate);
|
||||
@@ -276,7 +277,7 @@ class NonPeriodic
|
||||
return $dif;
|
||||
}
|
||||
if ($rate <= -1.0) {
|
||||
$xnpv += -abs($values[$i]) / (-1 - $rate) ** ($dif / 365);
|
||||
$xnpv += -abs($values[$i] + 0) / (-1 - $rate) ** ($dif / 365);
|
||||
} else {
|
||||
$xnpv += $values[$i] / (1 + $rate) ** ($dif / 365);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ class Xls extends XlsBase
|
||||
* The current MD5 context state.
|
||||
* It is never set in the program, so code which uses it is suspect.
|
||||
*/
|
||||
private string $md5Ctxt; // @phpstan-ignore-line
|
||||
private string $md5Ctxt = '';
|
||||
|
||||
protected int $textObjRef;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class ChainedBlockStream
|
||||
}
|
||||
}
|
||||
if (isset($this->params['size'])) {
|
||||
$this->data = substr($this->data, 0, $this->params['size']);
|
||||
$this->data = substr($this->data, 0, $this->params['size']); //* @phpstan-ignore-line
|
||||
}
|
||||
|
||||
if ($options & STREAM_USE_PATH) {
|
||||
|
||||
@@ -159,7 +159,7 @@ class PolynomialBestFit extends BestFit
|
||||
$coefficients = [];
|
||||
for ($i = 0; $i < $C->rows; ++$i) {
|
||||
$r = $C->getValue($i + 1, 1); // row and column are origin-1
|
||||
if (!is_numeric($r) || abs($r) <= 10 ** (-9)) {
|
||||
if (!is_numeric($r) || abs($r + 0) <= 10 ** (-9)) {
|
||||
$r = 0;
|
||||
} else {
|
||||
$r += 0;
|
||||
|
||||
@@ -42,7 +42,7 @@ class Formatter extends BaseFormatter
|
||||
};
|
||||
}
|
||||
|
||||
/** @param float|int|string $value value to be formatted */
|
||||
/** @param float|int|numeric-string $value value to be formatted */
|
||||
private static function splitFormatForSectionSelection(array $sections, mixed $value): array
|
||||
{
|
||||
// Extract the relevant section depending on whether number is positive, negative, or zero?
|
||||
@@ -79,7 +79,7 @@ class Formatter extends BaseFormatter
|
||||
$absval = $value;
|
||||
switch ($sectionCount) {
|
||||
case 2:
|
||||
$absval = abs($value);
|
||||
$absval = abs($value + 0);
|
||||
if (!self::splitFormatComparison($value, $conditionOperations[0], $conditionComparisonValues[0], '>=', 0)) {
|
||||
$color = $colors[1];
|
||||
$format = $sections[1];
|
||||
@@ -88,7 +88,7 @@ class Formatter extends BaseFormatter
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
$absval = abs($value);
|
||||
$absval = abs($value + 0);
|
||||
if (!self::splitFormatComparison($value, $conditionOperations[0], $conditionComparisonValues[0], '>', 0)) {
|
||||
if (self::splitFormatComparison($value, $conditionOperations[1], $conditionComparisonValues[1], '<', 0)) {
|
||||
$color = $colors[1];
|
||||
|
||||
@@ -2362,7 +2362,7 @@ class Worksheet extends BIFFwriter
|
||||
*
|
||||
* @param GdImage $image The image to process
|
||||
*
|
||||
* @return array Array with data and properties of the bitmap
|
||||
* @return array{0: float, 1: float, 2: int, 3: string} Data and properties of the bitmap
|
||||
*/
|
||||
public function processBitmapGd(GdImage $image): array
|
||||
{
|
||||
@@ -2372,9 +2372,9 @@ class Worksheet extends BIFFwriter
|
||||
$data = pack('Vvvvv', 0x000C, $width, $height, 0x01, 0x18);
|
||||
for ($j = $height; --$j;) {
|
||||
for ($i = 0; $i < $width; ++$i) {
|
||||
/** @phpstan-ignore-next-line */
|
||||
$color = imagecolorsforindex($image, imagecolorat($image, $i, $j));
|
||||
if ($color !== false) {
|
||||
$colorAt = imagecolorat($image, $i, $j);
|
||||
if ($colorAt !== false) {
|
||||
$color = imagecolorsforindex($image, $colorAt);
|
||||
foreach (['red', 'green', 'blue'] as $key) {
|
||||
$color[$key] = $color[$key] + (int) round((255 - $color[$key]) * $color['alpha'] / 127);
|
||||
}
|
||||
@@ -2385,8 +2385,11 @@ class Worksheet extends BIFFwriter
|
||||
$data .= str_repeat("\x00", 4 - 3 * $width % 4);
|
||||
}
|
||||
}
|
||||
// Phpstan says this always throws an exception before getting here.
|
||||
// I don't see why, but I think this is code is never exercised
|
||||
// in unit tests, so I can't say for sure it's wrong.
|
||||
|
||||
return [$width, $height, strlen($data), $data];
|
||||
return [$width, $height, strlen($data), $data]; //* @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user