mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-14 20:16:34 +00:00
Cleanup for Phpstan, PHP-CS-Fixer Upgrades (#3632)
* Cleanup for Phpstan, PHP-CS-Fixer Upgrades Dependabot wanted to upgrade, but changes resulted in new "errors". Fix them. * Scrutinizer It says value must be numeric; Phpstan says it might not be. Try to reconcile them.
This commit is contained in:
Generated
+11
-11
@@ -1239,16 +1239,16 @@
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.17.0",
|
||||
"version": "v3.20.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "3f0ed862f22386c55a767461ef5083bddceeed79"
|
||||
"reference": "0e8249e0b15e2bc022fbbd1090ce29d071481e69"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/3f0ed862f22386c55a767461ef5083bddceeed79",
|
||||
"reference": "3f0ed862f22386c55a767461ef5083bddceeed79",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/0e8249e0b15e2bc022fbbd1090ce29d071481e69",
|
||||
"reference": "0e8249e0b15e2bc022fbbd1090ce29d071481e69",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1323,7 +1323,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.17.0"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.20.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -1331,7 +1331,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-05-22T19:59:32+00:00"
|
||||
"time": "2023-06-27T20:22:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "masterminds/html5",
|
||||
@@ -1999,16 +1999,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.10.15",
|
||||
"version": "1.10.22",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd"
|
||||
"reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/762c4dac4da6f8756eebb80e528c3a47855da9bd",
|
||||
"reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/97d694dfd4ceb57bcce4e3b38548f13ea62e4287",
|
||||
"reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2057,7 +2057,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-05-09T15:28:01+00:00"
|
||||
"time": "2023-06-30T20:04:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-phpunit",
|
||||
|
||||
@@ -5,7 +5,6 @@ use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Title;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
require __DIR__ . '/../Header.php';
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation;
|
||||
|
||||
use Complex\Complex;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexOperations;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Engineering;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
|
||||
class BesselK
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Engineering;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
|
||||
class BitWise
|
||||
|
||||
@@ -77,6 +77,12 @@ class Erf
|
||||
return self::ERF($limit);
|
||||
}
|
||||
|
||||
/** @param mixed $value */
|
||||
private static function makeFloat($value): float
|
||||
{
|
||||
return is_numeric($value) ? ((float) $value) : 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to calculate the erf value.
|
||||
*
|
||||
@@ -88,7 +94,7 @@ class Erf
|
||||
{
|
||||
$value = (float) $value;
|
||||
if (abs($value) > 2.2) {
|
||||
return 1 - ErfC::ERFC($value);
|
||||
return 1 - self::makeFloat(ErfC::ERFC($value));
|
||||
}
|
||||
$sum = $term = $value;
|
||||
$xsqr = ($value * $value);
|
||||
|
||||
@@ -11,7 +11,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Offset;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\VLookup;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
/**
|
||||
* @deprecated 1.18.0
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\Value;
|
||||
|
||||
class Sum
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ class Deviations
|
||||
if (!is_numeric($mean)) {
|
||||
return ExcelError::DIV0();
|
||||
}
|
||||
$stdDev = StandardDeviations::STDEV($aArgs);
|
||||
$stdDev = (float) StandardDeviations::STDEV($aArgs);
|
||||
|
||||
if ($stdDev > 0) {
|
||||
$count = $summer = 0;
|
||||
|
||||
@@ -96,7 +96,9 @@ class ChiSquared
|
||||
}
|
||||
|
||||
if ($cumulative === true) {
|
||||
return 1 - self::distributionRightTail($value, $degrees);
|
||||
$temp = self::distributionRightTail($value, $degrees);
|
||||
|
||||
return 1 - (is_numeric($temp) ? $temp : 0);
|
||||
}
|
||||
|
||||
return ($value ** (($degrees / 2) - 1) * exp(-$value / 2)) /
|
||||
|
||||
@@ -148,6 +148,12 @@ class StandardNormal
|
||||
|
||||
$sub1 = Averages::average($dataSet);
|
||||
|
||||
return is_numeric($sub1) ? (1 - self::cumulative(($sub1 - $m0) / ($sigma / sqrt($n)))) : $sub1;
|
||||
if (!is_numeric($sub1)) {
|
||||
return $sub1;
|
||||
}
|
||||
|
||||
$temp = self::cumulative(($sub1 - $m0) / ($sigma / sqrt($n)));
|
||||
|
||||
return 1 - (is_numeric($temp) ? $temp : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Cell;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ class MemoryDrawing extends BaseDrawing
|
||||
if (function_exists('getimagesize')) {
|
||||
$imageSize = @getimagesize($temporaryFileName);
|
||||
if (is_array($imageSize)) {
|
||||
$mimeType = $imageSize['mime'] ?? null;
|
||||
$mimeType = $imageSize['mime'] ?? null; // @phpstan-ignore-line
|
||||
|
||||
return self::supportedMimeTypes($mimeType);
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ class Html extends BaseWriter
|
||||
if ($this->embedImages || substr($imageData, 0, 6) === 'zip://') {
|
||||
$picture = @file_get_contents($filename);
|
||||
if ($picture !== false) {
|
||||
$imageDetails = getimagesize($filename) ?: [];
|
||||
$imageDetails = getimagesize($filename) ?: ['mime' => ''];
|
||||
// base64 encode the binary data
|
||||
$base64 = base64_encode($picture);
|
||||
$imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
|
||||
@@ -764,7 +764,7 @@ class Html extends BaseWriter
|
||||
}
|
||||
|
||||
$html .= PHP_EOL;
|
||||
$imageDetails = getimagesize($chartFileName) ?: [];
|
||||
$imageDetails = getimagesize($chartFileName) ?: ['', '', 'mime' => ''];
|
||||
$filedesc = $chart->getTitle();
|
||||
$filedesc = $filedesc ? $filedesc->getCaptionText() : '';
|
||||
$filedesc = $filedesc ? htmlspecialchars($filedesc, ENT_QUOTES) : 'Embedded chart';
|
||||
|
||||
@@ -7,7 +7,6 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Row;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\RowCellIterator;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Exception;
|
||||
|
||||
@@ -427,6 +427,8 @@ class Xls extends BaseWriter
|
||||
$bstoreContainer->addBSE($BSE);
|
||||
}
|
||||
|
||||
private static int $two = 2; // phpstan silliness
|
||||
|
||||
private function processDrawing(BstoreContainer &$bstoreContainer, Drawing $drawing): void
|
||||
{
|
||||
$blipType = 0;
|
||||
@@ -434,7 +436,7 @@ class Xls extends BaseWriter
|
||||
$filename = $drawing->getPath();
|
||||
|
||||
$imageSize = getimagesize($filename);
|
||||
$imageFormat = empty($imageSize) ? 0 : ($imageSize[2] ?? 0);
|
||||
$imageFormat = empty($imageSize) ? 0 : ($imageSize[self::$two] ?? 0);
|
||||
|
||||
switch ($imageFormat) {
|
||||
case 1: // GIF, not supported by BIFF8, we convert to PNG
|
||||
|
||||
@@ -208,6 +208,8 @@ class ContentTypes extends WriterPart
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
private static int $three = 3; // phpstan silliness
|
||||
|
||||
/**
|
||||
* Get image mime type.
|
||||
*
|
||||
@@ -220,7 +222,7 @@ class ContentTypes extends WriterPart
|
||||
if (File::fileExists($filename)) {
|
||||
$image = getimagesize($filename);
|
||||
|
||||
return image_type_to_mime_type((is_array($image) && count($image) >= 3) ? $image[2] : 0);
|
||||
return image_type_to_mime_type((is_array($image) && count($image) >= self::$three) ? $image[2] : 0);
|
||||
}
|
||||
|
||||
throw new WriterException("File $filename does not exist");
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\DateTime;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\DateTime;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
|
||||
use PhpOffice\PhpSpreadsheet\Chart\Title;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Document\Properties;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Ods;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\File;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class WorksheetInfoNamesTest extends TestCase
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace PhpOffice\PhpSpreadsheetTests;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Exception as SSException;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SpreadsheetCoverageTest extends TestCase
|
||||
|
||||
Reference in New Issue
Block a user