mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-17 21:46:37 +00:00
Merge branch 'master' into 2.0-Development
# Conflicts: # phpstan-baseline.neon
This commit is contained in:
+12
-2
@@ -296,9 +296,19 @@ parameters:
|
||||
path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$callback of function set_error_handler expects \\(callable\\(int, string, string, int, array\\)\\: bool\\)\\|null, array\\{'PhpOffice\\\\\\\\PhpSpreadsheet\\\\\\\\Calculation\\\\\\\\Exception', 'errorHandlerCallback'\\} given\\.$#"
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:ISPMT\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/ExceptionHandler.php
|
||||
path: src/PhpSpreadsheet/Calculation/Financial.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:ISPMT\\(\\) has parameter \\$args with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\:\\:NPV\\(\\) has parameter \\$args with no type specified\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/Financial.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:isLeapYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
|
||||
|
||||
@@ -46,6 +46,13 @@ if (PHP_VERSION_ID < 80000) {
|
||||
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/StringHelper.php',
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Flagged in Php8+ - unsure how to correct code
|
||||
$config['parameters']['ignoreErrors'][] = [
|
||||
'message' => '#^Binary operation "/" between float and array[|]float[|]int[|]string results in an error.#',
|
||||
'path' => __DIR__ . '/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php',
|
||||
'count' => 2,
|
||||
];
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
||||
@@ -20,7 +20,7 @@ trait ArrayEnabled
|
||||
if (self::$arrayArgumentHelper === null) {
|
||||
self::$arrayArgumentHelper = new ArrayArgumentHelper();
|
||||
}
|
||||
self::$arrayArgumentHelper->initialise($arguments ?: []);
|
||||
self::$arrayArgumentHelper->initialise(($arguments === false) ? [] : $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,9 @@ class ExceptionHandler
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
set_error_handler([Exception::class, 'errorHandlerCallback'], E_ALL);
|
||||
/** @var callable */
|
||||
$callable = [Exception::class, 'errorHandlerCallback'];
|
||||
set_error_handler($callable, E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -795,7 +795,7 @@ class Html
|
||||
$domText = preg_replace(
|
||||
'/\s+/u',
|
||||
' ',
|
||||
str_replace(["\r", "\n"], ' ', $textNode->nodeValue ?: '')
|
||||
str_replace(["\r", "\n"], ' ', $textNode->nodeValue ?? '')
|
||||
);
|
||||
$this->stringData .= $domText;
|
||||
$this->buildTextRun();
|
||||
|
||||
@@ -580,7 +580,7 @@ class Html extends BaseReader
|
||||
{
|
||||
foreach ($element->childNodes as $child) {
|
||||
if ($child instanceof DOMText) {
|
||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue ?: ''));
|
||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue ?? ''));
|
||||
if (is_string($cellContent)) {
|
||||
// simply append the text if the cell content is a plain text string
|
||||
$cellContent .= $domText;
|
||||
|
||||
@@ -325,7 +325,7 @@ class Ods extends BaseReader
|
||||
}
|
||||
$spreadsheet->setActiveSheetIndex($worksheetID);
|
||||
|
||||
if ($worksheetName) {
|
||||
if ($worksheetName || is_numeric($worksheetName)) {
|
||||
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
|
||||
// formula cells... during the load, all formulae should be correct, and we're simply
|
||||
// bringing the worksheet name in line with the formula, not the reverse
|
||||
@@ -628,7 +628,7 @@ class Ods extends BaseReader
|
||||
foreach ($settings->getElementsByTagNameNS($configNs, 'config-item') as $t) {
|
||||
if ($t->getAttributeNs($configNs, 'name') === 'ActiveTable') {
|
||||
try {
|
||||
$spreadsheet->setActiveSheetIndexByName($t->nodeValue ?: '');
|
||||
$spreadsheet->setActiveSheetIndexByName($t->nodeValue ?? '');
|
||||
} catch (Throwable $e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ class Slk extends BaseReader
|
||||
|
||||
break;
|
||||
case 'M':
|
||||
$formatArray['font']['size'] = substr($rowDatum, 1) / 20;
|
||||
$formatArray['font']['size'] = ((float) substr($rowDatum, 1)) / 20;
|
||||
|
||||
break;
|
||||
case 'L':
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
|
||||
|
||||
class MD5
|
||||
{
|
||||
// Context
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -26,11 +24,17 @@ class MD5
|
||||
*/
|
||||
private $d;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private static $allOneBits;
|
||||
|
||||
/**
|
||||
* MD5 stream constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::$allOneBits = self::signedInt(0xffffffff);
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -40,8 +44,8 @@ class MD5
|
||||
public function reset(): void
|
||||
{
|
||||
$this->a = 0x67452301;
|
||||
$this->b = 0xEFCDAB89;
|
||||
$this->c = 0x98BADCFE;
|
||||
$this->b = self::signedInt(0xEFCDAB89);
|
||||
$this->c = self::signedInt(0x98BADCFE);
|
||||
$this->d = 0x10325476;
|
||||
}
|
||||
|
||||
@@ -156,10 +160,10 @@ class MD5
|
||||
self::step($I, $C, $D, $A, $B, $words[2], 15, 0x2ad7d2bb);
|
||||
self::step($I, $B, $C, $D, $A, $words[9], 21, 0xeb86d391);
|
||||
|
||||
$this->a = ($this->a + $A) & 0xffffffff;
|
||||
$this->b = ($this->b + $B) & 0xffffffff;
|
||||
$this->c = ($this->c + $C) & 0xffffffff;
|
||||
$this->d = ($this->d + $D) & 0xffffffff;
|
||||
$this->a = ($this->a + $A) & self::$allOneBits;
|
||||
$this->b = ($this->b + $B) & self::$allOneBits;
|
||||
$this->c = ($this->c + $C) & self::$allOneBits;
|
||||
$this->d = ($this->d + $D) & self::$allOneBits;
|
||||
}
|
||||
|
||||
private static function f(int $X, int $Y, int $Z): int
|
||||
@@ -182,18 +186,25 @@ class MD5
|
||||
return $Y ^ ($X | (~$Z)); // Y XOR (X OR NOT Z)
|
||||
}
|
||||
|
||||
private static function step(callable $func, int &$A, int $B, int $C, int $D, int $M, int $s, int $t): void
|
||||
/** @param float|int $t may be float on 32-bit system */
|
||||
private static function step(callable $func, int &$A, int $B, int $C, int $D, int $M, int $s, $t): void
|
||||
{
|
||||
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & 0xffffffff;
|
||||
$t = self::signedInt($t);
|
||||
$A = ($A + call_user_func($func, $B, $C, $D) + $M + $t) & self::$allOneBits;
|
||||
$A = self::rotate($A, $s);
|
||||
$A = ($B + $A) & 0xffffffff;
|
||||
$A = ($B + $A) & self::$allOneBits;
|
||||
}
|
||||
|
||||
/** @return float|int */
|
||||
private static function rotate(int $decimal, int $bits)
|
||||
/** @param float|int $result may be float on 32-bit system */
|
||||
private static function signedInt($result): int
|
||||
{
|
||||
return is_int($result) ? $result : (int) (PHP_INT_MIN + $result - 1 - PHP_INT_MAX);
|
||||
}
|
||||
|
||||
private static function rotate(int $decimal, int $bits): int
|
||||
{
|
||||
$binary = str_pad(decbin($decimal), 32, '0', STR_PAD_LEFT);
|
||||
|
||||
return bindec(substr($binary, $bits) . substr($binary, 0, $bits));
|
||||
return self::signedInt(bindec(substr($binary, $bits) . substr($binary, 0, $bits)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ class HtmlTest extends TestCase
|
||||
['können', 'können'],
|
||||
['русский', 'русский'],
|
||||
["foo\nbar", '<p>foo</p><p>bar</p>'],
|
||||
'issue2810' => ['0', '0'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Html;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue2810Test extends TestCase
|
||||
{
|
||||
// Reader has been converting falsey values to null
|
||||
public function testIssue2810(): void
|
||||
{
|
||||
$content = <<<'EOF'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Declaracion en Linea</title>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>2</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
EOF;
|
||||
$reader = new Html();
|
||||
$spreadsheet = $reader->loadFromString($content);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
self::assertSame(1, $sheet->getCell('A1')->getValue());
|
||||
self::assertSame(0, $sheet->getCell('B1')->getValue());
|
||||
self::assertSame(2, $sheet->getCell('C1')->getValue());
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Ods;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue2810Test extends TestCase
|
||||
{
|
||||
public function testIssue2810(): void
|
||||
{
|
||||
// Active sheet with title of '0' wasn't found
|
||||
$filename = 'tests/data/Reader/Ods/issue.2810.ods';
|
||||
$reader = new Ods();
|
||||
$spreadsheet = $reader->load($filename);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
self::assertSame('Active', $sheet->getCell('A1')->getValue());
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user