Resolve Phpstan Messages in Calculation Financial (#3284)

Reduce number of Phpstan messages by addressing their issues.
This commit is contained in:
oleibman
2023-01-15 08:18:33 -08:00
committed by GitHub
parent 811406ba7a
commit a5f1de02e3
12 changed files with 102 additions and 146 deletions
-120
View File
@@ -1,125 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\DateTimeExcel\\\\Helpers\\:\\:isLeapYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has no return type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$futureValue with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$numberOfPeriods with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$payment with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$presentValue with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$rate with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$type with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php
-
message: "#^Binary operation \"\\-\" between float\\|string and 0\\|float results in an error\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\InterestAndPrincipal\\:\\:\\$interest has no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php
-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\InterestAndPrincipal\\:\\:\\$principal has no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\NonPeriodic\\:\\:xnpvOrdered\\(\\) should return float\\|string but returns array\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Variable\\\\Periodic\\:\\:presentValue\\(\\) has parameter \\$args with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php
-
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateCost\\(\\) has parameter \\$cost with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateFactor\\(\\) has parameter \\$factor with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateLife\\(\\) has parameter \\$life with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateMonth\\(\\) has parameter \\$month with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validatePeriod\\(\\) has parameter \\$period with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateSalvage\\(\\) has parameter \\$salvage with no type specified\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php
-
message: "#^Binary operation \"/\" between float\\|string and float\\|string results in an error\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:received\\(\\) should return float\\|string but returns array\\|string\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
-
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
count: 1
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php
-
message: "#^Parameter \\#1 \\$year of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Helpers\\:\\:daysPerYear\\(\\) expects int\\|string, array\\|int\\|string given\\.$#"
count: 2
path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php
-
message: "#^Cannot call method getTokenSubType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#"
count: 4
+10 -12
View File
@@ -12,8 +12,6 @@ use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill;
/**
* @deprecated 1.18.0
*
* @codeCoverageIgnore
*/
class Financial
{
@@ -543,7 +541,7 @@ class Financial
* date when the security is traded to the buyer.
* @param mixed $maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int $price The security's price per $100 face value
* @param mixed $price The security's price per $100 face value
* @param int $redemption The security's redemption value per $100 face value
* @param int $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
@@ -1004,7 +1002,7 @@ class Financial
* is traded to the buyer.
* @param mixed $maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int $discount The security's discount rate
* @param mixed $discount The security's discount rate
* @param int $redemption The security's redemption value per $100 face value
* @param int $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
@@ -1035,8 +1033,8 @@ class Financial
* @param mixed $maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param mixed $issue The security's issue date
* @param int $rate The security's interest rate at date of issue
* @param int $yield The security's annual yield
* @param mixed $rate The security's interest rate at date of issue
* @param mixed $yield The security's annual yield
* @param int $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
@@ -1216,7 +1214,7 @@ class Financial
* Treasury bill is traded to the buyer.
* @param mixed $maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int $discount The Treasury bill's discount rate
* @param mixed $discount The Treasury bill's discount rate
*
* @return float|string Result, or a string containing an error
*/
@@ -1239,7 +1237,7 @@ class Financial
* when the Treasury bill is traded to the buyer.
* @param mixed $maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int $discount The Treasury bill's discount rate
* @param mixed $discount The Treasury bill's discount rate
*
* @return float|string Result, or a string containing an error
*/
@@ -1262,7 +1260,7 @@ class Financial
* when the Treasury bill is traded to the buyer.
* @param mixed $maturity The Treasury bill's maturity date.
* The maturity date is the date when the Treasury bill expires.
* @param int $price The Treasury bill's price per $100 face value
* @param mixed $price The Treasury bill's price per $100 face value
*
* @return float|mixed|string
*/
@@ -1342,7 +1340,7 @@ class Financial
* is traded to the buyer.
* @param mixed $maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param int $price The security's price per $100 face value
* @param mixed $price The security's price per $100 face value
* @param int $redemption The security's redemption value per $100 face value
* @param int $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
@@ -1373,8 +1371,8 @@ class Financial
* @param mixed $maturity The security's maturity date.
* The maturity date is the date when the security expires.
* @param mixed $issue The security's issue date
* @param int $rate The security's interest rate at date of issue
* @param int $price The security's price per $100 face value
* @param mixed $rate The security's interest rate at date of issue
* @param mixed $price The security's price per $100 face value
* @param int $basis The type of day count to use.
* 0 or omitted US (NASD) 30/360
* 1 Actual/actual
@@ -171,8 +171,9 @@ class Amortization
$yearFrac = $yearFracx;
if (
($basis == FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) &&
($yearFrac < 1) && (Functions::scalar(DateTimeExcel\Helpers::isLeapYear($purchasedYear)))
$basis == FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL
&& $yearFrac < 1
&& DateTimeExcel\Helpers::isLeapYear(Functions::scalar($purchasedYear))
) {
$yearFrac *= 365 / 366;
}
@@ -199,7 +199,8 @@ class Interest
return $close ? $rate : ExcelError::NAN();
}
private static function rateNextGuess($rate, $numberOfPeriods, $payment, $presentValue, $futureValue, $type)
/** @return float|string */
private static function rateNextGuess(float $rate, int $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type)
{
if ($rate == 0.0) {
return ExcelError::NAN();
@@ -6,8 +6,10 @@ use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstan
class InterestAndPrincipal
{
/** @var float */
protected $interest;
/** @var float */
protected $principal;
public function __construct(
@@ -24,7 +26,7 @@ class InterestAndPrincipal
$principal = 0.0;
for ($i = 1; $i <= $period; ++$i) {
$interest = ($type === FinancialConstants::PAYMENT_BEGINNING_OF_PERIOD && $i == 1) ? 0 : -$capital * $rate;
$principal = $payment - $interest;
$principal = (float) $payment - $interest;
$capital += $principal;
}
@@ -291,7 +291,7 @@ class NonPeriodic
if ($date0 > $datei) {
$dif = $ordered ? ExcelError::NAN() : -((int) DateTimeExcel\Difference::interval($datei, $date0, 'd'));
} else {
$dif = DateTimeExcel\Difference::interval($date0, $datei, 'd');
$dif = Functions::scalar(DateTimeExcel\Difference::interval($date0, $datei, 'd'));
}
if (!is_numeric($dif)) {
return $dif;
@@ -144,6 +144,7 @@ class Periodic
* Returns the Net Present Value of a cash flow series given a discount rate.
*
* @param mixed $rate
* @param array $args
*
* @return float
*/
@@ -200,7 +200,7 @@ class Coupons
}
/** @var int */
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(Functions::Scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
$next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT);
if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_NASD) {
@@ -208,6 +208,7 @@ class Depreciation
return $syd;
}
/** @param mixed $cost */
private static function validateCost($cost, bool $negativeValueAllowed = false): float
{
$cost = FinancialValidations::validateFloat($cost);
@@ -218,6 +219,7 @@ class Depreciation
return $cost;
}
/** @param mixed $salvage */
private static function validateSalvage($salvage, bool $negativeValueAllowed = false): float
{
$salvage = FinancialValidations::validateFloat($salvage);
@@ -228,6 +230,7 @@ class Depreciation
return $salvage;
}
/** @param mixed $life */
private static function validateLife($life, bool $negativeValueAllowed = false): float
{
$life = FinancialValidations::validateFloat($life);
@@ -238,6 +241,7 @@ class Depreciation
return $life;
}
/** @param mixed $period */
private static function validatePeriod($period, bool $negativeValueAllowed = false): float
{
$period = FinancialValidations::validateFloat($period);
@@ -248,6 +252,7 @@ class Depreciation
return $period;
}
/** @param mixed $month */
private static function validateMonth($month): int
{
$month = FinancialValidations::validateInt($month);
@@ -258,6 +263,7 @@ class Depreciation
return $month;
}
/** @param mixed $factor */
private static function validateFactor($factor): float
{
$factor = FinancialValidations::validateFloat($factor);
@@ -70,10 +70,10 @@ class Price
return $e->getMessage();
}
$dsc = Coupons::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
$e = Coupons::COUPDAYS($settlement, $maturity, $frequency, $basis);
$n = Coupons::COUPNUM($settlement, $maturity, $frequency, $basis);
$a = Coupons::COUPDAYBS($settlement, $maturity, $frequency, $basis);
$dsc = (float) Coupons::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
$e = (float) Coupons::COUPDAYS($settlement, $maturity, $frequency, $basis);
$n = (int) Coupons::COUPNUM($settlement, $maturity, $frequency, $basis);
$a = (float) Coupons::COUPDAYBS($settlement, $maturity, $frequency, $basis);
$baseYF = 1.0 + ($yield / $frequency);
$rfp = 100 * ($rate / $frequency);
@@ -195,7 +195,7 @@ class Price
return $e->getMessage();
}
$daysPerYear = Functions::scalar(Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis));
$daysPerYear = Helpers::daysPerYear(Functions::scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
@@ -276,7 +276,7 @@ class Price
$daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::fraction($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
return Functions::scalar($daysBetweenSettlementAndMaturity);
}
return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity));
@@ -57,7 +57,7 @@ class Yields
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(Functions::scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
@@ -122,7 +122,7 @@ class Yields
return $e->getMessage();
}
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
$daysPerYear = Helpers::daysPerYear(Functions::scalar(DateTimeExcel\DateParts::year($settlement)), $basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
@@ -0,0 +1,67 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Financial;
//use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Financial;
use PHPUnit\Framework\TestCase;
// Sanity tests for functions which have been moved out of Financial
// to their own classes. A deprecated version remains in Financial;
// this class contains cursory tests to ensure that those work properly.
// If Scrutinizer fails the PR because of these deprecations, I will
// remove this class from the PR.
class MovedFunctionsTest extends TestCase
{
public function testMovedFunctions(): void
{
self::assertEqualsWithDelta(16.6666666666666, /** @scrutinizer ignore-deprecated */ Financial::ACCRINT('2008-03-01', '2008-08-31', '2008-05-01', 0.10, 1000, 2, 0), 1E-8);
self::assertEqualsWithDelta(20.547945205478999, /** @scrutinizer ignore-deprecated */ Financial::ACCRINTM('2008-04-01', '2008-06-15', 0.10, 1000, 3), 1E-8);
self::assertEqualsWithDelta(776, /** @scrutinizer ignore-deprecated */ Financial::AMORDEGRC(2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, 1), 1E-8);
self::assertEqualsWithDelta(360, /** @scrutinizer ignore-deprecated */ Financial::AMORLINC(2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, 1), 1E-8);
self::assertEqualsWithDelta(71, /** @scrutinizer ignore-deprecated */ Financial::COUPDAYBS('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(181, /** @scrutinizer ignore-deprecated */ Financial::COUPDAYS('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(110, /** @scrutinizer ignore-deprecated */ Financial::COUPDAYSNC('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(39217, /** @scrutinizer ignore-deprecated */ Financial::COUPNCD('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(4, /** @scrutinizer ignore-deprecated */ Financial::COUPNUM('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(39036, /** @scrutinizer ignore-deprecated */ Financial::COUPPCD('25-Jan-2007', '15-Nov-2008', 2, 1), 1E-8);
self::assertEqualsWithDelta(-11135.232130750999, /** @scrutinizer ignore-deprecated */ Financial::CUMIPMT(0.0075, 360, 125000, 13, 24, 0), 1E-8);
self::assertEqualsWithDelta(-934.10712342088004, /** @scrutinizer ignore-deprecated */ Financial::CUMPRINC(0.0075, 360, 125000, 13, 24, 0), 1E-8);
self::assertEqualsWithDelta(186083.3333333334, /** @scrutinizer ignore-deprecated */ Financial::DB(1000000, 100000, 6, 1, 7), 1E-8);
self::assertEqualsWithDelta(0.13150684931507001, /** @scrutinizer ignore-deprecated */ Financial::DDB(2400, 300, 36500, 1), 1E-8);
self::assertEqualsWithDelta(0.052420213, /** @scrutinizer ignore-deprecated */ Financial::DISC('2007-01-25', '2007-06-15', 97.974999999999994, 100, 1), 1E-8);
self::assertEqualsWithDelta(2.5, /** @scrutinizer ignore-deprecated */ Financial::DOLLARDE(1.6, 4), 1E-8);
self::assertEqualsWithDelta(1.24, /** @scrutinizer ignore-deprecated */ Financial::DOLLARFR(1.6, 4), 1E-8);
self::assertEqualsWithDelta(0.053542667370758003, /** @scrutinizer ignore-deprecated */ Financial::EFFECT(0.052499999999999998, 4), 1E-8);
self::assertEqualsWithDelta(2581.4033740600998, /** @scrutinizer ignore-deprecated */ Financial::FV(0.005, 10, -200, -500, 1), 1E-8);
self::assertEqualsWithDelta(1.3308899999999999, /** @scrutinizer ignore-deprecated */ Financial::FVSCHEDULE(1, [0.089999999999999997, 0.11, 0.10000000000000001]), 1E-8);
self::assertEqualsWithDelta(0.05768, /** @scrutinizer ignore-deprecated */ Financial::INTRATE('2008-02-15', '2008-05-15', 1000000, 1014420, 2), 1E-8);
self::assertEqualsWithDelta(-22.858787457480013, /** @scrutinizer ignore-deprecated */ Financial::IPMT(0.0085, 3, 3, 8000), 1E-8);
self::assertEqualsWithDelta(-0.02124484827341, /** @scrutinizer ignore-deprecated */ Financial::IRR([-70000, 12000, 15000, 18000, 21000]), 1E-8);
self::assertEqualsWithDelta(-66111.111111111, /** @scrutinizer ignore-deprecated */ Financial::ISPMT(0.0085, 1, 36, 8000000), 1E-8);
self::assertEqualsWithDelta(0.12609413036591, /** @scrutinizer ignore-deprecated */ Financial::MIRR([-120000, [39000, 30000, 21000, 37000, 46000]], 0.10, 0.12), 1E-8);
self::assertEqualsWithDelta(0.052500319868356002, /** @scrutinizer ignore-deprecated */ Financial::NOMINAL(0.053543, 4), 1E-8);
self::assertEqualsWithDelta(59.673865674295001, /** @scrutinizer ignore-deprecated */ Financial::NPER(0.01, -100, -1000, 10000, 1), 1E-8);
self::assertEqualsWithDelta(1188.4434123352, /** @scrutinizer ignore-deprecated */ Financial::NPV(0.10, -10000, 3000, 4200, 6800), 1E-8);
self::assertEqualsWithDelta(10.33803507, /** @scrutinizer ignore-deprecated */ Financial::PDURATION(0.04, 10000, 15000), 1E-8);
self::assertEqualsWithDelta(-1037.032089359164, /** @scrutinizer ignore-deprecated */ Financial::PMT(0.08 / 12, 10, 10000), 1E-8);
self::assertEqualsWithDelta(-75.623186008367, /** @scrutinizer ignore-deprecated */ Financial::PPMT(0.10 / 12, 1, 2 * 12, 2000), 1E-8);
self::assertEqualsWithDelta(94.6343616213221, /** @scrutinizer ignore-deprecated */ Financial::PRICE('15-Feb-2008', '15-Nov-2017', 0.0575, 0.065, 100, 2, 0), 1E-8);
self::assertEqualsWithDelta(90.0, /** @scrutinizer ignore-deprecated */ Financial::PRICEDISC('01-Apr-2017', '31-Mar-2021', 0.025, 100), 1E-8);
self::assertEqualsWithDelta(99.98449887555694, /** @scrutinizer ignore-deprecated */ Financial::PRICEMAT('15-Feb-2008', '13-Apr-2008', '11-Nov-2007', 0.061, 0.061, 0), 1E-8);
self::assertEqualsWithDelta(-52990.70632392715, /** @scrutinizer ignore-deprecated */ Financial::PV(0.05 / 12, 60, 1000), 1E-8);
self::assertEqualsWithDelta(0.0077014724882014003, /** @scrutinizer ignore-deprecated */ Financial::RATE(48, -200, 8000), 1E-8);
self::assertEqualsWithDelta(1014584.6544071021, /** @scrutinizer ignore-deprecated */ Financial::RECEIVED('15-Feb-2008', '15-May-2008', 1000000, 0.0575, 2), 1E-8);
self::assertEqualsWithDelta(0.04137974399241062, /** @scrutinizer ignore-deprecated */ Financial::RRI(10, 10000, 15000), 1E-8);
self::assertEqualsWithDelta(1800, /** @scrutinizer ignore-deprecated */ Financial::SLN(10000, 1000, 5), 1E-8);
self::assertEqualsWithDelta(3000, /** @scrutinizer ignore-deprecated */ Financial::SYD(10000, 1000, 5, 1), 1E-8);
self::assertEqualsWithDelta(0.094151494, /** @scrutinizer ignore-deprecated */ Financial::TBILLEQ('31-Mar-2008', '1-Jun-2008', 0.0914), 1E-8);
self::assertEqualsWithDelta(98.45, /** @scrutinizer ignore-deprecated */ Financial::TBILLPRICE('31-Mar-2008', '1-Jun-2008', 0.09), 1E-8);
self::assertEqualsWithDelta(0.09141696292534264, /** @scrutinizer ignore-deprecated */ Financial::TBILLYIELD('31-Mar-2008', '1-Jun-2008', 98.45), 1E-8);
self::assertEqualsWithDelta(0.77868869226873, /** @scrutinizer ignore-deprecated */ Financial::XIRR([4000, -46000], ['2015-04-01', '2019-06-27'], 0.1), 1E-8);
self::assertEqualsWithDelta(772830.7339573108, /** @scrutinizer ignore-deprecated */ Financial::XNPV(0.10, [0, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000], ['2018-06-30', '2018-12-31', '2019-12-31', '2020-12-31', '2021-12-31', '2022-12-31', '2023-12-31', '2024-12-31', '2025-12-31', '2026-12-31', '2027-12-31']), 1E-8);
self::assertEqualsWithDelta(0.05282257198685834, /** @scrutinizer ignore-deprecated */ Financial::YIELDDISC('16-Feb-2008', '1-Mar-2008', 99.795, 100, 2), 1E-8);
self::assertEqualsWithDelta(0.06095433369153867, /** @scrutinizer ignore-deprecated */ Financial::YIELDMAT('15-Mar-2008', '3-Nov-2008', '8-Nov-2007', 0.0625, 100.0123, 0), 1E-8);
}
}