diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php index bb71ee6e..e95c3267 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationFunctionListTest.php @@ -41,7 +41,7 @@ class CalculationFunctionListTest extends TestCase * @param array|string $functionCall * @param string $argumentCount */ - public function testGetFunctions($category, $functionCall, $argumentCount): void + public function testGetFunctions(/** @scrutinizer ignore-unused */ $category, $functionCall, /** @scrutinizer ignore-unused */ $argumentCount): void { self::assertIsCallable($functionCall); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index 451908e0..827654ad 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -4,16 +4,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Engineering; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class ComplexTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerCOMPLEX * @@ -21,7 +15,15 @@ class ComplexTest extends TestCase */ public function testCOMPLEX($expectedResult, ...$args): void { - $result = Engineering::COMPLEX(...$args); + if (count($args) === 0) { + $result = Engineering::COMPLEX(); + } elseif (count($args) === 1) { + $result = Engineering::COMPLEX($args[0]); + } elseif (count($args) === 2) { + $result = Engineering::COMPLEX($args[0], $args[1]); + } else { + $result = Engineering::COMPLEX($args[0], $args[1], $args[2]); + } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php index cbb8e031..22d99eca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php @@ -4,16 +4,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class DollarDeTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerDOLLARDE * @@ -21,7 +15,13 @@ class DollarDeTest extends TestCase */ public function testDOLLARDE($expectedResult, ...$args): void { - $result = Financial::DOLLARDE(...$args); + if (count($args) === 0) { + $result = Financial::DOLLARDE(); + } elseif (count($args) === 1) { + $result = Financial::DOLLARDE($args[0]); + } else { + $result = Financial::DOLLARDE($args[0], $args[1]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php index ce74595a..79e3d5ca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class DollarFrTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerDOLLARFR * @@ -20,7 +14,13 @@ class DollarFrTest extends TestCase */ public function testDOLLARFR($expectedResult, ...$args): void { - $result = Financial::DOLLARFR(...$args); + if (count($args) === 0) { + $result = Financial::DOLLARFR(); + } elseif (count($args) === 1) { + $result = Financial::DOLLARFR($args[0]); + } else { + $result = Financial::DOLLARFR($args[0], $args[1]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php index 8d17d852..0e621766 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class FvTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerFV * @@ -20,7 +14,19 @@ class FvTest extends TestCase */ public function testFV($expectedResult, array $args): void { - $result = Financial::FV(...$args); + if (count($args) === 0) { + $result = Financial::FV(); + } elseif (count($args) === 1) { + $result = Financial::FV($args[0]); + } elseif (count($args) === 2) { + $result = Financial::FV($args[0], $args[1]); + } elseif (count($args) === 3) { + $result = Financial::FV($args[0], $args[1], $args[2]); + } elseif (count($args) === 4) { + $result = Financial::FV($args[0], $args[1], $args[2], $args[3]); + } else { + $result = Financial::FV($args[0], $args[1], $args[2], $args[3], $args[4]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php index 87230eca..2d7ded04 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NPerTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class NPerTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerNPER * @@ -20,7 +14,19 @@ class NPerTest extends TestCase */ public function testNPER($expectedResult, array $args): void { - $result = Financial::NPER(...$args); + if (count($args) === 0) { + $result = Financial::NPER(); + } elseif (count($args) === 1) { + $result = Financial::NPER($args[0]); + } elseif (count($args) === 2) { + $result = Financial::NPER($args[0], $args[1]); + } elseif (count($args) === 3) { + $result = Financial::NPER($args[0], $args[1], $args[2]); + } elseif (count($args) === 4) { + $result = Financial::NPER($args[0], $args[1], $args[2], $args[3]); + } else { + $result = Financial::NPER($args[0], $args[1], $args[2], $args[3], $args[4]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php index a8d3095a..dbe1b09a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class PDurationTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerPDURATION * @@ -20,7 +14,15 @@ class PDurationTest extends TestCase */ public function testPDURATION($expectedResult, array $args): void { - $result = Financial::PDURATION(...$args); + if (count($args) === 0) { + $result = Financial::PDURATION(); + } elseif (count($args) === 1) { + $result = Financial::PDURATION($args[0]); + } elseif (count($args) === 2) { + $result = Financial::PDURATION($args[0], $args[1]); + } else { + $result = Financial::PDURATION($args[0], $args[1], $args[2]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php index d996db10..5c1f6556 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class PmtTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerPMT * @@ -23,7 +17,13 @@ class PmtTest extends TestCase $interestRate = array_shift($args); $numberOfPeriods = array_shift($args); $presentValue = array_shift($args); - $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, ...$args); + if (count($args) === 0) { + $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue); + } elseif (count($args) === 1) { + $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0]); + } else { + $result = Financial::PMT($interestRate, $numberOfPeriods, $presentValue, $args[0], $args[1]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php index c1b40231..4e4a8f80 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class PvTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerPV * @@ -20,7 +14,19 @@ class PvTest extends TestCase */ public function testPV($expectedResult, array $args): void { - $result = Financial::PV(...$args); + if (count($args) === 0) { + $result = Financial::PV(); + } elseif (count($args) === 1) { + $result = Financial::PV($args[0]); + } elseif (count($args) === 2) { + $result = Financial::PV($args[0], $args[1]); + } elseif (count($args) === 3) { + $result = Financial::PV($args[0], $args[1], $args[2]); + } elseif (count($args) === 4) { + $result = Financial::PV($args[0], $args[1], $args[2], $args[3]); + } else { + $result = Financial::PV($args[0], $args[1], $args[2], $args[3], $args[4]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php index e641b590..9107ba96 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php @@ -3,16 +3,10 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial; use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PHPUnit\Framework\TestCase; class RriTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerRRI * @@ -20,7 +14,15 @@ class RriTest extends TestCase */ public function testRRI($expectedResult, array $args): void { - $result = Financial::RRI(...$args); + if (count($args) === 0) { + $result = Financial::RRI(); + } elseif (count($args) === 1) { + $result = Financial::RRI($args[0]); + } elseif (count($args) === 2) { + $result = Financial::RRI($args[0], $args[1]); + } else { + $result = Financial::RRI($args[0], $args[1], $args[2]); + } self::assertEqualsWithDelta($expectedResult, $result, 1E-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php index 770b8ffa..db8fa112 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php @@ -12,9 +12,13 @@ class UsDollarTest extends TestCase * * @param mixed $expectedResult */ - public function testUSDOLLAR($expectedResult, ...$args): void + public function testUSDOLLAR($expectedResult, float $amount, ?int $precision = null): void { - $result = Dollar::format(...$args); + if ($precision === null) { + $result = Dollar::format($amount); + } else { + $result = Dollar::format($amount, $precision); + } self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index b3e21986..58997161 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -2,17 +2,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Logical; use PHPUnit\Framework\TestCase; class IfTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerIF * @@ -20,7 +14,15 @@ class IfTest extends TestCase */ public function testIF($expectedResult, ...$args): void { - $result = Logical::statementIf(...$args); + if (count($args) === 0) { + $result = Logical::statementIf(); + } elseif (count($args) === 1) { + $result = Logical::statementIf($args[0]); + } elseif (count($args) === 2) { + $result = Logical::statementIf($args[0], $args[1]); + } else { + $result = Logical::statementIf($args[0], $args[1], $args[2]); + } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index 03eb15ba..6d8b2ca9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -3,17 +3,11 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; -use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Logical; use PHPUnit\Framework\TestCase; class NotTest extends TestCase { - protected function setUp(): void - { - Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); - } - /** * @dataProvider providerNOT * @@ -21,7 +15,11 @@ class NotTest extends TestCase */ public function testNOT($expectedResult, ...$args): void { - $result = Logical::NOT(...$args); + if (count($args) === 0) { + $result = Logical::NOT(); + } else { + $result = Logical::NOT($args[0]); + } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php index 6e63e5ca..6fffb31c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php @@ -17,7 +17,7 @@ class RandArrayTest extends AllSetupTeardown $result = MathTrig\Random::randArray($rows, $cols, $min, $max, true); self::assertIsArray($result); - self::assertCount($rows, $result); + self::assertCount($rows, /** @scrutinizer ignore-type */ $result); self::assertIsArray($result[0]); self::assertCount($cols, $result[0]); @@ -40,7 +40,7 @@ class RandArrayTest extends AllSetupTeardown $result = MathTrig\Random::randArray($rows, $cols, $min, $max, false); self::assertIsArray($result); - self::assertCount($rows, $result); + self::assertCount($rows, /** @scrutinizer ignore-type */ $result); self::assertIsArray($result[0]); self::assertCount($cols, $result[0]); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php index bd89d501..99cc1fa8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php @@ -62,7 +62,7 @@ class RandBetweenTest extends AllSetupTeardown self::assertIsArray($result); self::assertCount($expectedRows, $result); self::assertIsArray($result[0]); - self::assertCount($expectedColumns, $result[0]); + self::assertCount($expectedColumns, /** @scrutinizer ignore-type */ $result[0]); } public function providerRandBetweenArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php index d2ba3345..9346a6cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php @@ -2,7 +2,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig; -use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; +use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\MatrixFunctions; class SequenceTest extends AllSetupTeardown { @@ -14,7 +14,17 @@ class SequenceTest extends AllSetupTeardown */ public function testSEQUENCE(array $arguments, $expectedResult): void { - $result = MathTrig\MatrixFunctions::sequence(...$arguments); + if (count($arguments) === 0) { + $result = MatrixFunctions::sequence(); + } elseif (count($arguments) === 1) { + $result = MatrixFunctions::sequence($arguments[0]); + } elseif (count($arguments) === 2) { + $result = MatrixFunctions::sequence($arguments[0], $arguments[1]); + } elseif (count($arguments) === 3) { + $result = MatrixFunctions::sequence($arguments[0], $arguments[1], $arguments[2]); + } else { + $result = MatrixFunctions::sequence($arguments[0], $arguments[1], $arguments[2], $arguments[3]); + } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php index a5ed8223..a796c370 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php @@ -17,11 +17,16 @@ class GrowthTest extends TestCase * @dataProvider providerGROWTH * * @param mixed $expectedResult - * @param mixed $yValues */ - public function testGROWTH($expectedResult, $yValues, ...$args): void + public function testGROWTH($expectedResult, array $yValues, array $xValues, ?array $newValues = null, ?bool $const = null): void { - $result = Statistical::GROWTH($yValues, ...$args); + if ($newValues === null) { + $result = Statistical::GROWTH($yValues, $xValues); + } elseif ($const === null) { + $result = Statistical::GROWTH($yValues, $xValues, $newValues); + } else { + $result = Statistical::GROWTH($yValues, $xValues, $newValues, $const); + } self::assertEqualsWithDelta($expectedResult, $result[0], 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php index c367cb10..2cb06b77 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php @@ -17,11 +17,16 @@ class TrendTest extends TestCase * @dataProvider providerGROWTH * * @param mixed $expectedResult - * @param mixed $yValues */ - public function testTREND($expectedResult, $yValues, ...$args): void + public function testTREND($expectedResult, array $yValues, array $xValues, ?array $newValues = null, ?bool $const = null): void { - $result = Statistical::TREND($yValues, ...$args); + if ($newValues === null) { + $result = Statistical::TREND($yValues, $xValues); + } elseif ($const === null) { + $result = Statistical::TREND($yValues, $xValues, $newValues); + } else { + $result = Statistical::TREND($yValues, $xValues, $newValues, $const); + } self::assertEqualsWithDelta($expectedResult, $result[0], 1E-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php index 2aff7b3d..c458fd22 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php @@ -23,7 +23,7 @@ class WebServiceTest extends TestCase */ public function testWEBSERVICE(string $expectedResult, string $url, ?array $responseData): void { - if ($responseData) { + if (!empty($responseData)) { $body = $this->createMock(StreamInterface::class); $body->expects(self::atMost(1))->method('getContents')->willReturn($responseData[1]); diff --git a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php index c12bf060..9ea62400 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FunctionsTest.php @@ -76,12 +76,10 @@ class FunctionsTest extends TestCase /** * @dataProvider providerIfCondition - * - * @param mixed $expectedResult */ - public function testIfCondition($expectedResult, ...$args): void + public function testIfCondition(string $expectedResult, string $args): void { - $result = Functions::ifCondition(...$args); + $result = Functions::ifCondition($args); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Cell/AddressHelperTest.php b/tests/PhpSpreadsheetTests/Cell/AddressHelperTest.php index 58c696ef..f82a4ead 100644 --- a/tests/PhpSpreadsheetTests/Cell/AddressHelperTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AddressHelperTest.php @@ -32,15 +32,17 @@ class AddressHelperTest extends TestCase ?int $row = null, ?int $column = null ): void { - $args = []; - if ($row !== null) { - $args[] = $row; + if ($row === null) { + if ($column === null) { + $actualValue = AddressHelper::convertToA1($address); + } else { + $actualValue = AddressHelper::convertToA1($address, $column); + } + } elseif ($column === null) { + $actualValue = AddressHelper::convertToA1($address, $row); + } else { + $actualValue = AddressHelper::convertToA1($address, $row, $column); } - if ($column !== null) { - $args[] = $column; - } - - $actualValue = AddressHelper::convertToA1($address, ...$args); self::assertSame($expectedValue, $actualValue); } diff --git a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php index 9a0a2c21..8ed23427 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -265,7 +265,7 @@ class CoordinateTest extends TestCase $cellRange = null; // @phpstan-ignore-next-line - Coordinate::buildRange($cellRange); + Coordinate::buildRange(/** @scrutinizer ignore-type */ $cellRange); } public function testBuildRangeInvalid2(): void diff --git a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php index c539da09..e6c95cd4 100644 --- a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php @@ -155,11 +155,17 @@ class PropertiesTest extends TestCase * * @param mixed $expectedType * @param mixed $expectedValue - * @param mixed $propertyName + * @param string $propertyName + * @param mixed $propertyValue + * @param ?string $propertyType */ - public function testSetCustomProperties($expectedType, $expectedValue, $propertyName, ...$args): void + public function testSetCustomProperties($expectedType, $expectedValue, $propertyName, $propertyValue, $propertyType = null): void { - $this->properties->setCustomProperty($propertyName, ...$args); + if ($propertyType === null) { + $this->properties->setCustomProperty($propertyName, $propertyValue); + } else { + $this->properties->setCustomProperty($propertyName, $propertyValue, $propertyType); + } self::assertTrue($this->properties->isCustomPropertySet($propertyName)); self::assertSame($expectedType, $this->properties->getCustomPropertyType($propertyName)); $result = $this->properties->getCustomPropertyValue($propertyName); diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 958c6eb0..b516a9f4 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -81,39 +81,13 @@ class IOFactoryTest extends TestCase /** * @dataProvider providerIdentify - * - * @param string $file - * @param string $expectedName - * @param string $expectedClass */ - public function testIdentify($file, $expectedName, $expectedClass): void + public function testIdentifyCreateLoad(string $file, string $expectedName, string $expectedClass): void { $actual = IOFactory::identify($file); self::assertSame($expectedName, $actual); - } - - /** - * @dataProvider providerIdentify - * - * @param string $file - * @param string $expectedName - * @param string $expectedClass - */ - public function testCreateReaderForFile($file, $expectedName, $expectedClass): void - { $actual = IOFactory::createReaderForFile($file); self::assertSame($expectedClass, get_class($actual)); - } - - /** - * @dataProvider providerIdentify - * - * @param string $file - * @param string $expectedName - * @param string $expectedClass - */ - public function testLoad($file, $expectedName, $expectedClass): void - { $actual = IOFactory::load($file); self::assertInstanceOf(Spreadsheet::class, $actual); } diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 9fb4d919..90ed5cc2 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -176,9 +176,9 @@ class DateTest extends TestCase * * @param mixed $expectedResult */ - public function testIsDateTimeFormatCode($expectedResult, ...$args): void + public function testIsDateTimeFormatCode($expectedResult, string $format): void { - $result = Date::isDateTimeFormatCode(...$args); + $result = Date::isDateTimeFormatCode($format); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Style/ColorTest.php b/tests/PhpSpreadsheetTests/Style/ColorTest.php index 6575c850..9767c537 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -78,11 +78,14 @@ class ColorTest extends TestCase * @dataProvider providerColorGetRed * * @param mixed $expectedResult - * @param mixed $color */ - public function testGetRed($expectedResult, $color, ...$args): void + public function testGetRed($expectedResult, string $color, ?bool $bool = null): void { - $result = Color::getRed($color, ...$args); + if ($bool === null) { + $result = Color::getRed($color); + } else { + $result = Color::getRed($color, $bool); + } self::assertEquals($expectedResult, $result); } @@ -95,11 +98,14 @@ class ColorTest extends TestCase * @dataProvider providerColorGetGreen * * @param mixed $expectedResult - * @param mixed $color */ - public function testGetGreen($expectedResult, $color, ...$args): void + public function testGetGreen($expectedResult, string $color, ?bool $bool = null): void { - $result = Color::getGreen($color, ...$args); + if ($bool === null) { + $result = Color::getGreen($color); + } else { + $result = Color::getGreen($color, $bool); + } self::assertEquals($expectedResult, $result); } @@ -112,11 +118,14 @@ class ColorTest extends TestCase * @dataProvider providerColorGetBlue * * @param mixed $expectedResult - * @param mixed $color */ - public function testGetBlue($expectedResult, $color, ...$args): void + public function testGetBlue($expectedResult, string $color, ?bool $bool = null): void { - $result = Color::getBlue($color, ...$args); + if ($bool === null) { + $result = Color::getBlue($color); + } else { + $result = Color::getBlue($color, $bool); + } self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php index a81058af..b9e18e43 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ColumnCellIteratorTest.php @@ -44,7 +44,7 @@ class ColumnCellIteratorTest extends TestCase self::assertEquals($ColumnCellIndexResult++, $key); self::assertInstanceOf(Cell::class, $ColumnCell); } - $transposed = array_map(null, ...self::CELL_VALUES); + $transposed = array_map(/** @scrutinizer ignore-type */ null, ...self::CELL_VALUES); self::assertSame($transposed[0], $values); $spreadsheet->disconnectWorksheets(); }