From a34695e0f9e7125e701b255f17f1436c2554eabe Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 12 Apr 2021 22:08:58 +0200 Subject: [PATCH] Financial functions more rationalization (#1990) * Additional unit tests and rationalisation for Financial Functions * Providing a series of sample files for Financial functions * Refactor the last of the existing Financial functions * Some more unit tests with default assignments from null arguments Co-authored-by: Adrien Crivelli --- phpstan-baseline.neon | 940 +----------------- samples/Calculations/Financial/ACCRINT.php | 35 + samples/Calculations/Financial/ACCRINTM.php | 33 + samples/Calculations/Financial/AMORDEGRC.php | 38 + samples/Calculations/Financial/AMORLINC.php | 38 + samples/Calculations/Financial/COUPDAYBS.php | 29 + samples/Calculations/Financial/COUPDAYS.php | 29 + samples/Calculations/Financial/COUPDAYSNC.php | 29 + samples/Calculations/Financial/COUPNCD.php | 30 + samples/Calculations/Financial/COUPNUM.php | 30 + samples/Calculations/Financial/COUPPCD.php | 30 + samples/Calculations/Financial/CUMIPMT.php | 38 + samples/Calculations/Financial/CUMPRINC.php | 38 + samples/Calculations/Financial/DB.php | 50 + samples/Calculations/Financial/DDB.php | 36 + samples/Calculations/Financial/DISC.php | 32 + samples/Calculations/Financial/DOLLARDE.php | 30 + samples/Calculations/Financial/DOLLARFR.php | 30 + samples/Calculations/Financial/EFFECT.php | 31 + samples/Calculations/Financial/FV.php | 36 + samples/Calculations/Financial/FVSCHEDULE.php | 36 + samples/Calculations/Financial/INTRATE.php | 32 + samples/Calculations/Financial/IPMT.php | 37 + samples/Calculations/Financial/IRR.php | 38 + samples/Calculations/Financial/ISPMT.php | 36 + samples/Calculations/Financial/MIRR.php | 42 + samples/Calculations/Financial/NOMINAL.php | 31 + samples/Calculations/Financial/NPER.php | 39 + samples/Calculations/Financial/NPV.php | 43 + .../Calculation/Calculation.php | 6 +- .../Calculation/DateTimeExcel/Helpers.php | 4 +- src/PhpSpreadsheet/Calculation/Financial.php | 167 ++-- .../Calculation/Financial/Amortization.php | 68 +- .../Calculation/Financial/BaseValidations.php | 72 -- .../CashFlow/CashFlowValidations.php | 56 ++ .../Financial/CashFlow/Constant/Periodic.php | 81 +- .../CashFlow/Constant/Periodic/Cumulative.php | 60 +- .../CashFlow/Constant/Periodic/Interest.php | 70 +- .../Periodic/InterestAndPrincipal.php | 6 +- .../CashFlow/Constant/Periodic/Payments.php | 50 +- .../Calculation/Financial/CashFlow/Single.php | 27 +- .../Calculation/Financial/Constants.php | 19 + .../Calculation/Financial/Coupons.php | 139 ++- .../Calculation/Financial/Depreciation.php | 19 +- ...lidations.php => FinancialValidations.php} | 149 +-- .../Calculation/Financial/Helpers.php | 31 +- .../Calculation/Financial/InterestRate.php | 10 +- .../Financial/Securities/AccruedInterest.php | 64 +- .../Financial/Securities/Constants.php | 13 - .../Financial/Securities/Price.php | 146 ++- .../Financial/Securities/Rates.php | 137 +++ .../Securities/SecurityValidations.php | 42 + .../Financial/Securities/Yields.php | 91 +- .../Calculation/Financial/TreasuryBill.php | 96 +- tests/data/Calculation/Financial/ACCRINT.php | 14 +- tests/data/Calculation/Financial/ACCRINTM.php | 4 + .../data/Calculation/Financial/AMORDEGRC.php | 28 + tests/data/Calculation/Financial/AMORLINC.php | 36 + .../data/Calculation/Financial/COUPDAYBS.php | 7 + tests/data/Calculation/Financial/COUPDAYS.php | 7 + .../data/Calculation/Financial/COUPDAYSNC.php | 7 + tests/data/Calculation/Financial/COUPNCD.php | 7 + tests/data/Calculation/Financial/COUPNUM.php | 7 + tests/data/Calculation/Financial/COUPPCD.php | 7 + tests/data/Calculation/Financial/CUMIPMT.php | 9 + tests/data/Calculation/Financial/CUMPRINC.php | 9 + tests/data/Calculation/Financial/DISC.php | 8 + .../Calculation/Financial/DaysPerYear.php | 14 +- tests/data/Calculation/Financial/FV.php | 18 +- tests/data/Calculation/Financial/INTRATE.php | 12 +- .../data/Calculation/Financial/PDURATION.php | 4 + tests/data/Calculation/Financial/PRICE.php | 10 + .../data/Calculation/Financial/PRICEDISC.php | 4 + tests/data/Calculation/Financial/PRICEMAT.php | 4 + tests/data/Calculation/Financial/RECEIVED.php | 28 + .../data/Calculation/Financial/YIELDDISC.php | 8 + tests/data/Calculation/Financial/YIELDMAT.php | 4 + tests/data/Calculation/Statistical/ZTEST.php | 10 + 78 files changed, 2234 insertions(+), 1571 deletions(-) create mode 100644 samples/Calculations/Financial/ACCRINT.php create mode 100644 samples/Calculations/Financial/ACCRINTM.php create mode 100644 samples/Calculations/Financial/AMORDEGRC.php create mode 100644 samples/Calculations/Financial/AMORLINC.php create mode 100644 samples/Calculations/Financial/COUPDAYBS.php create mode 100644 samples/Calculations/Financial/COUPDAYS.php create mode 100644 samples/Calculations/Financial/COUPDAYSNC.php create mode 100644 samples/Calculations/Financial/COUPNCD.php create mode 100644 samples/Calculations/Financial/COUPNUM.php create mode 100644 samples/Calculations/Financial/COUPPCD.php create mode 100644 samples/Calculations/Financial/CUMIPMT.php create mode 100644 samples/Calculations/Financial/CUMPRINC.php create mode 100644 samples/Calculations/Financial/DB.php create mode 100644 samples/Calculations/Financial/DDB.php create mode 100644 samples/Calculations/Financial/DISC.php create mode 100644 samples/Calculations/Financial/DOLLARDE.php create mode 100644 samples/Calculations/Financial/DOLLARFR.php create mode 100644 samples/Calculations/Financial/EFFECT.php create mode 100644 samples/Calculations/Financial/FV.php create mode 100644 samples/Calculations/Financial/FVSCHEDULE.php create mode 100644 samples/Calculations/Financial/INTRATE.php create mode 100644 samples/Calculations/Financial/IPMT.php create mode 100644 samples/Calculations/Financial/IRR.php create mode 100644 samples/Calculations/Financial/ISPMT.php create mode 100644 samples/Calculations/Financial/MIRR.php create mode 100644 samples/Calculations/Financial/NOMINAL.php create mode 100644 samples/Calculations/Financial/NPER.php create mode 100644 samples/Calculations/Financial/NPV.php delete mode 100644 src/PhpSpreadsheet/Calculation/Financial/BaseValidations.php create mode 100644 src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php create mode 100644 src/PhpSpreadsheet/Calculation/Financial/Constants.php rename src/PhpSpreadsheet/Calculation/Financial/{Securities/BaseValidations.php => FinancialValidations.php} (51%) delete mode 100644 src/PhpSpreadsheet/Calculation/Financial/Securities/Constants.php create mode 100644 src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php create mode 100644 src/PhpSpreadsheet/Calculation/Financial/Securities/SecurityValidations.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 494b90a85d..4566305f40 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -701,679 +701,44 @@ parameters: path: src/PhpSpreadsheet/Calculation/Financial.php - - message: "#^Result of && is always true\\.$#" - count: 2 - path: src/PhpSpreadsheet/Calculation/Financial.php - - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Amortization\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Amortization.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Cumulative\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:schedulePayment\\(\\) has no return typehint 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 no return typehint 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 typehint 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 typehint 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 typehint 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 typehint 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 typehint 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 typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Payments\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Single\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Binary operation \"\\*\" between float\\|string and int results in an error\\.$#" - count: 2 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Binary operation \"\\*\" between float\\|string and int\\|string results in an error\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$next with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateCouponPeriod\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateCouponPeriod\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateCost\\(\\) has parameter \\$cost with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateSalvage\\(\\) has parameter \\$salvage with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateLife\\(\\) has parameter \\$life with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validatePeriod\\(\\) has parameter \\$period with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateMonth\\(\\) has parameter \\$month with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateFactor\\(\\) has parameter \\$factor with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\InterestRate\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/InterestRate.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:schedulePayment\\(\\) has no return typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has no return typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$futureValue with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateInt\\(\\) has parameter \\$value with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$numberOfPeriods with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$payment with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$presentValue with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$rate with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\TreasuryBill\\:\\:price\\(\\) should return float\\|string but returns float\\|int\\<0, max\\>\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\Interest\\:\\:rateNextGuess\\(\\) has parameter \\$type with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php + path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php - message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\CashFlow\\\\Constant\\\\Periodic\\\\InterestAndPrincipal\\:\\:\\$interest has no typehint specified\\.$#" @@ -1501,289 +866,74 @@ parameters: path: src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateIssueDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateIssueDate\\(\\) has parameter \\$issue with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateSecurityPeriod\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateSecurityPeriod\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateRate\\(\\) has parameter \\$rate with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateParValue\\(\\) has parameter \\$parValue with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validatePrice\\(\\) has parameter \\$price with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateYield\\(\\) has parameter \\$yield with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateRedemption\\(\\) has parameter \\$redemption with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateDiscount\\(\\) has parameter \\$discount with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\AccruedInterest\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateIssueDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateIssueDate\\(\\) has parameter \\$issue with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateSecurityPeriod\\(\\) has parameter \\$maturity with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateSecurityPeriod\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateRate\\(\\) has parameter \\$rate with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateParValue\\(\\) has parameter \\$parValue with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validatePrice\\(\\) has parameter \\$price with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateYield\\(\\) has parameter \\$yield with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateRedemption\\(\\) has parameter \\$redemption with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateDiscount\\(\\) has parameter \\$discount with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Price\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateDate\\(\\) has parameter \\$date with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateFloat\\(\\) has parameter \\$value with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateSettlementDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateSettlementDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php - - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateMaturityDate\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + message: "#^Binary operation \"\\*\" between float\\|string and int results in an error\\.$#" + count: 2 + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateMaturityDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" + message: "#^Binary operation \"\\*\" between float\\|string and int\\|string results in an error\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateIssueDate\\(\\) has no return typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has no return typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateIssueDate\\(\\) has parameter \\$issue with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$maturity with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateSecurityPeriod\\(\\) has parameter \\$maturity with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$next with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateSecurityPeriod\\(\\) has parameter \\$settlement with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:couponFirstPeriodDate\\(\\) has parameter \\$settlement with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateRate\\(\\) has parameter \\$rate with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateCouponPeriod\\(\\) has parameter \\$maturity with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateParValue\\(\\) has parameter \\$parValue with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Coupons\\:\\:validateCouponPeriod\\(\\) has parameter \\$settlement with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Coupons.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validatePrice\\(\\) has parameter \\$price with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateCost\\(\\) has parameter \\$cost with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateYield\\(\\) has parameter \\$yield with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateSalvage\\(\\) has parameter \\$salvage with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateRedemption\\(\\) has parameter \\$redemption with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateLife\\(\\) has parameter \\$life with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateDiscount\\(\\) has parameter \\$discount with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validatePeriod\\(\\) has parameter \\$period with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateFrequency\\(\\) has parameter \\$frequency with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateMonth\\(\\) has parameter \\$month with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Securities\\\\Yields\\:\\:validateBasis\\(\\) has parameter \\$basis with no typehint specified\\.$#" + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Financial\\\\Depreciation\\:\\:validateFactor\\(\\) has parameter \\$factor with no typehint specified\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php + path: src/PhpSpreadsheet/Calculation/Financial/Depreciation.php - message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#" diff --git a/samples/Calculations/Financial/ACCRINT.php b/samples/Calculations/Financial/ACCRINT.php new file mode 100644 index 0000000000..6f24f65160 --- /dev/null +++ b/samples/Calculations/Financial/ACCRINT.php @@ -0,0 +1,35 @@ +log('Returns the accrued interest for a security that pays periodic interest.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Issue Date', DateHelper::getDateValue('01-Jan-2012')], + ['First Interest Date', DateHelper::getDateValue('01-Apr-2012')], + ['Settlement Date', DateHelper::getDateValue('31-Dec-2013')], + ['Annual Coupon Rate', 0.08], + ['Par Value', 10000], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B3')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B4')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B5')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B10', '=ACCRINT(B1, B2, B3, B4, B5, B6)'); +$worksheet->getStyle('B10')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B10')->getValue()); +$helper->log('ACCRINT() Result is ' . $worksheet->getCell('B10')->getFormattedValue()); diff --git a/samples/Calculations/Financial/ACCRINTM.php b/samples/Calculations/Financial/ACCRINTM.php new file mode 100644 index 0000000000..8cc738994a --- /dev/null +++ b/samples/Calculations/Financial/ACCRINTM.php @@ -0,0 +1,33 @@ +log('Returns the accrued interest for a security that pays interest at maturity.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Issue Date', DateHelper::getDateValue('01-Jan-2012')], + ['Settlement Date', DateHelper::getDateValue('31-Dec-2012')], + ['Annual Coupon Rate', 0.08], + ['Par Value', 10000], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B3')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B4')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B6', '=ACCRINTM(B1, B2, B3, B4)'); +$worksheet->getStyle('B6')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('ACCRINTM() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/AMORDEGRC.php b/samples/Calculations/Financial/AMORDEGRC.php new file mode 100644 index 0000000000..c9e0c4c91e --- /dev/null +++ b/samples/Calculations/Financial/AMORDEGRC.php @@ -0,0 +1,38 @@ +log('Returns the prorated linear depreciation of an asset for a specified accounting period.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Cost', 150.00], + ['Date Purchased', DateHelper::getDateValue('01-Jan-2015')], + ['First Period Date', DateHelper::getDateValue('30-Sep-2015')], + ['Salvage Value', 20.00], + ['Number of Periods', 1], + ['Depreciation Rate', 0.20], + ['Basis', FinancialConstants::BASIS_DAYS_PER_YEAR_360_EUROPEAN], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('$#,##0.00'); +$worksheet->getStyle('B2:B3')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B4')->getNumberFormat()->setFormatCode('$#,##0.00'); +$worksheet->getStyle('B6')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +$worksheet->setCellValue('B10', '=AMORDEGRC(B1, B2, B3, B4, B5, B6, B7)'); +$worksheet->getStyle('B10')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B10')->getValue()); +$helper->log('AMORDEGRC() Result is ' . $worksheet->getCell('B10')->getFormattedValue()); diff --git a/samples/Calculations/Financial/AMORLINC.php b/samples/Calculations/Financial/AMORLINC.php new file mode 100644 index 0000000000..3491eae02c --- /dev/null +++ b/samples/Calculations/Financial/AMORLINC.php @@ -0,0 +1,38 @@ +log('Returns the prorated linear depreciation of an asset for a specified accounting period.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Cost', 150.00], + ['Date Purchased', DateHelper::getDateValue('01-Jan-2015')], + ['First Period Date', DateHelper::getDateValue('30-Sep-2015')], + ['Salvage Value', 20.00], + ['Period', 1], + ['Depreciation Rate', 0.20], + ['Basis', FinancialConstants::BASIS_DAYS_PER_YEAR_360_EUROPEAN], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('$#,##0.00'); +$worksheet->getStyle('B2:B3')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B4')->getNumberFormat()->setFormatCode('$#,##0.00'); +$worksheet->getStyle('B6')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +$worksheet->setCellValue('B10', '=AMORLINC(B1, B2, B3, B4, B5, B6, B7)'); +$worksheet->getStyle('B10')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B10')->getValue()); +$helper->log('AMORLINC() Result is ' . $worksheet->getCell('B10')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPDAYBS.php b/samples/Calculations/Financial/COUPDAYBS.php new file mode 100644 index 0000000000..727d17d9d9 --- /dev/null +++ b/samples/Calculations/Financial/COUPDAYBS.php @@ -0,0 +1,29 @@ +log('Returns the number of days from the beginning of a coupon\'s period to the settlement date.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPDAYBS(B1, B2, B3)'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPDAYBS() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPDAYS.php b/samples/Calculations/Financial/COUPDAYS.php new file mode 100644 index 0000000000..f6e148cce2 --- /dev/null +++ b/samples/Calculations/Financial/COUPDAYS.php @@ -0,0 +1,29 @@ +log('Returns the number of days in the coupon period that contains the settlement date.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPDAYS(B1, B2, B3)'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPDAYS() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPDAYSNC.php b/samples/Calculations/Financial/COUPDAYSNC.php new file mode 100644 index 0000000000..dfb21dd7c5 --- /dev/null +++ b/samples/Calculations/Financial/COUPDAYSNC.php @@ -0,0 +1,29 @@ +log('Returns the number of days from the settlement date to the next coupon date.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPDAYSNC(B1, B2, B3)'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPDAYSNC() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPNCD.php b/samples/Calculations/Financial/COUPNCD.php new file mode 100644 index 0000000000..b38faf032b --- /dev/null +++ b/samples/Calculations/Financial/COUPNCD.php @@ -0,0 +1,30 @@ +log('Returns the next coupon date, after the settlement date.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPNCD(B1, B2, B3)'); +$worksheet->getStyle('B6')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPNCD() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPNUM.php b/samples/Calculations/Financial/COUPNUM.php new file mode 100644 index 0000000000..b1bd0d52ab --- /dev/null +++ b/samples/Calculations/Financial/COUPNUM.php @@ -0,0 +1,30 @@ +log('Returns the number of coupons payable, between a security\'s settlement date and maturity date,'); +$helper->log('rounded up to the nearest whole coupon.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPNUM(B1, B2, B3)'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPNUM() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/COUPPCD.php b/samples/Calculations/Financial/COUPPCD.php new file mode 100644 index 0000000000..8ac7860638 --- /dev/null +++ b/samples/Calculations/Financial/COUPPCD.php @@ -0,0 +1,30 @@ +log('Returns the previous coupon date, before the settlement date for a security.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Jan-2011')], + ['Maturity Date', DateHelper::getDateValue('25-Oct-2012')], + ['Frequency', 4], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +// Now the formula +$worksheet->setCellValue('B6', '=COUPPCD(B1, B2, B3)'); +$worksheet->getStyle('B6')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); + +$helper->log($worksheet->getCell('B6')->getValue()); +$helper->log('COUPPCD() Result is ' . $worksheet->getCell('B6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/CUMIPMT.php b/samples/Calculations/Financial/CUMIPMT.php new file mode 100644 index 0000000000..f97caec85c --- /dev/null +++ b/samples/Calculations/Financial/CUMIPMT.php @@ -0,0 +1,38 @@ +log('Returns the cumulative interest paid on a loan or investment, between two specified periods.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate (per period)', 0.05 / 12], + ['Number of Periods', 5 * 12], + ['Present Value', 50000], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B3')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 5; +for ($year = 1; $year <= 5; ++$year) { + $row = (string) ($baseRow + $year); + $yearStartPeriod = (int) $year * 12 - 11; + $yearEndPeriod = (int) $year * 12; + + $worksheet->setCellValue("A{$row}", "Yr {$year}"); + $worksheet->setCellValue("B{$row}", "=CUMIPMT(\$B\$1, \$B\$2, \$B\$3, {$yearStartPeriod}, {$yearEndPeriod}, 0)"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("CUMIPMT() Year {$year} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/CUMPRINC.php b/samples/Calculations/Financial/CUMPRINC.php new file mode 100644 index 0000000000..86de3070ae --- /dev/null +++ b/samples/Calculations/Financial/CUMPRINC.php @@ -0,0 +1,38 @@ +log('Returns the cumulative payment on the principal of a loan or investment, between two specified periods.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate (per period)', 0.05 / 12], + ['Number of Periods', 5 * 12], + ['Present Value', 50000], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B3')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 5; +for ($year = 1; $year <= 5; ++$year) { + $row = (string) ($baseRow + $year); + $yearStartPeriod = (int) $year * 12 - 11; + $yearEndPeriod = (int) $year * 12; + + $worksheet->setCellValue("A{$row}", "Yr {$year}"); + $worksheet->setCellValue("B{$row}", "=CUMPRINC(\$B\$1, \$B\$2, \$B\$3, {$yearStartPeriod}, {$yearEndPeriod}, 0)"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("CUMPRINC() Year {$year} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/DB.php b/samples/Calculations/Financial/DB.php new file mode 100644 index 0000000000..0759c0aac8 --- /dev/null +++ b/samples/Calculations/Financial/DB.php @@ -0,0 +1,50 @@ +log('Returns the depreciation of an asset, using the Fixed Declining Balance Method,'); +$helper->log('for each period of the asset\'s lifetime.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Cost Value', 10000], + ['Salvage', 1000], + ['Life', 5, 'Years'], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 5; +for ($year = 1; $year <= 5; ++$year) { + $row = (string) ($baseRow + $year); + + $worksheet->setCellValue("A{$row}", "Depreciation after Yr {$year}"); + $worksheet->setCellValue("B{$row}", "=DB(\$B\$1, \$B\$2, \$B\$3, {$year})"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("DB() Year {$year} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} + +$helper->log('And with depreciation only starting after 6 months.'); + +$baseRow = 12; +for ($year = 1; $year <= 6; ++$year) { + $row = (string) ($baseRow + $year); + + $worksheet->setCellValue("A{$row}", "Depreciation after Yr {$year}"); + $worksheet->setCellValue("B{$row}", "=DB(\$B\$1, \$B\$2, \$B\$3, {$year}, 6)"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("DB() Year {$year} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/DDB.php b/samples/Calculations/Financial/DDB.php new file mode 100644 index 0000000000..d261d4bd59 --- /dev/null +++ b/samples/Calculations/Financial/DDB.php @@ -0,0 +1,36 @@ +log('Returns the depreciation of an asset, using the Double Declining Balance Method,'); +$helper->log('for each period of the asset\'s lifetime.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Cost Value', 10000], + ['Salvage', 1000], + ['Life', 5, 'Years'], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 5; +for ($year = 1; $year <= 5; ++$year) { + $row = (string) ($baseRow + $year); + + $worksheet->setCellValue("A{$row}", "Depreciation after Yr {$year}"); + $worksheet->setCellValue("B{$row}", "=DDB(\$B\$1, \$B\$2, \$B\$3, {$year})"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("DDB() Year {$year} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/DISC.php b/samples/Calculations/Financial/DISC.php new file mode 100644 index 0000000000..389d75e068 --- /dev/null +++ b/samples/Calculations/Financial/DISC.php @@ -0,0 +1,32 @@ +log('Returns the the Discount Rate for a security.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Apr-2016')], + ['Maturity Date', DateHelper::getDateValue('31-Mar-2021')], + ['Par Value', 95.00], + ['Redemption Value', 100.00], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B3:B4')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B7', '=DISC(B1, B2, B3, B4)'); +$worksheet->getStyle('B7')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('B7')->getValue()); +$helper->log('DISC() Result is ' . $worksheet->getCell('B7')->getFormattedValue()); diff --git a/samples/Calculations/Financial/DOLLARDE.php b/samples/Calculations/Financial/DOLLARDE.php new file mode 100644 index 0000000000..d71874018f --- /dev/null +++ b/samples/Calculations/Financial/DOLLARDE.php @@ -0,0 +1,30 @@ +log('Returns the dollar value in fractional notation, into a dollar value expressed as a decimal.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + [1.01, 16], + [1.1, 16], + [1.03, 32], + [1.3, 32], + [1.12, 32], +]; + +$worksheet->fromArray($arguments, null, 'A1'); + +// Now the formula +for ($row = 1; $row <= 5; ++$row) { + $worksheet->setCellValue("C{$row}", "=DOLLARDE(A{$row}, B{$row})"); + + $helper->log($worksheet->getCell("C{$row}")->getValue()); + $helper->log('DOLLARDE() Result is ' . $worksheet->getCell("C{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/DOLLARFR.php b/samples/Calculations/Financial/DOLLARFR.php new file mode 100644 index 0000000000..75424be03f --- /dev/null +++ b/samples/Calculations/Financial/DOLLARFR.php @@ -0,0 +1,30 @@ +log('Returns the dollar value expressed as a decimal number, into a dollar price, expressed as a fraction.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + [1.0625, 16], + [1.625, 16], + [1.09375, 32], + [1.9375, 32], + [1.375, 32], +]; + +$worksheet->fromArray($arguments, null, 'A1'); + +// Now the formula +for ($row = 1; $row <= 5; ++$row) { + $worksheet->setCellValue("C{$row}", "=DOLLARFR(A{$row}, B{$row})"); + + $helper->log($worksheet->getCell("C{$row}")->getValue()); + $helper->log('DOLLARFR() Result is ' . $worksheet->getCell("C{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/EFFECT.php b/samples/Calculations/Financial/EFFECT.php new file mode 100644 index 0000000000..a74f4500d8 --- /dev/null +++ b/samples/Calculations/Financial/EFFECT.php @@ -0,0 +1,31 @@ +log('Returns the effective annual interest rate for a given nominal interest rate and number of'); +$helper->log('compounding periods per year.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + [0.10, 4], + [0.10, 2], + [0.025, 2], +]; + +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B3')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +for ($row = 1; $row <= 3; ++$row) { + $worksheet->setCellValue("C{$row}", "=EFFECT(A{$row}, B{$row})"); + $worksheet->getStyle("C{$row}")->getNumberFormat()->setFormatCode('0.00%'); + + $helper->log($worksheet->getCell("C{$row}")->getValue()); + $helper->log('EFFECT() Result is ' . $worksheet->getCell("C{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/FV.php b/samples/Calculations/Financial/FV.php new file mode 100644 index 0000000000..31ddb63033 --- /dev/null +++ b/samples/Calculations/Financial/FV.php @@ -0,0 +1,36 @@ +log('Returns the Future Value of an investment with periodic constant payments and a constant interest rate.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate', 0.05, 0.10], + ['Pament Frequency', 12, 4], + ['Duration (Years)', 5, 4], + ['Investment', -1000.00, -2000.00], + ['Payment Type', 0, 1], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:C1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B4:C4')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B8', '=FV(B1/B2, B3*B2, B4)'); +$worksheet->setCellValue('C8', '=FV(C1/C2, C3*C2, C4, null, C5)'); +$worksheet->getStyle('B8:C8')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B8')->getValue()); +$helper->log('FV() Result is ' . $worksheet->getCell('B8')->getFormattedValue()); + +$helper->log($worksheet->getCell('C6')->getValue()); +$helper->log('FV() Result is ' . $worksheet->getCell('C8')->getFormattedValue()); diff --git a/samples/Calculations/Financial/FVSCHEDULE.php b/samples/Calculations/Financial/FVSCHEDULE.php new file mode 100644 index 0000000000..dfd2abbced --- /dev/null +++ b/samples/Calculations/Financial/FVSCHEDULE.php @@ -0,0 +1,36 @@ +log('Returns the Future Value of an initial principal, after applying a series of compound interest rates.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Principal'], + [10000.00], + [null], + ['Schedule'], + [0.05], + [0.05], + [0.035], + [0.035], + [0.035], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('A2')->getNumberFormat()->setFormatCode('$#,##0.00'); +$worksheet->getStyle('A5:A9')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +$worksheet->setCellValue('B1', '=FVSCHEDULE(A2, A5:A9)'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B1')->getValue()); +$helper->log('FVSCHEDULE() Result is ' . $worksheet->getCell('B1')->getFormattedValue()); diff --git a/samples/Calculations/Financial/INTRATE.php b/samples/Calculations/Financial/INTRATE.php new file mode 100644 index 0000000000..594fb6cb89 --- /dev/null +++ b/samples/Calculations/Financial/INTRATE.php @@ -0,0 +1,32 @@ +log('Returns the interest rate for a fully invested security.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Settlement Date', DateHelper::getDateValue('01-Apr-2005')], + ['Maturity Date', DateHelper::getDateValue('31-Mar-2010')], + ['Investment', 1000.00], + ['Investment', 2125.00], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B2')->getNumberFormat()->setFormatCode('dd-mmm-yyyy'); +$worksheet->getStyle('B3:B4')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B7', '=INTRATE(B1, B2, B3, B4)'); +$worksheet->getStyle('B7')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('B7')->getValue()); +$helper->log('INTRATE() Result is ' . $worksheet->getCell('B7')->getFormattedValue()); diff --git a/samples/Calculations/Financial/IPMT.php b/samples/Calculations/Financial/IPMT.php new file mode 100644 index 0000000000..138ec37857 --- /dev/null +++ b/samples/Calculations/Financial/IPMT.php @@ -0,0 +1,37 @@ +log('Returns the interest payment, during a specific period of a loan or investment that is paid in,'); +$helper->log('constant periodic payments, with a constant interest rate.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate', 0.05], + ['Number of Years', 5], + ['Present Value', 50000.00], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B3')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 6; +for ($month = 1; $month <= 12; ++$month) { + $row = (string) ($baseRow + $month); + + $worksheet->setCellValue("A{$row}", "Payment for Mth {$month}"); + $worksheet->setCellValue("B{$row}", "=IPMT(\$B\$1/12, {$month}, \$B\$2*12, \$B\$3)"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("IPMT() Month {$month} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/IRR.php b/samples/Calculations/Financial/IRR.php new file mode 100644 index 0000000000..e489af934c --- /dev/null +++ b/samples/Calculations/Financial/IRR.php @@ -0,0 +1,38 @@ +log('Returns the Internal Rate of Return for a supplied series of periodic cash flows.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Initial Investment', -100.00], + ['Year 1 Income', 20.00], + ['Year 2 Income', 24.00, 'IRR after 3 Years'], + ['Year 3 Income', 28.80], + ['Year 4 Income', 34.56, 'IRR after 5 Years'], + ['Year 5 Income', 41.47], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B6')->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('C4', '=IRR(B1:B4)'); +$worksheet->getStyle('C4')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('C4')->getValue()); +$helper->log('IRR() Result is ' . $worksheet->getCell('C4')->getFormattedValue()); + +$worksheet->setCellValue('C6', '=IRR(B1:B6)'); +$worksheet->getStyle('C6')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('C6')->getValue()); +$helper->log('IRR() Result is ' . $worksheet->getCell('C6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/ISPMT.php b/samples/Calculations/Financial/ISPMT.php new file mode 100644 index 0000000000..cbede7cece --- /dev/null +++ b/samples/Calculations/Financial/ISPMT.php @@ -0,0 +1,36 @@ +log('Returns the interest paid during a specific period of a loan or investment.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate', 0.05], + ['Number of Years', 5], + ['Present Value', 50000.00], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B3')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$baseRow = 6; +for ($month = 1; $month <= 12; ++$month) { + $row = (string) ($baseRow + $month); + + $worksheet->setCellValue("A{$row}", "Payment for Mth {$month}"); + $worksheet->setCellValue("B{$row}", "=ISPMT(\$B\$1/12, {$month}, \$B\$2*12, \$B\$3)"); + $worksheet->getStyle("B{$row}")->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); + + $helper->log($worksheet->getCell("B{$row}")->getValue()); + $helper->log("ISPMT() Month {$month} Result is " . $worksheet->getCell("B{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/MIRR.php b/samples/Calculations/Financial/MIRR.php new file mode 100644 index 0000000000..313e10bd11 --- /dev/null +++ b/samples/Calculations/Financial/MIRR.php @@ -0,0 +1,42 @@ +log('Returns the Modified Internal Rate of Return for a supplied series of periodic cash flows.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Initial Investment', -100.00], + ['Year 1 Income', 18.00], + ['Year 2 Income', 22.50, 'MIRR after 3 Years'], + ['Year 3 Income', 28.00], + ['Year 4 Income', 35.50, 'MIRR after 5 Years'], + ['Year 5 Income', 45.00], + [null], + ['Finance Rate', 0.055], + ['Re-invest Rate', 0.05], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B6')->getNumberFormat()->setFormatCode('$#,##0.00;-$#,##0.00'); +$worksheet->getStyle('B8:B9')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +$worksheet->setCellValue('C4', '=MIRR(B1:B4, B8, B9)'); +$worksheet->getStyle('C4')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('C4')->getValue()); +$helper->log('MIRR() Result is ' . $worksheet->getCell('C4')->getFormattedValue()); + +$worksheet->setCellValue('C6', '=MIRR(B1:B6, B8, B9)'); +$worksheet->getStyle('C6')->getNumberFormat()->setFormatCode('0.00%'); + +$helper->log($worksheet->getCell('C6')->getValue()); +$helper->log('MIRR() Result is ' . $worksheet->getCell('C6')->getFormattedValue()); diff --git a/samples/Calculations/Financial/NOMINAL.php b/samples/Calculations/Financial/NOMINAL.php new file mode 100644 index 0000000000..6b7951a174 --- /dev/null +++ b/samples/Calculations/Financial/NOMINAL.php @@ -0,0 +1,31 @@ +log('Returns the nominal interest rate for a given effective interest rate and number of'); +$helper->log('compounding periods per year.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + [0.10, 4], + [0.10, 2], + [0.025, 12], +]; + +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:B3')->getNumberFormat()->setFormatCode('0.00%'); + +// Now the formula +for ($row = 1; $row <= 3; ++$row) { + $worksheet->setCellValue("C{$row}", "=NOMINAL(A{$row}, B{$row})"); + $worksheet->getStyle("C{$row}")->getNumberFormat()->setFormatCode('0.00%'); + + $helper->log($worksheet->getCell("C{$row}")->getValue()); + $helper->log('NOMINAL() Result is ' . $worksheet->getCell("C{$row}")->getFormattedValue()); +} diff --git a/samples/Calculations/Financial/NPER.php b/samples/Calculations/Financial/NPER.php new file mode 100644 index 0000000000..8acae4737c --- /dev/null +++ b/samples/Calculations/Financial/NPER.php @@ -0,0 +1,39 @@ +log('Returns the number of periods required to pay off a loan, for a constant periodic payment'); +$helper->log('and a constant interest rate.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Interest Rate', 0.04, 0.06], + ['Payments per Year', 1, 4], + ['Payment Amount', -6000.00, -2000], + ['Present Value', 50000, 60000], + ['Future Value', null, 30000], + ['Payment Type', null, FinancialConstants::PAYMENT_BEGINNING_OF_PERIOD], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:C1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B3:C5')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +$worksheet->setCellValue('B8', '=NPER(B1/B2, B3, B4)'); + +$helper->log($worksheet->getCell('B8')->getValue()); +$helper->log('NPER() Result is ' . $worksheet->getCell('B8')->getFormattedValue()); + +$worksheet->setCellValue('C8', '=NPER(C1/C2, C3, C4, C5, C6)'); + +$helper->log($worksheet->getCell('C8')->getValue()); +$helper->log('NPER() Result is ' . $worksheet->getCell('C8')->getFormattedValue()); diff --git a/samples/Calculations/Financial/NPV.php b/samples/Calculations/Financial/NPV.php new file mode 100644 index 0000000000..fa76d54224 --- /dev/null +++ b/samples/Calculations/Financial/NPV.php @@ -0,0 +1,43 @@ +log('Returns the Net Present Value of an investment, based on a supplied discount rate,'); +$helper->log('and a series of future payments and income.'); + +// Create new PhpSpreadsheet object +$spreadsheet = new Spreadsheet(); +$worksheet = $spreadsheet->getActiveSheet(); + +// Add some data +$arguments = [ + ['Annual Discount Rate', 0.02, 0.05], + ['Initial Investment Cost', -5000.00, -10000], + ['Return from Year 1', 800.00, 2000.00], + ['Return from Year 2', 950.00, 2400.00], + ['Return from Year 3', 1080.00, 2900.00], + ['Return from Year 4', 1220.00, 3500.00], + ['Return from Year 5', 1500.00, 4100.00], +]; + +// Some basic formatting for the data +$worksheet->fromArray($arguments, null, 'A1'); +$worksheet->getStyle('B1:C1')->getNumberFormat()->setFormatCode('0.00%'); +$worksheet->getStyle('B2:C7')->getNumberFormat()->setFormatCode('$#,##0.00'); + +// Now the formula +// When initial investment is made at the end of the first period +$worksheet->setCellValue('B10', '=NPV(B1, B2:B7)'); +$worksheet->getStyle('B10')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('B10')->getValue()); +$helper->log('NPV() Result is ' . $worksheet->getCell('B10')->getFormattedValue()); + +// When initial investment is made at the start of the first period +$worksheet->setCellValue('C10', '=NPV(C1, C3:C7) + C2'); +$worksheet->getStyle('C10')->getNumberFormat()->setFormatCode('$#,##0.00'); + +$helper->log($worksheet->getCell('C10')->getValue()); +$helper->log('NPV() Result is ' . $worksheet->getCell('C10')->getFormattedValue()); diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index a11b8a1275..32586b4cb0 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -855,7 +855,7 @@ class Calculation ], 'DISC' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial::class, 'DISC'], + 'functionCall' => [Financial\Securities\Rates::class, 'discount'], 'argumentCount' => '4,5', ], 'DMAX' => [ @@ -1429,7 +1429,7 @@ class Calculation ], 'INTRATE' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial::class, 'INTRATE'], + 'functionCall' => [Financial\Securities\Rates::class, 'interest'], 'argumentCount' => '4,5', ], 'IPMT' => [ @@ -2078,7 +2078,7 @@ class Calculation ], 'RECEIVED' => [ 'category' => Category::CATEGORY_FINANCIAL, - 'functionCall' => [Financial::class, 'RECEIVED'], + 'functionCall' => [Financial\Securities\Price::class, 'received'], 'argumentCount' => '4-5', ], 'REPLACE' => [ diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 636f0c87bb..5b3a8067cc 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -16,7 +16,7 @@ class Helpers * * @return bool TRUE if the year is a leap year, otherwise FALSE */ - public static function isLeapYear($year) + public static function isLeapYear($year): bool { return (($year % 4) === 0) && (($year % 100) !== 0) || (($year % 400) === 0); } @@ -28,7 +28,7 @@ public static function isLeapYear($year) * * @return float Excel date/time serial value */ - public static function getDateValue($dateValue, bool $allowBool = true) + public static function getDateValue($dateValue, bool $allowBool = true): float { if (is_object($dateValue)) { $retval = Date::PHPToExcel($dateValue); diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index ebf5cec187..9d933b4a92 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -10,6 +10,9 @@ use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities; use PhpOffice\PhpSpreadsheet\Calculation\Financial\TreasuryBill; +/** + * @deprecated 1.18.0 + */ class Financial { const FINANCIAL_MAX_ITERATIONS = 128; @@ -30,24 +33,24 @@ class Financial * Use the periodic() method in the Financial\Securities\AccruedInterest class instead * * @param mixed $issue the security's issue date - * @param mixed $firstinterest the security's first interest date + * @param mixed $firstInterest the security's first interest date * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue date * when the security is traded to the buyer. * @param mixed $rate the security's annual coupon rate - * @param mixed $par The security's par value. - * If you omit par, ACCRINT uses $1,000. + * @param mixed $parValue The security's par value. + * If you omit par, ACCRINT uses $1,000. * @param mixed $frequency The number of coupon payments per year. - * Valid frequency values are: - * 1 Annual - * 2 Semi-Annual - * 4 Quarterly + * Valid frequency values are: + * 1 Annual + * 2 Semi-Annual + * 4 Quarterly * @param mixed $basis The type of day count to use. - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * @param mixed $calcMethod * If true, use Issue to Settlement * If false, use FirstInterest to Settlement @@ -56,20 +59,20 @@ class Financial */ public static function ACCRINT( $issue, - $firstinterest, + $firstInterest, $settlement, $rate, - $par = 1000, + $parValue = 1000, $frequency = 1, $basis = 0, $calcMethod = true ) { return Securities\AccruedInterest::periodic( $issue, - $firstinterest, + $firstInterest, $settlement, $rate, - $par, + $parValue, $frequency, $basis, $calcMethod @@ -92,20 +95,20 @@ public static function ACCRINT( * @param mixed $issue The security's issue date * @param mixed $settlement The security's settlement (or maturity) date * @param mixed $rate The security's annual coupon rate - * @param mixed $par The security's par value. - * If you omit par, ACCRINT uses $1,000. + * @param mixed $parValue The security's par value. + * If you omit par, ACCRINT uses $1,000. * @param mixed $basis The type of day count to use. - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * * @return float|string Result, or a string containing an error */ - public static function ACCRINTM($issue, $settlement, $rate, $par = 1000, $basis = 0) + public static function ACCRINTM($issue, $settlement, $rate, $parValue = 1000, $basis = 0) { - return Securities\AccruedInterest::atMaturity($issue, $settlement, $rate, $par, $basis); + return Securities\AccruedInterest::atMaturity($issue, $settlement, $rate, $parValue, $basis); } /** @@ -170,11 +173,11 @@ public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $per * @param float $period The period * @param float $rate Rate of depreciation * @param int $basis The type of day count to use. - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * * @return float|string (string containing the error type if there is an error) */ @@ -543,6 +546,11 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) * Excel Function: * DISC(settlement,maturity,price,redemption[,basis]) * + * @Deprecated 1.18.0 + * + * @see Financial\Securities\Rates::discount() + * Use the discount() method in the Financial\Securities\Rates class instead + * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue * date when the security is traded to the buyer. @@ -561,30 +569,7 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) */ public static function DISC($settlement, $maturity, $price, $redemption, $basis = 0) { - $settlement = Functions::flattenSingleValue($settlement); - $maturity = Functions::flattenSingleValue($maturity); - $price = Functions::flattenSingleValue($price); - $redemption = Functions::flattenSingleValue($redemption); - $basis = Functions::flattenSingleValue($basis); - - // Validate - if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) { - $price = (float) $price; - $redemption = (float) $redemption; - $basis = (int) $basis; - if (($price <= 0) || ($redemption <= 0)) { - return Functions::NAN(); - } - $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); - if (!is_numeric($daysBetweenSettlementAndMaturity)) { - // return date error - return $daysBetweenSettlementAndMaturity; - } - - return (1 - $price / $redemption) / $daysBetweenSettlementAndMaturity; - } - - return Functions::VALUE(); + return Financial\Securities\Rates::discount($settlement, $maturity, $price, $redemption, $basis); } /** @@ -724,47 +709,30 @@ public static function FVSCHEDULE($principal, $schedule) * Excel Function: * INTRATE(settlement,maturity,investment,redemption[,basis]) * + * @Deprecated 1.18.0 + * + * @see Financial\Securities\Rates::interest() + * Use the interest() method in the Financial\Securities\Rates class instead + * * @param mixed $settlement The security's settlement date. - * The security settlement date is the date after the issue date when the security is traded to the buyer. + * The security settlement date is the date after the issue 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. + * The maturity date is the date when the security expires. * @param int $investment the amount invested in the security * @param int $redemption the amount to be received at maturity * @param int $basis The type of day count to use. - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * * @return float|string */ public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0) { - $settlement = Functions::flattenSingleValue($settlement); - $maturity = Functions::flattenSingleValue($maturity); - $investment = Functions::flattenSingleValue($investment); - $redemption = Functions::flattenSingleValue($redemption); - $basis = Functions::flattenSingleValue($basis); - - // Validate - if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) { - $investment = (float) $investment; - $redemption = (float) $redemption; - $basis = (int) $basis; - if (($investment <= 0) || ($redemption <= 0)) { - return Functions::NAN(); - } - $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); - if (!is_numeric($daysBetweenSettlementAndMaturity)) { - // return date error - return $daysBetweenSettlementAndMaturity; - } - - return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity); - } - - return Functions::VALUE(); + return Financial\Securities\Rates::interest($settlement, $maturity, $investment, $redemption, $basis); } /** @@ -1174,7 +1142,12 @@ public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1 /** * RECEIVED. * - * Returns the price per $100 face value of a discounted security. + * Returns the amount received at maturity for a fully invested Security. + * + * @Deprecated 1.18.0 + * + * @see Financial\Securities\Price::received() + * Use the received() method in the Financial\Securities\Price class instead * * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue date when the security @@ -1194,27 +1167,7 @@ public static function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1 */ public static function RECEIVED($settlement, $maturity, $investment, $discount, $basis = 0) { - $settlement = Functions::flattenSingleValue($settlement); - $maturity = Functions::flattenSingleValue($maturity); - $investment = (float) Functions::flattenSingleValue($investment); - $discount = (float) Functions::flattenSingleValue($discount); - $basis = (int) Functions::flattenSingleValue($basis); - - // Validate - if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) { - if (($investment <= 0) || ($discount <= 0)) { - return Functions::NAN(); - } - $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); - if (!is_numeric($daysBetweenSettlementAndMaturity)) { - // return date error - return $daysBetweenSettlementAndMaturity; - } - - return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity)); - } - - return Functions::VALUE(); + return Financial\Securities\Price::received($settlement, $maturity, $investment, $discount, $basis); } /** diff --git a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php index 8b901872d1..2ea0f4fee0 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php @@ -4,12 +4,11 @@ use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; use PhpOffice\PhpSpreadsheet\Calculation\Exception; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Amortization { - use BaseValidations; - /** * AMORDEGRC. * @@ -40,24 +39,33 @@ class Amortization * * @return float|string (string containing the error type if there is an error) */ - public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) - { + public static function AMORDEGRC( + $cost, + $purchased, + $firstPeriod, + $salvage, + $period, + $rate, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $cost = Functions::flattenSingleValue($cost); $purchased = Functions::flattenSingleValue($purchased); $firstPeriod = Functions::flattenSingleValue($firstPeriod); $salvage = Functions::flattenSingleValue($salvage); - $period = floor(Functions::flattenSingleValue($period)); + $period = Functions::flattenSingleValue($period); $rate = Functions::flattenSingleValue($rate); - $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $cost = self::validateFloat($cost); - $purchased = self::validateDate($purchased); - $firstPeriod = self::validateDate($firstPeriod); - $salvage = self::validateFloat($salvage); - $period = self::validateFloat($period); - $rate = self::validateFloat($rate); - $basis = self::validateBasis($basis); + $cost = FinancialValidations::validateFloat($cost); + $purchased = FinancialValidations::validateDate($purchased); + $firstPeriod = FinancialValidations::validateDate($firstPeriod); + $salvage = FinancialValidations::validateFloat($salvage); + $period = FinancialValidations::validateInt($period); + $rate = FinancialValidations::validateFloat($rate); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -118,24 +126,33 @@ public static function AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $per * * @return float|string (string containing the error type if there is an error) */ - public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis = 0) - { + public static function AMORLINC( + $cost, + $purchased, + $firstPeriod, + $salvage, + $period, + $rate, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $cost = Functions::flattenSingleValue($cost); $purchased = Functions::flattenSingleValue($purchased); $firstPeriod = Functions::flattenSingleValue($firstPeriod); $salvage = Functions::flattenSingleValue($salvage); $period = Functions::flattenSingleValue($period); $rate = Functions::flattenSingleValue($rate); - $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $cost = self::validateFloat($cost); - $purchased = self::validateDate($purchased); - $firstPeriod = self::validateDate($firstPeriod); - $salvage = self::validateFloat($salvage); - $period = self::validateFloat($period); - $rate = self::validateFloat($rate); - $basis = self::validateBasis($basis); + $cost = FinancialValidations::validateFloat($cost); + $purchased = FinancialValidations::validateDate($purchased); + $firstPeriod = FinancialValidations::validateDate($firstPeriod); + $salvage = FinancialValidations::validateFloat($salvage); + $period = FinancialValidations::validateFloat($period); + $rate = FinancialValidations::validateFloat($rate); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -149,7 +166,10 @@ public static function AMORLINC($cost, $purchased, $firstPeriod, $salvage, $peri return $yearFrac; } - if (($basis == 1) && ($yearFrac < 1) && (DateTimeExcel\Helpers::isLeapYear($purchasedYear))) { + if ( + ($basis == FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) && + ($yearFrac < 1) && (DateTimeExcel\Helpers::isLeapYear($purchasedYear)) + ) { $yearFrac *= 365 / 366; } diff --git a/src/PhpSpreadsheet/Calculation/Financial/BaseValidations.php b/src/PhpSpreadsheet/Calculation/Financial/BaseValidations.php deleted file mode 100644 index 01d9ab308d..0000000000 --- a/src/PhpSpreadsheet/Calculation/Financial/BaseValidations.php +++ /dev/null @@ -1,72 +0,0 @@ - 4)) { - throw new Exception(Functions::NAN()); - } - - return $basis; - } -} diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php new file mode 100644 index 0000000000..fde688605e --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php @@ -0,0 +1,56 @@ +getMessage(); } - // Validate parameters - if ($numberOfPeriods < 0 || ($type !== 0 && $type !== 1)) { - return Functions::NAN(); - } - return self::calculateFutureValue($rate, $numberOfPeriods, $payment, $presentValue, $type); } @@ -70,26 +69,31 @@ public static function futureValue($rate, $numberOfPeriods, $payment = 0, $prese * * @return float|string Result, or a string containing an error */ - public static function presentValue($rate, $numberOfPeriods, $payment = 0, $futureValue = 0, $type = 0) - { + public static function presentValue( + $rate, + $numberOfPeriods, + $payment = 0.0, + $futureValue = 0.0, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $rate = Functions::flattenSingleValue($rate); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $payment = ($payment === null) ? 0.0 : Functions::flattenSingleValue($payment); $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $rate = self::validateFloat($rate); - $numberOfPeriods = self::validateInt($numberOfPeriods); - $payment = self::validateFloat($payment); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); + $rate = CashFlowValidations::validateRate($rate); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $payment = CashFlowValidations::validateFloat($payment); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($numberOfPeriods < 0 || ($type !== 0 && $type !== 1)) { + if ($numberOfPeriods < 0) { return Functions::NAN(); } @@ -109,26 +113,31 @@ public static function presentValue($rate, $numberOfPeriods, $payment = 0, $futu * * @return float|string Result, or a string containing an error */ - public static function periods($rate, $payment, $presentValue, $futureValue = 0, $type = 0) - { + public static function periods( + $rate, + $payment, + $presentValue, + $futureValue = 0.0, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $rate = Functions::flattenSingleValue($rate); $payment = Functions::flattenSingleValue($payment); $presentValue = Functions::flattenSingleValue($presentValue); $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $rate = self::validateFloat($rate); - $payment = self::validateFloat($payment); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); + $rate = CashFlowValidations::validateRate($rate); + $payment = CashFlowValidations::validateFloat($payment); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($payment == 0.0 || ($type != 0 && $type != 1)) { + if ($payment == 0.0) { return Functions::NAN(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php index 4f6ed17049..b7f6011c31 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php @@ -3,14 +3,12 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PhpOffice\PhpSpreadsheet\Calculation\Exception; -use PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Constants; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\CashFlowValidations; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Cumulative { - use Financial\BaseValidations; - /** * CUMIPMT. * @@ -31,30 +29,33 @@ class Cumulative * * @return float|string */ - public static function interest($rate, $periods, $presentValue, $start, $end, $type = Constants::END_OF_PERIOD) - { + public static function interest( + $rate, + $periods, + $presentValue, + $start, + $end, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $rate = Functions::flattenSingleValue($rate); $periods = Functions::flattenSingleValue($periods); $presentValue = Functions::flattenSingleValue($presentValue); $start = Functions::flattenSingleValue($start); $end = Functions::flattenSingleValue($end); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $rate = self::validateFloat($rate); - $periods = self::validateInt($periods); - $presentValue = self::validateFloat($presentValue); - $start = self::validateInt($start); - $end = self::validateInt($end); - $type = self::validateInt($type); + $rate = CashFlowValidations::validateRate($rate); + $periods = CashFlowValidations::validateInt($periods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $start = CashFlowValidations::validateInt($start); + $end = CashFlowValidations::validateInt($end); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($type !== Constants::END_OF_PERIOD && $type !== Constants::BEGINNING_OF_PERIOD) { - return Functions::NAN(); - } if ($start < 1 || $start > $end) { return Functions::NAN(); } @@ -93,30 +94,33 @@ public static function interest($rate, $periods, $presentValue, $start, $end, $t * * @return float|string */ - public static function principal($rate, $periods, $presentValue, $start, $end, $type = 0) - { + public static function principal( + $rate, + $periods, + $presentValue, + $start, + $end, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $rate = Functions::flattenSingleValue($rate); $periods = Functions::flattenSingleValue($periods); $presentValue = Functions::flattenSingleValue($presentValue); $start = Functions::flattenSingleValue($start); $end = Functions::flattenSingleValue($end); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $rate = self::validateFloat($rate); - $periods = self::validateInt($periods); - $presentValue = self::validateFloat($presentValue); - $start = self::validateInt($start); - $end = self::validateInt($end); - $type = self::validateInt($type); + $rate = CashFlowValidations::validateRate($rate); + $periods = CashFlowValidations::validateInt($periods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $start = CashFlowValidations::validateInt($start); + $end = CashFlowValidations::validateInt($end); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($type !== 0 && $type !== 1) { - return Functions::NAN(); - } if ($start < 1 || $start > $end) { return Functions::VALUE(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php index 3f579ce248..56d2e37929 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php @@ -3,13 +3,12 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PhpOffice\PhpSpreadsheet\Calculation\Exception; -use PhpOffice\PhpSpreadsheet\Calculation\Financial\BaseValidations; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\CashFlowValidations; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Interest { - use BaseValidations; - private const FINANCIAL_MAX_ITERATIONS = 128; private const FINANCIAL_PRECISION = 1.0e-08; @@ -32,30 +31,33 @@ class Interest * * @return float|string */ - public static function payment($interestRate, $period, $numberOfPeriods, $presentValue, $futureValue = 0, $type = 0) - { + public static function payment( + $interestRate, + $period, + $numberOfPeriods, + $presentValue, + $futureValue = 0, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $interestRate = Functions::flattenSingleValue($interestRate); $period = Functions::flattenSingleValue($period); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $presentValue = Functions::flattenSingleValue($presentValue); - $futureValue = Functions::flattenSingleValue($futureValue); - $type = Functions::flattenSingleValue($type); + $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $interestRate = self::validateFloat($interestRate); - $period = self::validateInt($period); - $numberOfPeriods = self::validateInt($numberOfPeriods); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); + $interestRate = CashFlowValidations::validateRate($interestRate); + $period = CashFlowValidations::validateInt($period); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($type != 0 && $type != 1) { - return Functions::NAN(); - } if ($period <= 0 || $period > $numberOfPeriods) { return Functions::NAN(); } @@ -94,17 +96,19 @@ public static function schedulePayment($interestRate, $period, $numberOfPeriods, $principleRemaining = Functions::flattenSingleValue($principleRemaining); try { - $interestRate = self::validateFloat($interestRate); - $period = self::validateInt($period); - $numberOfPeriods = self::validateInt($numberOfPeriods); - $principleRemaining = self::validateFloat($principleRemaining); + $interestRate = CashFlowValidations::validateRate($interestRate); + $period = CashFlowValidations::validateInt($period); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $principleRemaining = CashFlowValidations::validateFloat($principleRemaining); } catch (Exception $e) { return $e->getMessage(); } + // Validate parameters if ($period <= 0 || $period > $numberOfPeriods) { return Functions::NAN(); } + // Return value $returnValue = 0; @@ -148,22 +152,28 @@ public static function schedulePayment($interestRate, $period, $numberOfPeriods, * * @return float|string */ - public static function rate($numberOfPeriods, $payment, $presentValue, $futureValue = 0.0, $type = 0, $guess = 0.1) - { + public static function rate( + $numberOfPeriods, + $payment, + $presentValue, + $futureValue = 0.0, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD, + $guess = 0.1 + ) { $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $payment = Functions::flattenSingleValue($payment); $presentValue = Functions::flattenSingleValue($presentValue); $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); $guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess); try { - $numberOfPeriods = self::validateInt($numberOfPeriods); - $payment = self::validateFloat($payment); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); - $guess = self::validateFloat($guess); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $payment = CashFlowValidations::validateFloat($payment); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); + $guess = CashFlowValidations::validateFloat($guess); } catch (Exception $e) { return $e->getMessage(); } @@ -188,7 +198,7 @@ public static function rate($numberOfPeriods, $payment, $presentValue, $futureVa private static function rateNextGuess($rate, $numberOfPeriods, $payment, $presentValue, $futureValue, $type) { - if ($rate == 0) { + if ($rate == 0.0) { return Functions::NAN(); } $tt1 = ($rate + 1) ** $numberOfPeriods; diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php index 5e76f34612..ca989e0058 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; + class InterestAndPrincipal { protected $interest; @@ -14,14 +16,14 @@ public function __construct( int $numberOfPeriods = 0, float $presentValue = 0, float $futureValue = 0, - int $type = 0 + int $type = FinancialConstants::PAYMENT_END_OF_PERIOD ) { $payment = Payments::annuity($rate, $numberOfPeriods, $presentValue, $futureValue, $type); $capital = $presentValue; $interest = 0.0; $principal = 0.0; for ($i = 1; $i <= $period; ++$i) { - $interest = ($type && $i == 1) ? 0 : -$capital * $rate; + $interest = ($type === FinancialConstants::PAYMENT_BEGINNING_OF_PERIOD && $i == 1) ? 0 : -$capital * $rate; $principal = $payment - $interest; $capital += $principal; } diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php index a0c6158614..e103f92366 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php @@ -3,13 +3,12 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\Constant\Periodic; use PhpOffice\PhpSpreadsheet\Calculation\Exception; -use PhpOffice\PhpSpreadsheet\Calculation\Financial\BaseValidations; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow\CashFlowValidations; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Payments { - use BaseValidations; - /** * PMT. * @@ -23,29 +22,29 @@ class Payments * * @return float|string Result, or a string containing an error */ - public static function annuity($interestRate, $numberOfPeriods, $presentValue, $futureValue = 0, $type = 0) - { + public static function annuity( + $interestRate, + $numberOfPeriods, + $presentValue, + $futureValue = 0, + $type = FinancialConstants::PAYMENT_END_OF_PERIOD + ) { $interestRate = Functions::flattenSingleValue($interestRate); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $presentValue = Functions::flattenSingleValue($presentValue); $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $interestRate = self::validateFloat($interestRate); - $numberOfPeriods = self::validateInt($numberOfPeriods); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); + $interestRate = CashFlowValidations::validateRate($interestRate); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } - // Validate parameters - if ($type != 0 && $type != 1) { - return Functions::NAN(); - } - // Calculate if ($interestRate != 0.0) { return (-$futureValue - $presentValue * (1 + $interestRate) ** $numberOfPeriods) / @@ -76,30 +75,27 @@ public static function interestPayment( $numberOfPeriods, $presentValue, $futureValue = 0, - $type = 0 + $type = FinancialConstants::PAYMENT_END_OF_PERIOD ) { $interestRate = Functions::flattenSingleValue($interestRate); $period = Functions::flattenSingleValue($period); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $presentValue = Functions::flattenSingleValue($presentValue); $futureValue = ($futureValue === null) ? 0.0 : Functions::flattenSingleValue($futureValue); - $type = ($type === null) ? 0 : Functions::flattenSingleValue($type); + $type = ($type === null) ? FinancialConstants::PAYMENT_END_OF_PERIOD : Functions::flattenSingleValue($type); try { - $interestRate = self::validateFloat($interestRate); - $period = self::validateInt($period); - $numberOfPeriods = self::validateInt($numberOfPeriods); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); - $type = self::validateInt($type); + $interestRate = CashFlowValidations::validateRate($interestRate); + $period = CashFlowValidations::validateInt($period); + $numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); + $type = CashFlowValidations::validatePeriodType($type); } catch (Exception $e) { return $e->getMessage(); } // Validate parameters - if ($type != 0 && $type != 1) { - return Functions::NAN(); - } if ($period <= 0 || $period > $numberOfPeriods) { return Functions::NAN(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php index 9fecd75537..a30634da3b 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php @@ -3,13 +3,10 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\CashFlow; use PhpOffice\PhpSpreadsheet\Calculation\Exception; -use PhpOffice\PhpSpreadsheet\Calculation\Financial\BaseValidations; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Single { - use BaseValidations; - /** * FVSCHEDULE. * @@ -30,10 +27,10 @@ public static function futureValue($principal, $schedule) $schedule = Functions::flattenArray($schedule); try { - $principal = self::validateFloat($principal); + $principal = CashFlowValidations::validateFloat($principal); foreach ($schedule as $rate) { - $rate = self::validateFloat($rate); + $rate = CashFlowValidations::validateFloat($rate); $principal *= 1 + $rate; } } catch (Exception $e) { @@ -48,22 +45,22 @@ public static function futureValue($principal, $schedule) * * Calculates the number of periods required for an investment to reach a specified value. * - * @param float $rate Interest rate per period - * @param float $presentValue Present Value - * @param float $futureValue Future Value + * @param mixed $rate Interest rate per period + * @param mixed $presentValue Present Value + * @param mixed $futureValue Future Value * * @return float|string Result, or a string containing an error */ - public static function periods($rate = 0.0, $presentValue = 0.0, $futureValue = 0.0) + public static function periods($rate, $presentValue, $futureValue) { $rate = Functions::flattenSingleValue($rate); $presentValue = Functions::flattenSingleValue($presentValue); $futureValue = Functions::flattenSingleValue($futureValue); try { - $rate = self::validateFloat($rate); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); + $rate = CashFlowValidations::validateRate($rate); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); } catch (Exception $e) { return $e->getMessage(); } @@ -94,9 +91,9 @@ public static function interestRate($periods = 0.0, $presentValue = 0.0, $future $futureValue = Functions::flattenSingleValue($futureValue); try { - $periods = self::validateFloat($periods); - $presentValue = self::validateFloat($presentValue); - $futureValue = self::validateFloat($futureValue); + $periods = CashFlowValidations::validateFloat($periods); + $presentValue = CashFlowValidations::validatePresentValue($presentValue); + $futureValue = CashFlowValidations::validateFutureValue($futureValue); } catch (Exception $e) { return $e->getMessage(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Constants.php b/src/PhpSpreadsheet/Calculation/Financial/Constants.php new file mode 100644 index 0000000000..17740b0acd --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Financial/Constants.php @@ -0,0 +1,19 @@ +getMessage(); } @@ -68,7 +69,7 @@ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = He } $prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_PREVIOUS); - if ($basis === Helpers::DAYS_PER_YEAR_ACTUAL) { + if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL) { return abs(DateTimeExcel\Days::funcDays($prev, $settlement)); } @@ -102,30 +103,36 @@ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis = He * * @return float|string */ - public static function COUPDAYS($settlement, $maturity, $frequency, $basis = Helpers::DAYS_PER_YEAR_NASD) - { + public static function COUPDAYS( + $settlement, + $maturity, + $frequency, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); self::validateCouponPeriod($settlement, $maturity); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $frequency = FinancialValidations::validateFrequency($frequency); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } switch ($basis) { - case Helpers::DAYS_PER_YEAR_365: + case FinancialConstants::BASIS_DAYS_PER_YEAR_365: // Actual/365 return 365 / $frequency; - case Helpers::DAYS_PER_YEAR_ACTUAL: + case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL: // Actual/actual - if ($frequency == self::FREQUENCY_ANNUAL) { + if ($frequency == FinancialConstants::FREQUENCY_ANNUAL) { $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis); return $daysPerYear / $frequency; @@ -167,19 +174,25 @@ public static function COUPDAYS($settlement, $maturity, $frequency, $basis = Hel * * @return float|string */ - public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = Helpers::DAYS_PER_YEAR_NASD) - { + public static function COUPDAYSNC( + $settlement, + $maturity, + $frequency, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); self::validateCouponPeriod($settlement, $maturity); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $frequency = FinancialValidations::validateFrequency($frequency); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -187,7 +200,7 @@ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = H $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis); $next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT); - if ($basis === Helpers::DAYS_PER_YEAR_NASD) { + if ($basis === FinancialConstants::BASIS_DAYS_PER_YEAR_NASD) { $settlementDate = Date::excelToDateTimeObject($settlement); $settlementEoM = Helpers::isLastDayOfMonth($settlementDate); if ($settlementEoM) { @@ -226,19 +239,25 @@ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = H * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ - public static function COUPNCD($settlement, $maturity, $frequency, $basis = Helpers::DAYS_PER_YEAR_NASD) - { + public static function COUPNCD( + $settlement, + $maturity, + $frequency, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); self::validateCouponPeriod($settlement, $maturity); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $frequency = FinancialValidations::validateFrequency($frequency); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -274,19 +293,25 @@ public static function COUPNCD($settlement, $maturity, $frequency, $basis = Help * * @return int|string */ - public static function COUPNUM($settlement, $maturity, $frequency, $basis = Helpers::DAYS_PER_YEAR_NASD) - { + public static function COUPNUM( + $settlement, + $maturity, + $frequency, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); self::validateCouponPeriod($settlement, $maturity); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $frequency = FinancialValidations::validateFrequency($frequency); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -294,7 +319,7 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = Help $yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac( $settlement, $maturity, - Helpers::DAYS_PER_YEAR_NASD + FinancialConstants::BASIS_DAYS_PER_YEAR_NASD ); return (int) ceil($yearsBetweenSettlementAndMaturity * $frequency); @@ -328,19 +353,25 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = Help * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ - public static function COUPPCD($settlement, $maturity, $frequency, $basis = Helpers::DAYS_PER_YEAR_NASD) - { + public static function COUPPCD( + $settlement, + $maturity, + $frequency, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); self::validateCouponPeriod($settlement, $maturity); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $frequency = FinancialValidations::validateFrequency($frequency); + $basis = FinancialValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php index a918bf7d88..650a4861b2 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php @@ -7,8 +7,6 @@ class Depreciation { - use BaseValidations; - /** * DB. * @@ -127,7 +125,10 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) $previousDepreciation = 0; $depreciation = 0; for ($per = 1; $per <= $period; ++$per) { - $depreciation = min(($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation)); + $depreciation = min( + ($cost - $previousDepreciation) * ($factor / $life), + ($cost - $salvage - $previousDepreciation) + ); $previousDepreciation += $depreciation; } @@ -205,7 +206,7 @@ public static function SYD($cost, $salvage, $life, $period) private static function validateCost($cost, bool $negativeValueAllowed = false): float { - $cost = self::validateFloat($cost); + $cost = FinancialValidations::validateFloat($cost); if ($cost < 0.0 && $negativeValueAllowed === false) { throw new Exception(Functions::NAN()); } @@ -215,7 +216,7 @@ private static function validateCost($cost, bool $negativeValueAllowed = false): private static function validateSalvage($salvage, bool $negativeValueAllowed = false): float { - $salvage = self::validateFloat($salvage); + $salvage = FinancialValidations::validateFloat($salvage); if ($salvage < 0.0 && $negativeValueAllowed === false) { throw new Exception(Functions::NAN()); } @@ -225,7 +226,7 @@ private static function validateSalvage($salvage, bool $negativeValueAllowed = f private static function validateLife($life, bool $negativeValueAllowed = false): float { - $life = self::validateFloat($life); + $life = FinancialValidations::validateFloat($life); if ($life < 0.0 && $negativeValueAllowed === false) { throw new Exception(Functions::NAN()); } @@ -235,7 +236,7 @@ private static function validateLife($life, bool $negativeValueAllowed = false): private static function validatePeriod($period, bool $negativeValueAllowed = false): float { - $period = self::validateFloat($period); + $period = FinancialValidations::validateFloat($period); if ($period <= 0.0 && $negativeValueAllowed === false) { throw new Exception(Functions::NAN()); } @@ -245,7 +246,7 @@ private static function validatePeriod($period, bool $negativeValueAllowed = fal private static function validateMonth($month): int { - $month = self::validateInt($month); + $month = FinancialValidations::validateInt($month); if ($month < 1) { throw new Exception(Functions::NAN()); } @@ -255,7 +256,7 @@ private static function validateMonth($month): int private static function validateFactor($factor): float { - $factor = self::validateFloat($factor); + $factor = FinancialValidations::validateFloat($factor); if ($factor <= 0.0) { throw new Exception(Functions::NAN()); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/BaseValidations.php b/src/PhpSpreadsheet/Calculation/Financial/FinancialValidations.php similarity index 51% rename from src/PhpSpreadsheet/Calculation/Financial/Securities/BaseValidations.php rename to src/PhpSpreadsheet/Calculation/Financial/FinancialValidations.php index bd197d7f9e..310e0051c9 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/BaseValidations.php +++ b/src/PhpSpreadsheet/Calculation/Financial/FinancialValidations.php @@ -1,51 +1,66 @@ = $maturity) { - throw new Exception(Functions::NAN()); + if (!is_numeric($value)) { + throw new Exception(Functions::VALUE()); } + + return (int) floor((float) $value); } - protected static function validateRate($rate): float + /** + * @param mixed $rate + */ + public static function validateRate($rate): float { $rate = self::validateFloat($rate); if ($rate < 0.0) { @@ -55,85 +70,89 @@ protected static function validateRate($rate): float return $rate; } - protected static function validateParValue($parValue): float + /** + * @param mixed $frequency + */ + public static function validateFrequency($frequency): int { - $parValue = self::validateFloat($parValue); - if ($parValue < 0.0) { + $frequency = self::validateInt($frequency); + if ( + ($frequency !== FinancialConstants::FREQUENCY_ANNUAL) && + ($frequency !== FinancialConstants::FREQUENCY_SEMI_ANNUAL) && + ($frequency !== FinancialConstants::FREQUENCY_QUARTERLY) + ) { throw new Exception(Functions::NAN()); } - return $parValue; + return $frequency; } - protected static function validatePrice($price): float + /** + * @param mixed $basis + */ + public static function validateBasis($basis): int { - $price = self::validateFloat($price); - if ($price < 0.0) { - throw new Exception(Functions::NAN()); + if (!is_numeric($basis)) { + throw new Exception(Functions::VALUE()); } - return $price; - } - - protected static function validateYield($yield): float - { - $yield = self::validateFloat($yield); - if ($yield < 0.0) { + $basis = (int) $basis; + if (($basis < 0) || ($basis > 4)) { throw new Exception(Functions::NAN()); } - return $yield; + return $basis; } - protected static function validateRedemption($redemption): float + /** + * @param mixed $price + */ + public static function validatePrice($price): float { - $redemption = self::validateFloat($redemption); - if ($redemption <= 0.0) { + $price = self::validateFloat($price); + if ($price < 0.0) { throw new Exception(Functions::NAN()); } - return $redemption; + return $price; } - protected static function validateDiscount($discount): float + /** + * @param mixed $parValue + */ + public static function validateParValue($parValue): float { - $discount = self::validateFloat($discount); - if ($discount <= 0.0) { + $parValue = self::validateFloat($parValue); + if ($parValue < 0.0) { throw new Exception(Functions::NAN()); } - return $discount; + return $parValue; } - protected static function validateFrequency($frequency): int + /** + * @param mixed $yield + */ + public static function validateYield($yield): float { - if (!is_numeric($frequency)) { - throw new Exception(Functions::VALUE()); - } - - $frequency = (int) $frequency; - if ( - ($frequency !== SecuritiesConstants::FREQUENCY_ANNUAL) && - ($frequency !== SecuritiesConstants::FREQUENCY_SEMI_ANNUAL) && - ($frequency !== SecuritiesConstants::FREQUENCY_QUARTERLY) - ) { + $yield = self::validateFloat($yield); + if ($yield < 0.0) { throw new Exception(Functions::NAN()); } - return $frequency; + return $yield; } - protected static function validateBasis($basis): int + /** + * @param mixed $discount + */ + public static function validateDiscount($discount): float { - if (!is_numeric($basis)) { - throw new Exception(Functions::VALUE()); - } - - $basis = (int) $basis; - if (($basis < 0) || ($basis > 4)) { + $discount = self::validateFloat($discount); + if ($discount <= 0.0) { throw new Exception(Functions::NAN()); } - return $basis; + return $discount; } } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Helpers.php b/src/PhpSpreadsheet/Calculation/Financial/Helpers.php index 79ef61e35c..d339b13416 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Helpers.php @@ -4,16 +4,11 @@ use DateTimeInterface; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Helpers { - public const DAYS_PER_YEAR_NASD = 0; - public const DAYS_PER_YEAR_ACTUAL = 1; - public const DAYS_PER_YEAR_360 = 2; - public const DAYS_PER_YEAR_365 = 3; - public const DAYS_PER_YEAR_360_EUROPEAN = 4; - /** * daysPerYear. * @@ -21,11 +16,11 @@ class Helpers * * @param int|string $year The year against which we're testing * @param int|string $basis The type of day count: - * 0 or omitted US (NASD) 360 - * 1 Actual (365 or 366 in a leap year) - * 2 360 - * 3 365 - * 4 European 360 + * 0 or omitted US (NASD) 360 + * 1 Actual (365 or 366 in a leap year) + * 2 360 + * 3 365 + * 4 European 360 * * @return int|string Result, or a string containing an error */ @@ -36,13 +31,13 @@ public static function daysPerYear($year, $basis = 0) } switch ($basis) { - case self::DAYS_PER_YEAR_NASD: - case self::DAYS_PER_YEAR_360: - case self::DAYS_PER_YEAR_360_EUROPEAN: + case FinancialConstants::BASIS_DAYS_PER_YEAR_NASD: + case FinancialConstants::BASIS_DAYS_PER_YEAR_360: + case FinancialConstants::BASIS_DAYS_PER_YEAR_360_EUROPEAN: return 360; - case self::DAYS_PER_YEAR_365: + case FinancialConstants::BASIS_DAYS_PER_YEAR_365: return 365; - case self::DAYS_PER_YEAR_ACTUAL: + case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL: return (DateTimeExcel\Helpers::isLeapYear($year)) ? 366 : 365; } @@ -55,10 +50,8 @@ public static function daysPerYear($year, $basis = 0) * Returns a boolean TRUE/FALSE indicating if this date is the last date of the month * * @param DateTimeInterface $date The date for testing - * - * @return bool */ - public static function isLastDayOfMonth(DateTimeInterface $date) + public static function isLastDayOfMonth(DateTimeInterface $date): bool { return $date->format('d') === $date->format('t'); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php b/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php index 7d66c89121..72df31e164 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php +++ b/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php @@ -7,8 +7,6 @@ class InterestRate { - use BaseValidations; - /** * EFFECT. * @@ -29,8 +27,8 @@ public static function effective($nominalRate = 0, $periodsPerYear = 0) $periodsPerYear = Functions::flattenSingleValue($periodsPerYear); try { - $nominalRate = self::validateFloat($nominalRate); - $periodsPerYear = self::validateInt($periodsPerYear); + $nominalRate = FinancialValidations::validateFloat($nominalRate); + $periodsPerYear = FinancialValidations::validateInt($periodsPerYear); } catch (Exception $e) { return $e->getMessage(); } @@ -58,8 +56,8 @@ public static function nominal($effectiveRate = 0, $periodsPerYear = 0) $periodsPerYear = Functions::flattenSingleValue($periodsPerYear); try { - $effectiveRate = self::validateFloat($effectiveRate); - $periodsPerYear = self::validateInt($periodsPerYear); + $effectiveRate = FinancialValidations::validateFloat($effectiveRate); + $periodsPerYear = FinancialValidations::validateInt($periodsPerYear); } catch (Exception $e) { return $e->getMessage(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php index 1875b8b7a5..004b47f311 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/AccruedInterest.php @@ -4,12 +4,11 @@ use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\YearFrac; use PhpOffice\PhpSpreadsheet\Calculation\Exception; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class AccruedInterest { - use BaseValidations; - public const ACCRINT_CALCMODE_ISSUE_TO_SETTLEMENT = true; public const ACCRINT_CALCMODE_FIRST_INTEREST_TO_SETTLEMENT = false; @@ -23,7 +22,7 @@ class AccruedInterest * ACCRINT(issue,firstinterest,settlement,rate,par,frequency[,basis][,calc_method]) * * @param mixed $issue the security's issue date - * @param mixed $firstinterest the security's first interest date + * @param mixed $firstInterest the security's first interest date * @param mixed $settlement The security's settlement date. * The security settlement date is the date after the issue date * when the security is traded to the buyer. @@ -47,30 +46,34 @@ class AccruedInterest */ public static function periodic( $issue, - $firstinterest, + $firstInterest, $settlement, $rate, $parValue = 1000, - $frequency = 1, - $basis = 0, + $frequency = FinancialConstants::FREQUENCY_ANNUAL, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD, $calcMethod = self::ACCRINT_CALCMODE_ISSUE_TO_SETTLEMENT ) { $issue = Functions::flattenSingleValue($issue); - $firstinterest = Functions::flattenSingleValue($firstinterest); + $firstInterest = Functions::flattenSingleValue($firstInterest); $settlement = Functions::flattenSingleValue($settlement); $rate = Functions::flattenSingleValue($rate); $parValue = ($parValue === null) ? 1000 : Functions::flattenSingleValue($parValue); - $frequency = ($frequency === null) ? 1 : Functions::flattenSingleValue($frequency); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $frequency = ($frequency === null) + ? FinancialConstants::FREQUENCY_ANNUAL + : Functions::flattenSingleValue($frequency); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $issue = self::validateIssueDate($issue); - $settlement = self::validateSettlementDate($settlement); - self::validateSecurityPeriod($issue, $settlement); - $rate = self::validateRate($rate); - $parValue = self::validateParValue($parValue); - $frequency = self::validateFrequency($frequency); - $basis = self::validateBasis($basis); + $issue = SecurityValidations::validateIssueDate($issue); + $settlement = SecurityValidations::validateSettlementDate($settlement); + SecurityValidations::validateSecurityPeriod($issue, $settlement); + $rate = SecurityValidations::validateRate($rate); + $parValue = SecurityValidations::validateParValue($parValue); + $frequency = SecurityValidations::validateFrequency($frequency); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -80,7 +83,7 @@ public static function periodic( // return date error return $daysBetweenIssueAndSettlement; } - $daysBetweenFirstInterestAndSettlement = YearFrac::funcYearFrac($firstinterest, $settlement, $basis); + $daysBetweenFirstInterestAndSettlement = YearFrac::funcYearFrac($firstInterest, $settlement, $basis); if (!is_numeric($daysBetweenFirstInterestAndSettlement)) { // return date error return $daysBetweenFirstInterestAndSettlement; @@ -101,7 +104,7 @@ public static function periodic( * @param mixed $settlement The security's settlement (or maturity) date * @param mixed $rate The security's annual coupon rate * @param mixed $parValue The security's par value. - * If you omit par, ACCRINT uses $1,000. + * If you omit parValue, ACCRINT uses $1,000. * @param mixed $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -111,21 +114,28 @@ public static function periodic( * * @return float|string Result, or a string containing an error */ - public static function atMaturity($issue, $settlement, $rate, $parValue = 1000, $basis = 0) - { + public static function atMaturity( + $issue, + $settlement, + $rate, + $parValue = 1000, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $issue = Functions::flattenSingleValue($issue); $settlement = Functions::flattenSingleValue($settlement); $rate = Functions::flattenSingleValue($rate); $parValue = ($parValue === null) ? 1000 : Functions::flattenSingleValue($parValue); - $basis = ($basis === null) ? 0 : Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $issue = self::validateIssueDate($issue); - $settlement = self::validateSettlementDate($settlement); - self::validateSecurityPeriod($issue, $settlement); - $rate = self::validateRate($rate); - $parValue = self::validateParValue($parValue); - $basis = self::validateBasis($basis); + $issue = SecurityValidations::validateIssueDate($issue); + $settlement = SecurityValidations::validateSettlementDate($settlement); + SecurityValidations::validateSecurityPeriod($issue, $settlement); + $rate = SecurityValidations::validateRate($rate); + $parValue = SecurityValidations::validateParValue($parValue); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/Constants.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/Constants.php deleted file mode 100644 index f7bc273172..0000000000 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ -getMessage(); } @@ -100,21 +108,28 @@ public static function price($settlement, $maturity, $rate, $yield, $redemption, * * @return float|string Result, or a string containing an error */ - public static function priceDiscounted($settlement, $maturity, $discount, $redemption, $basis = 0) - { + public static function priceDiscounted( + $settlement, + $maturity, + $discount, + $redemption, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $discount = Functions::flattenSingleValue($discount); $redemption = Functions::flattenSingleValue($redemption); - $basis = Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); - self::validateSecurityPeriod($settlement, $maturity); - $discount = self::validateDiscount($discount); - $redemption = self::validateRedemption($redemption); - $basis = self::validateBasis($basis); + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $discount = SecurityValidations::validateDiscount($discount); + $redemption = SecurityValidations::validateRedemption($redemption); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -150,23 +165,31 @@ public static function priceDiscounted($settlement, $maturity, $discount, $redem * * @return float|string Result, or a string containing an error */ - public static function priceAtMaturity($settlement, $maturity, $issue, $rate, $yield, $basis = 0) - { + public static function priceAtMaturity( + $settlement, + $maturity, + $issue, + $rate, + $yield, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $issue = Functions::flattenSingleValue($issue); $rate = Functions::flattenSingleValue($rate); $yield = Functions::flattenSingleValue($yield); - $basis = Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); - self::validateSecurityPeriod($settlement, $maturity); - $issue = self::validateIssueDate($issue); - $rate = self::validateRate($rate); - $yield = self::validateYield($yield); - $basis = self::validateBasis($basis); + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $issue = SecurityValidations::validateIssueDate($issue); + $rate = SecurityValidations::validateRate($rate); + $yield = SecurityValidations::validateYield($yield); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -198,4 +221,63 @@ public static function priceAtMaturity($settlement, $maturity, $issue, $rate, $y (1 + (($daysBetweenSettlementAndMaturity / $daysPerYear) * $yield)) - (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate * 100); } + + /** + * RECEIVED. + * + * Returns the amount received at maturity for a fully invested Security. + * + * @param mixed $settlement The security's settlement date. + * The security settlement date is the date after the issue 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 mixed $investment The amount invested in the security + * @param mixed $discount The security's discount rate + * @param mixed $basis The type of day count to use. + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 + * + * @return float|string Result, or a string containing an error + */ + public static function received( + $settlement, + $maturity, + $investment, + $discount, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { + $settlement = Functions::flattenSingleValue($settlement); + $maturity = Functions::flattenSingleValue($maturity); + $investment = Functions::flattenSingleValue($investment); + $discount = Functions::flattenSingleValue($discount); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); + + try { + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $investment = SecurityValidations::validateFloat($investment); + $discount = SecurityValidations::validateDiscount($discount); + $basis = SecurityValidations::validateBasis($basis); + } catch (Exception $e) { + return $e->getMessage(); + } + + if ($investment <= 0) { + return Functions::NAN(); + } + $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); + if (!is_numeric($daysBetweenSettlementAndMaturity)) { + // return date error + return $daysBetweenSettlementAndMaturity; + } + + return $investment / (1 - ($discount * $daysBetweenSettlementAndMaturity)); + } } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php new file mode 100644 index 0000000000..5a32d1d101 --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php @@ -0,0 +1,137 @@ +getMessage(); + } + + if ($price <= 0.0) { + return Functions::NAN(); + } + + $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); + if (!is_numeric($daysBetweenSettlementAndMaturity)) { + // return date error + return $daysBetweenSettlementAndMaturity; + } + + return (1 - $price / $redemption) / $daysBetweenSettlementAndMaturity; + } + + /** + * INTRATE. + * + * Returns the interest rate for a fully invested security. + * + * Excel Function: + * INTRATE(settlement,maturity,investment,redemption[,basis]) + * + * @param mixed $settlement The security's settlement date. + * The security settlement date is the date after the issue 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 mixed $investment the amount invested in the security + * @param mixed $redemption the amount to be received at maturity + * @param mixed $basis The type of day count to use. + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 + * + * @return float|string + */ + public static function interest( + $settlement, + $maturity, + $investment, + $redemption, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { + $settlement = Functions::flattenSingleValue($settlement); + $maturity = Functions::flattenSingleValue($maturity); + $investment = Functions::flattenSingleValue($investment); + $redemption = Functions::flattenSingleValue($redemption); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); + + try { + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $investment = SecurityValidations::validateFloat($investment); + $redemption = SecurityValidations::validateRedemption($redemption); + $basis = SecurityValidations::validateBasis($basis); + } catch (Exception $e) { + return $e->getMessage(); + } + + if ($investment <= 0) { + return Functions::NAN(); + } + + $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis); + if (!is_numeric($daysBetweenSettlementAndMaturity)) { + // return date error + return $daysBetweenSettlementAndMaturity; + } + + return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity); + } +} diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/SecurityValidations.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/SecurityValidations.php new file mode 100644 index 0000000000..497197b843 --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/SecurityValidations.php @@ -0,0 +1,42 @@ += $maturity) { + throw new Exception(Functions::NAN()); + } + } + + /** + * @param mixed $redemption + */ + public static function validateRedemption($redemption): float + { + $redemption = self::validateFloat($redemption); + if ($redemption <= 0.0) { + throw new Exception(Functions::NAN()); + } + + return $redemption; + } +} diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php index 46c3bb05ce..bdd638fa09 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/Yields.php @@ -4,13 +4,12 @@ use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; use PhpOffice\PhpSpreadsheet\Calculation\Exception; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Financial\Helpers; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class Yields { - use BaseValidations; - /** * YIELDDISC. * @@ -21,32 +20,39 @@ class Yields * 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 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 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * @param mixed $price The security's price per $100 face value + * @param mixed $redemption The security's redemption value per $100 face value + * @param mixed $basis The type of day count to use. + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * * @return float|string Result, or a string containing an error */ - public static function yieldDiscounted($settlement, $maturity, $price, $redemption, $basis = 0) - { + public static function yieldDiscounted( + $settlement, + $maturity, + $price, + $redemption, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $price = Functions::flattenSingleValue($price); $redemption = Functions::flattenSingleValue($redemption); - $basis = (int) Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); - self::validateSecurityPeriod($settlement, $maturity); - $price = self::validatePrice($price); - $redemption = self::validateRedemption($redemption); - $basis = self::validateBasis($basis); + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $price = SecurityValidations::validatePrice($price); + $redemption = SecurityValidations::validateRedemption($redemption); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -76,34 +82,42 @@ public static function yieldDiscounted($settlement, $maturity, $price, $redempti * @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 int $basis The type of day count to use. - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 + * @param mixed $rate The security's interest rate at date of issue + * @param mixed $price The security's price per $100 face value + * @param mixed $basis The type of day count to use. + * 0 or omitted US (NASD) 30/360 + * 1 Actual/actual + * 2 Actual/360 + * 3 Actual/365 + * 4 European 30/360 * * @return float|string Result, or a string containing an error */ - public static function yieldAtMaturity($settlement, $maturity, $issue, $rate, $price, $basis = 0) - { + public static function yieldAtMaturity( + $settlement, + $maturity, + $issue, + $rate, + $price, + $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + ) { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $issue = Functions::flattenSingleValue($issue); $rate = Functions::flattenSingleValue($rate); $price = Functions::flattenSingleValue($price); - $basis = Functions::flattenSingleValue($basis); + $basis = ($basis === null) + ? FinancialConstants::BASIS_DAYS_PER_YEAR_NASD + : Functions::flattenSingleValue($basis); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); - self::validateSecurityPeriod($settlement, $maturity); - $issue = self::validateIssueDate($issue); - $rate = self::validateRate($rate); - $price = self::validatePrice($price); - $basis = self::validateBasis($basis); + $settlement = SecurityValidations::validateSettlementDate($settlement); + $maturity = SecurityValidations::validateMaturityDate($maturity); + SecurityValidations::validateSecurityPeriod($settlement, $maturity); + $issue = SecurityValidations::validateIssueDate($issue); + $rate = SecurityValidations::validateRate($rate); + $price = SecurityValidations::validatePrice($price); + $basis = SecurityValidations::validateBasis($basis); } catch (Exception $e) { return $e->getMessage(); } @@ -131,7 +145,8 @@ public static function yieldAtMaturity($settlement, $maturity, $issue, $rate, $p } $daysBetweenSettlementAndMaturity *= $daysPerYear; - return ((1 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate) - (($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) / + return ((1 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate) - + (($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) / (($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) * ($daysPerYear / $daysBetweenSettlementAndMaturity); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php b/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php index 8f170488b4..31146c3158 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php +++ b/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php @@ -4,12 +4,11 @@ use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; use PhpOffice\PhpSpreadsheet\Calculation\Exception; +use PhpOffice\PhpSpreadsheet\Calculation\Financial\Constants as FinancialConstants; use PhpOffice\PhpSpreadsheet\Calculation\Functions; class TreasuryBill { - use BaseValidations; - /** * TBILLEQ. * @@ -31,29 +30,28 @@ public static function bondEquivalentYield($settlement, $maturity, $discount) $discount = Functions::flattenSingleValue($discount); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); + $discount = FinancialValidations::validateFloat($discount); } catch (Exception $e) { return $e->getMessage(); } - // Validate - if (is_numeric($discount)) { - if ($discount <= 0) { - return Functions::NAN(); - } - - $daysBetweenSettlementAndMaturity = $maturity - $settlement; - $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL); + if ($discount <= 0) { + return Functions::NAN(); + } - if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { - return Functions::NAN(); - } + $daysBetweenSettlementAndMaturity = $maturity - $settlement; + $daysPerYear = Helpers::daysPerYear( + DateTimeExcel\Year::funcYear($maturity), + FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL + ); - return (365 * $discount) / (360 - $discount * $daysBetweenSettlementAndMaturity); + if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { + return Functions::NAN(); } - return Functions::VALUE(); + return (365 * $discount) / (360 - $discount * $daysBetweenSettlementAndMaturity); } /** @@ -77,34 +75,33 @@ public static function price($settlement, $maturity, $discount) $discount = Functions::flattenSingleValue($discount); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); + $discount = FinancialValidations::validateFloat($discount); } catch (Exception $e) { return $e->getMessage(); } - // Validate - if (is_numeric($discount)) { - if ($discount <= 0) { - return Functions::NAN(); - } - - $daysBetweenSettlementAndMaturity = $maturity - $settlement; - $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL); + if ($discount <= 0) { + return Functions::NAN(); + } - if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { - return Functions::NAN(); - } + $daysBetweenSettlementAndMaturity = $maturity - $settlement; + $daysPerYear = Helpers::daysPerYear( + DateTimeExcel\Year::funcYear($maturity), + FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL + ); - $price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360)); - if ($price < 0.0) { - return Functions::NAN(); - } + if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { + return Functions::NAN(); + } - return $price; + $price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360)); + if ($price < 0.0) { + return Functions::NAN(); } - return Functions::VALUE(); + return $price; } /** @@ -128,28 +125,23 @@ public static function yield($settlement, $maturity, $price) $price = Functions::flattenSingleValue($price); try { - $settlement = self::validateSettlementDate($settlement); - $maturity = self::validateMaturityDate($maturity); + $settlement = FinancialValidations::validateSettlementDate($settlement); + $maturity = FinancialValidations::validateMaturityDate($maturity); + $price = FinancialValidations::validatePrice($price); } catch (Exception $e) { return $e->getMessage(); } - // Validate - if (is_numeric($price)) { - if ($price <= 0) { - return Functions::NAN(); - } - - $daysBetweenSettlementAndMaturity = $maturity - $settlement; - $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL); - - if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { - return Functions::NAN(); - } + $daysBetweenSettlementAndMaturity = $maturity - $settlement; + $daysPerYear = Helpers::daysPerYear( + DateTimeExcel\Year::funcYear($maturity), + FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL + ); - return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity); + if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) { + return Functions::NAN(); } - return Functions::VALUE(); + return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity); } } diff --git a/tests/data/Calculation/Financial/ACCRINT.php b/tests/data/Calculation/Financial/ACCRINT.php index 1852e7e352..a7b508d16a 100644 --- a/tests/data/Calculation/Financial/ACCRINT.php +++ b/tests/data/Calculation/Financial/ACCRINT.php @@ -13,11 +13,15 @@ ], [ 15.5555555555559, - '2008-03-05', '2008-08-31', '2008-05-01', 0.10, 1000, 2, 0, true, + '2008-03-05', '2008-08-31', '2008-05-01', 0.10, 1000, 2, null, + ], + [ + 15.5555555555559, + '2008-03-05', '2008-08-31', '2008-05-01', 0.10, 1000, 2, 0, ], [ 7.22222222222222, - '2008-04-05', '2008-08-31', '2008-05-01', 0.10, 1000, 2, 0, true, + '2008-04-05', '2008-08-31', '2008-05-01', 0.10, 1000, 2, 0, ], [ 200, @@ -29,15 +33,15 @@ ], [ 32.363013698630134, - '2012-01-01', '2012-03-31', '2012-02-15', 0.0525, 5000, 4, 3, 1, + '2012-01-01', '2012-03-31', '2012-02-15', 0.0525, 5000, 4, 3, ], [ 6.472602739726027, - '2012-01-01', '2012-03-31', '2012-02-15', 0.0525, 1000, 4, 3, 1, + '2012-01-01', '2012-03-31', '2012-02-15', 0.0525, 1000, 4, 3, ], [ 18.05555555555555, - '2017-08-05', '2017-11-10', '2017-10-10', 0.05, 2000, 4, 0, 1, + '2017-08-05', '2017-11-10', '2017-10-10', 0.05, 2000, 4, 0, ], [ '#NUM!', diff --git a/tests/data/Calculation/Financial/ACCRINTM.php b/tests/data/Calculation/Financial/ACCRINTM.php index e442b6f8bc..444e41f90b 100644 --- a/tests/data/Calculation/Financial/ACCRINTM.php +++ b/tests/data/Calculation/Financial/ACCRINTM.php @@ -11,6 +11,10 @@ 800, '2010-01-01', '2010-12-31', 0.08, 10000, ], + [ + 800, + '2010-01-01', '2010-12-31', 0.08, 10000, null, + ], [ 365.958904109589, '2012-01-01', '2013-02-15', 0.065, 5000, 3, diff --git a/tests/data/Calculation/Financial/AMORDEGRC.php b/tests/data/Calculation/Financial/AMORDEGRC.php index ef3ef1e0ce..fa546c8cd4 100644 --- a/tests/data/Calculation/Financial/AMORDEGRC.php +++ b/tests/data/Calculation/Financial/AMORDEGRC.php @@ -7,6 +7,14 @@ 776, 2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, 1, ], + [ + 776, + 2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, 0, + ], + [ + 776, + 2400, '2008-08-19', '2008-12-31', 300, 1, 0.15, null, + ], [ 820, 2400, '2008-08-19', '2008-12-31', 300, 1, 0.2, 1, @@ -51,6 +59,10 @@ 2813, 10000, '2012-03-01', '2012-12-31', 1500, 1, 0.3, 1, ], + [ + 0.0, + 500, '2012-03-01', '2012-12-31', 500, 3, 0.3, 1, + ], [ '#VALUE!', 'NaN', '2012-03-01', '2020-12-25', 20, 1, 0.2, 4, @@ -67,4 +79,20 @@ '#VALUE!', 550, '2012-03-01', '2020-12-25', 'NaN', 1, 0.2, 4, ], + [ + '#VALUE!', + 550, '2012-03-01', '2020-12-25', 20, 'NaN', 0.2, 4, + ], + [ + '#VALUE!', + 550, '2012-03-01', '2020-12-25', 20, 1, 'NaN', 4, + ], + [ + '#VALUE!', + 550, '2012-03-01', '2020-12-25', 20, 1, 0.2, 'NaN', + ], + [ + '#NUM!', + 550, '2012-03-01', '2020-12-25', 20, 1, 0.2, 99, + ], ]; diff --git a/tests/data/Calculation/Financial/AMORLINC.php b/tests/data/Calculation/Financial/AMORLINC.php index 34485c8a8e..c017553684 100644 --- a/tests/data/Calculation/Financial/AMORLINC.php +++ b/tests/data/Calculation/Financial/AMORLINC.php @@ -11,6 +11,14 @@ 576, 2400, '2008-08-19', '2008-12-31', 300, 2, 0.24, 1, ], + [ + 576, + 2400, '2008-08-19', '2008-12-31', 300, 2, 0.24, 0, + ], + [ + 576, + 2400, '2008-08-19', '2008-12-31', 300, 2, 0.24, null, + ], [ 30, 150, '2011-01-01', '2011-09-30', 20, 1, 0.2, 4, @@ -27,8 +35,36 @@ 0.0, 150, '2011-01-01', '2011-09-30', 20, 5, 0.2, 4, ], + [ + '#VALUE!', + 'NaN', '2011-01-01', '2011-09-30', 20, 1, 0.2, 4, + ], + [ + '#VALUE!', + 150, '2011-01-01', 'notADate', 20, 1, 0.2, 4, + ], [ '#VALUE!', 150, 'notADate', '2011-09-30', 20, 1, 0.2, 4, ], + [ + '#VALUE!', + 150, '2011-01-01', '2011-09-30', 'NaN', 1, 0.2, 4, + ], + [ + '#VALUE!', + 150, '2011-01-01', '2011-09-30', 20, 'NaN', 0.2, 4, + ], + [ + '#VALUE!', + 150, '2011-01-01', '2011-09-30', 20, 1, 'NaN', 4, + ], + [ + '#VALUE!', + 150, '2011-01-01', '2011-09-30', 20, 1, 0.2, 'NaN', + ], + [ + '#NUM!', + 550, '2012-03-01', '2020-12-25', 20, 1, 0.2, 99, + ], ]; diff --git a/tests/data/Calculation/Financial/COUPDAYBS.php b/tests/data/Calculation/Financial/COUPDAYBS.php index 7a805fdf32..260783faa5 100644 --- a/tests/data/Calculation/Financial/COUPDAYBS.php +++ b/tests/data/Calculation/Financial/COUPDAYBS.php @@ -16,6 +16,13 @@ '2012-10-25', 4, ], + [ + 66, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ 71, '2011-01-25', diff --git a/tests/data/Calculation/Financial/COUPDAYS.php b/tests/data/Calculation/Financial/COUPDAYS.php index 2cd2469c9d..c72d26c136 100644 --- a/tests/data/Calculation/Financial/COUPDAYS.php +++ b/tests/data/Calculation/Financial/COUPDAYS.php @@ -16,6 +16,13 @@ '2012-10-25', 4, ], + [ + 90, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ 182.5, '25-Jan-2007', diff --git a/tests/data/Calculation/Financial/COUPDAYSNC.php b/tests/data/Calculation/Financial/COUPDAYSNC.php index 6a7c5bb56a..ca61147529 100644 --- a/tests/data/Calculation/Financial/COUPDAYSNC.php +++ b/tests/data/Calculation/Financial/COUPDAYSNC.php @@ -16,6 +16,13 @@ '2012-10-25', 4, ], + [ + 24, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ '#VALUE!', 'Invalid Date', diff --git a/tests/data/Calculation/Financial/COUPNCD.php b/tests/data/Calculation/Financial/COUPNCD.php index 222c6aa57d..8dee4c0a96 100644 --- a/tests/data/Calculation/Financial/COUPNCD.php +++ b/tests/data/Calculation/Financial/COUPNCD.php @@ -16,6 +16,13 @@ '2012-10-25', 4, ], + [ + 40568, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ '#VALUE!', 'Invalid Date', diff --git a/tests/data/Calculation/Financial/COUPNUM.php b/tests/data/Calculation/Financial/COUPNUM.php index 5af5fd7b73..4cf0cc29b1 100644 --- a/tests/data/Calculation/Financial/COUPNUM.php +++ b/tests/data/Calculation/Financial/COUPNUM.php @@ -17,6 +17,13 @@ 4, 0, ], + [ + 8, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ '#VALUE!', 'Invalid Date', diff --git a/tests/data/Calculation/Financial/COUPPCD.php b/tests/data/Calculation/Financial/COUPPCD.php index 07c00d198c..e906f147d5 100644 --- a/tests/data/Calculation/Financial/COUPPCD.php +++ b/tests/data/Calculation/Financial/COUPPCD.php @@ -16,6 +16,13 @@ '2012-10-25', 4, ], + [ + 40476, + '2011-01-01', + '2012-10-25', + 4, + null, + ], [ '#VALUE!', 'Invalid Date', diff --git a/tests/data/Calculation/Financial/CUMIPMT.php b/tests/data/Calculation/Financial/CUMIPMT.php index d9a16a8b44..2ccc5ff245 100644 --- a/tests/data/Calculation/Financial/CUMIPMT.php +++ b/tests/data/Calculation/Financial/CUMIPMT.php @@ -21,6 +21,15 @@ 1, 0, ], + [ + -937.5, + 0.0075, + 360, + 125000, + 1, + 1, + null, + ], [ -2299.6141712553544, 0.004175, diff --git a/tests/data/Calculation/Financial/CUMPRINC.php b/tests/data/Calculation/Financial/CUMPRINC.php index 2e623223d3..e14d5adc16 100644 --- a/tests/data/Calculation/Financial/CUMPRINC.php +++ b/tests/data/Calculation/Financial/CUMPRINC.php @@ -21,6 +21,15 @@ 1, 0, ], + [ + -68.278271180977001, + 0.0075, + 360, + 125000, + 1, + 1, + null, + ], [ -9025.875084814226, 0.004175, diff --git a/tests/data/Calculation/Financial/DISC.php b/tests/data/Calculation/Financial/DISC.php index d77b0a8168..f33ed21bf1 100644 --- a/tests/data/Calculation/Financial/DISC.php +++ b/tests/data/Calculation/Financial/DISC.php @@ -18,6 +18,14 @@ 95, 100, ], + [ + 0.01, + '2010-04-01', + '2015-03-31', + 95, + 100, + null, + ], [ '#NUM!', '2010-04-01', diff --git a/tests/data/Calculation/Financial/DaysPerYear.php b/tests/data/Calculation/Financial/DaysPerYear.php index f9ca1c1db0..d8adb1c58e 100644 --- a/tests/data/Calculation/Financial/DaysPerYear.php +++ b/tests/data/Calculation/Financial/DaysPerYear.php @@ -1,15 +1,15 @@