Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpUnit 10 Compatibility Part 1 #3523

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4250,7 +4250,7 @@ private function internalParseFormula($formula, ?Cell $cell = null)
} elseif ($expectedArgumentCount != '*') {
$isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/', $expectedArgumentCount, $argMatch);
self::doNothing($isOperandOrFunction);
switch ($argMatch[2]) {
switch ($argMatch[2] ?? '') {
case '+':
if ($argumentCount < $argMatch[1]) {
$argumentCountError = true;
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function loadZip(string $filename, string $ns = '', bool $replaceUnclose
if ($replaceUnclosedBr) {
$contents = str_replace('<br>', '<br/>', $contents);
}
$rels = simplexml_load_string(
$rels = @simplexml_load_string(
$this->getSecurityScannerOrThrow()->scan($contents),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testNamedFormulaeCalculationsWithAdjustedRateValue(string $cellA
self::assertSame($expectedValue, $calculatedCellValue, "Failed calculation for cell {$cellAddress}");
}

public function namedRangeCalculationTest1(): array
public static function namedRangeCalculationTest1(): array
{
return [
['C4', 56.25],
Expand All @@ -84,7 +84,7 @@ public function namedRangeCalculationTest1(): array
];
}

public function namedRangeCalculationTest2(): array
public static function namedRangeCalculationTest2(): array
{
return [
['C4', 93.75],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public function testDAverageAsWorksheetFormula($expectedResult, array $database,
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
}

public function providerDAverage(): array
public static function providerDAverage(): array
{
return [
[
12,
$this->database1(),
self::database1(),
'Yield',
[
['Tree', 'Height'],
Expand All @@ -49,7 +49,7 @@ public function providerDAverage(): array
],
[
268333.333333333333,
$this->database2(),
self::database2(),
'Sales',
[
['Quarter', 'Sales Rep.'],
Expand All @@ -58,7 +58,7 @@ public function providerDAverage(): array
],
[
372500,
$this->database2(),
self::database2(),
'Sales',
[
['Quarter', 'Area'],
Expand All @@ -67,25 +67,25 @@ public function providerDAverage(): array
],
'numeric column, in this case referring to age' => [
13,
$this->database1(),
self::database1(),
3,
$this->database1(),
self::database1(),
],
'null field' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
null,
$this->database1(),
self::database1(),
],
'field unknown column' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
'xyz',
$this->database1(),
self::database1(),
],
'multiple criteria, omit equal sign' => [
10.5,
$this->database1(),
self::database1(),
'Yield',
[
['Tree', 'Height'],
Expand All @@ -95,7 +95,7 @@ public function providerDAverage(): array
],
'multiple criteria for same field' => [
10,
$this->database1(),
self::database1(),
'Yield',
[
['Tree', 'Height', 'Age', 'Height'],
Expand All @@ -108,15 +108,15 @@ public function providerDAverage(): array
content to return #VALUE! as an invalid name would */
'field column number too high' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
99,
$this->database1(),
self::database1(),
],
'field column number too low' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
0,
$this->database1(),
self::database1(),
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function testDCountAAsWorksheetFormula($expectedResult, $database, $field
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
}

public function providerDCountA(): array
public static function providerDCountA(): array
{
return [
[
1,
$this->database1(),
self::database1(),
'Profit',
[
['Tree', 'Height', 'Height'],
Expand All @@ -51,7 +51,7 @@ public function providerDCountA(): array
],
[
2,
$this->database3(),
self::database3(),
'Score',
[
['Subject', 'Gender'],
Expand All @@ -60,7 +60,7 @@ public function providerDCountA(): array
],
[
1,
$this->database3(),
self::database3(),
'Score',
[
['Subject', 'Gender'],
Expand All @@ -69,7 +69,7 @@ public function providerDCountA(): array
],
[
3,
$this->database3(),
self::database3(),
'Score',
[
['Subject', 'Score'],
Expand All @@ -78,7 +78,7 @@ public function providerDCountA(): array
],
'invalid field name' => [
ExcelError::VALUE(),
$this->database3(),
self::database3(),
'Scorex',
[
['Subject', 'Score'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testDCountAsWorksheetFormula($expectedResult, $database, $field,
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
}

private function database4(): array
private static function database4(): array
{
return [
['Status', 'Value'],
Expand All @@ -52,12 +52,12 @@ private function database4(): array
];
}

public function providerDCount(): array
public static function providerDCount(): array
{
return [
[
1,
$this->database1(),
self::database1(),
'Age',
[
['Tree', 'Height', 'Height'],
Expand All @@ -66,7 +66,7 @@ public function providerDCount(): array
],
[
1,
$this->database3(),
self::database3(),
'Score',
[
['Subject', 'Gender'],
Expand All @@ -75,7 +75,7 @@ public function providerDCount(): array
],
[
1,
$this->database3(),
self::database3(),
'Score',
[
['Subject', 'Gender'],
Expand All @@ -84,7 +84,7 @@ public function providerDCount(): array
],
[
3,
$this->database4(),
self::database4(),
'Value',
[
['Status'],
Expand All @@ -93,7 +93,7 @@ public function providerDCount(): array
],
[
5,
$this->database4(),
self::database4(),
'Value',
[
['Status'],
Expand All @@ -102,13 +102,13 @@ public function providerDCount(): array
],
'field column number okay' => [
0,
$this->database1(),
self::database1(),
1,
$this->database1(),
self::database1(),
],
'omitted field name' => [
ExcelError::VALUE(),
$this->database3(),
self::database3(),
null,
[
['Subject', 'Score'],
Expand All @@ -121,15 +121,15 @@ public function providerDCount(): array
content to return #VALUE! as an invalid name would */
'field column number too high' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
99,
$this->database1(),
self::database1(),
],
'field column number too low' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
0,
$this->database1(),
self::database1(),
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function testDGetAsWorksheetFormula($expectedResult, $database, $field, $
self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12);
}

public function providerDGet(): array
public static function providerDGet(): array
{
return [
[
ExcelError::NAN(),
$this->database1(),
self::database1(),
'Yield',
[
['Tree'],
Expand All @@ -52,7 +52,7 @@ public function providerDGet(): array
],
[
10,
$this->database1(),
self::database1(),
'Yield',
[
['Tree', 'Height', 'Height'],
Expand All @@ -62,7 +62,7 @@ public function providerDGet(): array
],
[
188000,
$this->database2(),
self::database2(),
'Sales',
[
['Sales Rep.', 'Quarter'],
Expand All @@ -71,7 +71,7 @@ public function providerDGet(): array
],
[
ExcelError::NAN(),
$this->database2(),
self::database2(),
'Sales',
[
['Area', 'Quarter'],
Expand All @@ -80,9 +80,9 @@ public function providerDGet(): array
],
'omitted field name' => [
ExcelError::VALUE(),
$this->database1(),
self::database1(),
null,
$this->database1(),
self::database1(),
],
];
}
Expand Down
Loading