diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index d380995c..1c745bdb 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -227,7 +227,8 @@ class OLE // in OLE_ChainedBlockStream::stream_open(). // Object is removed from self::$instances in OLE_Stream::close(). $GLOBALS['_OLE_INSTANCES'][] = $this; - $instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES'])); + $keys = array_keys($GLOBALS['_OLE_INSTANCES']); + $instanceId = end($keys); $path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId; if ($blockIdOrPps instanceof OLE\PPS) { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index c2ded195..4c33eb37 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -595,7 +595,9 @@ class AutoFilter sort($dataValues); } - return array_pop(array_slice($dataValues, 0, $ruleValue)); + $slice = array_slice($dataValues, 0, $ruleValue); + + return array_pop($slice); } /** diff --git a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php b/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php deleted file mode 100644 index d6135a46..00000000 --- a/tests/PhpSpreadsheetTests/Calculation/FinancialTest.php +++ /dev/null @@ -1,500 +0,0 @@ - 0.999999 && $frac < 1.000001) { - $result = $expectedResult; - } - } - } - self::assertEquals($expectedResult, $result, $message); - } - - public function providerXIRR() - { - return require 'tests/data/Calculation/Financial/XIRR.php'; - } - - /** - * @dataProvider providerXNPV - * - * @param mixed $expectedResult - * @param mixed $message - */ - public function testXNPV($expectedResult, $message, ...$args): void - { - $result = Financial::XNPV(...$args); - if (is_numeric($result) && is_numeric($expectedResult)) { - if ($expectedResult != 0) { - $frac = $result / $expectedResult; - if ($frac > 0.999999 && $frac < 1.000001) { - $result = $expectedResult; - } - } - } - self::assertEquals($expectedResult, $result, $message); - } - - public function providerXNPV() - { - return require 'tests/data/Calculation/Financial/XNPV.php'; - } - - /** - * @dataProvider providerPDURATION - * - * @param mixed $expectedResult - */ - public function testPDURATION($expectedResult, array $args): void - { - $result = Financial::PDURATION(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerPDURATION() - { - return require 'tests/data/Calculation/Financial/PDURATION.php'; - } - - /** - * @dataProvider providerRRI - * - * @param mixed $expectedResult - */ - public function testRRI($expectedResult, array $args): void - { - $result = Financial::RRI(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerRRI() - { - return require 'tests/data/Calculation/Financial/RRI.php'; - } - - /** - * @dataProvider providerSLN - * - * @param mixed $expectedResult - */ - public function testSLN($expectedResult, array $args): void - { - $result = Financial::SLN(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerSLN() - { - return require 'tests/data/Calculation/Financial/SLN.php'; - } - - /** - * @dataProvider providerSYD - * - * @param mixed $expectedResult - */ - public function testSYD($expectedResult, array $args): void - { - $result = Financial::SYD(...$args); - self::assertEqualsWithDelta($expectedResult, $result, 1E-8); - } - - public function providerSYD() - { - return require 'tests/data/Calculation/Financial/SYD.php'; - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php new file mode 100644 index 00000000..ff82bcbc --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php @@ -0,0 +1,31 @@ + 0.999999 && $frac < 1.000001) { + $result = $expectedResult; + } + } + } + self::assertEquals($expectedResult, $result, $message); + } + + public function providerXNPV() + { + return require 'tests/data/Calculation/Financial/XNPV.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php new file mode 100644 index 00000000..042ef298 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php @@ -0,0 +1,40 @@ + 0.999999 && $frac < 1.000001) { + $result = $expectedResult; + } + } + } + self::assertEquals($expectedResult, $result, $message); + } + + public function providerXIRR() + { + return require 'tests/data/Calculation/Financial/XIRR.php'; + } +}