Switch calls to deprecated function methods to the equivalent new methods (#1957)

This commit is contained in:
Mark Baker 2021-03-26 18:29:05 +01:00 committed by GitHub
parent 9239b3deca
commit d36f9d5a23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 82 additions and 82 deletions

View File

@ -38,7 +38,7 @@ class DProduct extends DatabaseAbstract
return null; return null;
} }
return MathTrig::PRODUCT( return MathTrig\Product::funcProduct(
self::getFilteredColumn($database, $field, $criteria) self::getFilteredColumn($database, $field, $criteria)
); );
} }

View File

@ -38,7 +38,7 @@ class DSum extends DatabaseAbstract
return null; return null;
} }
return MathTrig::SUM( return MathTrig\Sum::funcSum(
self::getFilteredColumn($database, $field, $criteria) self::getFilteredColumn($database, $field, $criteria)
); );
} }

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Amortization class Amortization
@ -47,7 +47,7 @@ class Amortization
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = ($basis === null) ? 0 : (int) Functions::flattenSingleValue($basis);
$yearFrac = DateTime::YEARFRAC($purchased, $firstPeriod, $basis); $yearFrac = DateTimeExcel\YearFrac::funcYearFrac($purchased, $firstPeriod, $basis);
if (is_string($yearFrac)) { if (is_string($yearFrac)) {
return $yearFrac; return $yearFrac;
} }
@ -116,13 +116,13 @@ class Amortization
$fOneRate = $cost * $rate; $fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage; $fCostDelta = $cost - $salvage;
// Note, quirky variation for leap years on the YEARFRAC for this function // Note, quirky variation for leap years on the YEARFRAC for this function
$purchasedYear = DateTime::YEAR($purchased); $purchasedYear = DateTimeExcel\Year::funcYear($purchased);
$yearFrac = DateTime::YEARFRAC($purchased, $firstPeriod, $basis); $yearFrac = DateTimeExcel\YearFrac::funcYearFrac($purchased, $firstPeriod, $basis);
if (is_string($yearFrac)) { if (is_string($yearFrac)) {
return $yearFrac; return $yearFrac;
} }
if (($basis == 1) && ($yearFrac < 1) && (DateTime::isLeapYear($purchasedYear))) { if (($basis == 1) && ($yearFrac < 1) && (DateTimeExcel\Helpers::isLeapYear($purchasedYear))) {
$yearFrac *= 365 / 366; $yearFrac *= 365 / 366;
} }

View File

@ -2,7 +2,8 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use DateTime;
use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\Date;
@ -60,14 +61,14 @@ class Coupons
return $e->getMessage(); return $e->getMessage();
} }
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_PREVIOUS); $prev = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_PREVIOUS);
if ($basis === Helpers::DAYS_PER_YEAR_ACTUAL) { if ($basis === Helpers::DAYS_PER_YEAR_ACTUAL) {
return abs(DateTime::DAYS($prev, $settlement)); return abs(DateTimeExcel\Days::funcDays($prev, $settlement));
} }
return DateTime::YEARFRAC($prev, $settlement, $basis) * $daysPerYear; return DateTimeExcel\YearFrac::funcYearFrac($prev, $settlement, $basis) * $daysPerYear;
} }
/** /**
@ -121,7 +122,7 @@ class Coupons
case Helpers::DAYS_PER_YEAR_ACTUAL: case Helpers::DAYS_PER_YEAR_ACTUAL:
// Actual/actual // Actual/actual
if ($frequency == self::FREQUENCY_ANNUAL) { if ($frequency == self::FREQUENCY_ANNUAL) {
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
return $daysPerYear / $frequency; return $daysPerYear / $frequency;
} }
@ -179,7 +180,7 @@ class Coupons
return $e->getMessage(); return $e->getMessage();
} }
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
$next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT); $next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT);
if ($basis === Helpers::DAYS_PER_YEAR_NASD) { if ($basis === Helpers::DAYS_PER_YEAR_NASD) {
@ -190,7 +191,7 @@ class Coupons
} }
} }
return DateTime::YEARFRAC($settlement, $next, $basis) * $daysPerYear; return DateTimeExcel\YearFrac::funcYearFrac($settlement, $next, $basis) * $daysPerYear;
} }
/** /**
@ -286,7 +287,7 @@ class Coupons
return $e->getMessage(); return $e->getMessage();
} }
$yearsBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, 0); $yearsBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, 0);
return ceil($yearsBetweenSettlementAndMaturity * $frequency); return ceil($yearsBetweenSettlementAndMaturity * $frequency);
} }
@ -344,11 +345,11 @@ class Coupons
* *
* Returns a boolean TRUE/FALSE indicating if this date is the last date of the month * Returns a boolean TRUE/FALSE indicating if this date is the last date of the month
* *
* @param \DateTime $testDate The date for testing * @param DateTime $testDate The date for testing
* *
* @return bool * @return bool
*/ */
private static function isLastDayOfMonth(\DateTime $testDate) private static function isLastDayOfMonth(DateTime $testDate)
{ {
return $testDate->format('d') === $testDate->format('t'); return $testDate->format('d') === $testDate->format('t');
} }
@ -376,7 +377,7 @@ class Coupons
private static function validateInputDate($date) private static function validateInputDate($date)
{ {
$date = DateTime::getDateValue($date); $date = DateTimeExcel\Helpers::getDateValue($date);
if (is_string($date)) { if (is_string($date)) {
throw new Exception(Functions::VALUE()); throw new Exception(Functions::VALUE());
} }

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class Helpers class Helpers
@ -42,7 +42,7 @@ class Helpers
case self::DAYS_PER_YEAR_365: case self::DAYS_PER_YEAR_365:
return 365; return 365;
case self::DAYS_PER_YEAR_ACTUAL: case self::DAYS_PER_YEAR_ACTUAL:
return (DateTime::isLeapYear($year)) ? 366 : 365; return (DateTimeExcel\Helpers::isLeapYear($year)) ? 366 : 365;
} }
return Functions::NAN(); return Functions::NAN();

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Constants as SecuritiesConstants; use PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Constants as SecuritiesConstants;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
@ -11,7 +11,7 @@ abstract class BaseValidations
{ {
protected static function validateInputDate($date) protected static function validateInputDate($date)
{ {
$date = DateTime::getDateValue($date); $date = DateTimeExcel\Helpers::getDateValue($date);
if (is_string($date)) { if (is_string($date)) {
throw new Exception(Functions::VALUE()); throw new Exception(Functions::VALUE());
} }

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Coupons; use PhpOffice\PhpSpreadsheet\Calculation\Financial\Coupons;
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Helpers; use PhpOffice\PhpSpreadsheet\Calculation\Financial\Helpers;
@ -117,7 +117,7 @@ class Price extends BaseValidations
return $e->getMessage(); return $e->getMessage();
} }
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) { if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error // return date error
return $daysBetweenSettlementAndMaturity; return $daysBetweenSettlementAndMaturity;
@ -169,23 +169,23 @@ class Price extends BaseValidations
return $e->getMessage(); return $e->getMessage();
} }
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
if (!is_numeric($daysPerYear)) { if (!is_numeric($daysPerYear)) {
return $daysPerYear; return $daysPerYear;
} }
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis); $daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::funcYearFrac($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) { if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error // return date error
return $daysBetweenIssueAndSettlement; return $daysBetweenIssueAndSettlement;
} }
$daysBetweenIssueAndSettlement *= $daysPerYear; $daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = DateTime::YEARFRAC($issue, $maturity, $basis); $daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) { if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error // return date error
return $daysBetweenIssueAndMaturity; return $daysBetweenIssueAndMaturity;
} }
$daysBetweenIssueAndMaturity *= $daysPerYear; $daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) { if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error // return date error
return $daysBetweenSettlementAndMaturity; return $daysBetweenSettlementAndMaturity;

View File

@ -2,7 +2,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Financial\Helpers; use PhpOffice\PhpSpreadsheet\Calculation\Financial\Helpers;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
@ -49,11 +49,11 @@ class Yields extends BaseValidations
return $e->getMessage(); return $e->getMessage();
} }
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
if (!is_numeric($daysPerYear)) { if (!is_numeric($daysPerYear)) {
return $daysPerYear; return $daysPerYear;
} }
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) { if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error // return date error
return $daysBetweenSettlementAndMaturity; return $daysBetweenSettlementAndMaturity;
@ -106,23 +106,23 @@ class Yields extends BaseValidations
return $e->getMessage(); return $e->getMessage();
} }
$daysPerYear = Helpers::daysPerYear(DateTime::YEAR($settlement), $basis); $daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($settlement), $basis);
if (!is_numeric($daysPerYear)) { if (!is_numeric($daysPerYear)) {
return $daysPerYear; return $daysPerYear;
} }
$daysBetweenIssueAndSettlement = DateTime::YEARFRAC($issue, $settlement, $basis); $daysBetweenIssueAndSettlement = DateTimeExcel\YearFrac::funcYearFrac($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) { if (!is_numeric($daysBetweenIssueAndSettlement)) {
// return date error // return date error
return $daysBetweenIssueAndSettlement; return $daysBetweenIssueAndSettlement;
} }
$daysBetweenIssueAndSettlement *= $daysPerYear; $daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = DateTime::YEARFRAC($issue, $maturity, $basis); $daysBetweenIssueAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) { if (!is_numeric($daysBetweenIssueAndMaturity)) {
// return date error // return date error
return $daysBetweenIssueAndMaturity; return $daysBetweenIssueAndMaturity;
} }
$daysBetweenIssueAndMaturity *= $daysPerYear; $daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = DateTime::YEARFRAC($settlement, $maturity, $basis); $daysBetweenSettlementAndMaturity = DateTimeExcel\YearFrac::funcYearFrac($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) { if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error // return date error
return $daysBetweenSettlementAndMaturity; return $daysBetweenSettlementAndMaturity;

View File

@ -2,7 +2,8 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\Financial; namespace PhpOffice\PhpSpreadsheet\Calculation\Financial;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class TreasuryBill class TreasuryBill
@ -27,11 +28,11 @@ class TreasuryBill
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$discount = Functions::flattenSingleValue($discount); $discount = Functions::flattenSingleValue($discount);
if ( try {
is_string($maturity = DateTime::getDateValue($maturity)) || $maturity = DateTimeExcel\Helpers::getDateValue($maturity);
is_string($settlement = DateTime::getDateValue($settlement)) $settlement = DateTimeExcel\Helpers::getDateValue($settlement);
) { } catch (Exception $e) {
return Functions::VALUE(); return $e->getMessage();
} }
// Validate // Validate
@ -41,11 +42,9 @@ class TreasuryBill
} }
$daysBetweenSettlementAndMaturity = $maturity - $settlement; $daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL);
if ( if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) {
$daysBetweenSettlementAndMaturity > Helpers::daysPerYear(DateTime::YEAR($maturity), Helpers::DAYS_PER_YEAR_ACTUAL) ||
$daysBetweenSettlementAndMaturity < 0
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -75,11 +74,11 @@ class TreasuryBill
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$discount = Functions::flattenSingleValue($discount); $discount = Functions::flattenSingleValue($discount);
if ( try {
is_string($maturity = DateTime::getDateValue($maturity)) || $maturity = DateTimeExcel\Helpers::getDateValue($maturity);
is_string($settlement = DateTime::getDateValue($settlement)) $settlement = DateTimeExcel\Helpers::getDateValue($settlement);
) { } catch (Exception $e) {
return Functions::VALUE(); return $e->getMessage();
} }
// Validate // Validate
@ -89,13 +88,12 @@ class TreasuryBill
} }
$daysBetweenSettlementAndMaturity = $maturity - $settlement; $daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL);
if ( if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) {
$daysBetweenSettlementAndMaturity > Helpers::daysPerYear(DateTime::YEAR($maturity), Helpers::DAYS_PER_YEAR_ACTUAL) ||
$daysBetweenSettlementAndMaturity < 0
) {
return Functions::NAN(); return Functions::NAN();
} }
$price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360)); $price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360));
if ($price < 0.0) { if ($price < 0.0) {
return Functions::NAN(); return Functions::NAN();
@ -127,11 +125,11 @@ class TreasuryBill
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$price = Functions::flattenSingleValue($price); $price = Functions::flattenSingleValue($price);
if ( try {
is_string($maturity = DateTime::getDateValue($maturity)) || $maturity = DateTimeExcel\Helpers::getDateValue($maturity);
is_string($settlement = DateTime::getDateValue($settlement)) $settlement = DateTimeExcel\Helpers::getDateValue($settlement);
) { } catch (Exception $e) {
return Functions::VALUE(); return $e->getMessage();
} }
// Validate // Validate
@ -141,8 +139,9 @@ class TreasuryBill
} }
$daysBetweenSettlementAndMaturity = $maturity - $settlement; $daysBetweenSettlementAndMaturity = $maturity - $settlement;
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\Year::funcYear($maturity), Helpers::DAYS_PER_YEAR_ACTUAL);
if ($daysBetweenSettlementAndMaturity > 360 || $daysBetweenSettlementAndMaturity < 0) { if ($daysBetweenSettlementAndMaturity > $daysPerYear || $daysBetweenSettlementAndMaturity < 0) {
return Functions::NAN(); return Functions::NAN();
} }

View File

@ -33,7 +33,7 @@ class Fact
$factLoop = floor($factVal); $factLoop = floor($factVal);
if ($factVal > $factLoop) { if ($factVal > $factLoop) {
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
return Statistical::GAMMAFunction($factVal + 1); return Statistical\Distributions\Gamma::gammaValue($factVal + 1);
} }
} }

View File

@ -946,7 +946,7 @@ class Statistical
{ {
$aArgs = Functions::flattenArray($args); $aArgs = Functions::flattenArray($args);
$aMean = MathTrig::PRODUCT($aArgs); $aMean = MathTrig\Product::funcProduct($aArgs);
if (is_numeric($aMean) && ($aMean > 0)) { if (is_numeric($aMean) && ($aMean > 0)) {
$aCount = Counts::COUNT($aArgs); $aCount = Counts::COUNT($aArgs);
if (Minimum::MIN($aArgs) > 0) { if (Minimum::MIN($aArgs) > 0) {

View File

@ -44,12 +44,12 @@ class Poisson
$summer = 0; $summer = 0;
$floor = floor($value); $floor = floor($value);
for ($i = 0; $i <= $floor; ++$i) { for ($i = 0; $i <= $floor; ++$i) {
$summer += $mean ** $i / MathTrig::FACT($i); $summer += $mean ** $i / MathTrig\Fact::funcFact($i);
} }
return exp(0 - $mean) * $summer; return exp(0 - $mean) * $summer;
} }
return (exp(0 - $mean) * $mean ** $value) / MathTrig::FACT($value); return (exp(0 - $mean) * $mean ** $value) / MathTrig\Fact::funcFact($value);
} }
} }

View File

@ -32,7 +32,7 @@ class Permutations
return Functions::NAN(); return Functions::NAN();
} }
return round(MathTrig::FACT($numObjs) / MathTrig::FACT($numObjs - $numInSet)); return round(MathTrig\Fact::funcFact($numObjs) / MathTrig\Fact::funcFact($numObjs - $numInSet));
} }
return Functions::VALUE(); return Functions::VALUE();

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData; namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
use DateTimeInterface; use DateTimeInterface;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig; use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Shared\Date;
@ -96,7 +96,7 @@ class Format
$format = Functions::flattenSingleValue($format); $format = Functions::flattenSingleValue($format);
if ((is_string($value)) && (!is_numeric($value)) && Date::isDateTimeFormatCode($format)) { if ((is_string($value)) && (!is_numeric($value)) && Date::isDateTimeFormatCode($format)) {
$value = DateTime::DATEVALUE($value); $value = DateTimeExcel\DateValue::funcDateValue($value);
} }
return (string) NumberFormat::toFormattedString($value, $format); return (string) NumberFormat::toFormattedString($value, $format);
@ -127,14 +127,14 @@ class Format
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
if (strpos($value, ':') !== false) { if (strpos($value, ':') !== false) {
$timeValue = DateTime::TIMEVALUE($value); $timeValue = DateTimeExcel\TimeValue::funcTimeValue($value);
if ($timeValue !== Functions::VALUE()) { if ($timeValue !== Functions::VALUE()) {
Functions::setReturnDateType($dateSetting); Functions::setReturnDateType($dateSetting);
return $timeValue; return $timeValue;
} }
} }
$dateValue = DateTime::DATEVALUE($value); $dateValue = DateTimeExcel\DateValue::funcDateValue($value);
if ($dateValue !== Functions::VALUE()) { if ($dateValue !== Functions::VALUE()) {
Functions::setReturnDateType($dateSetting); Functions::setReturnDateType($dateSetting);

View File

@ -3,7 +3,6 @@
namespace PhpOffice\PhpSpreadsheet\Calculation\TextData; namespace PhpOffice\PhpSpreadsheet\Calculation\TextData;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\TextData;
class Replace class Replace
{ {
@ -23,7 +22,7 @@ class Replace
$newText = Functions::flattenSingleValue($newText); $newText = Functions::flattenSingleValue($newText);
$left = Extract::left($oldText, $start - 1); $left = Extract::left($oldText, $start - 1);
$right = Extract::right($oldText, TextData::STRINGLENGTH($oldText) - ($start + $chars) + 1); $right = Extract::right($oldText, Text::length($oldText) - ($start + $chars) + 1);
return $left . $newText . $right; return $left . $newText . $right;
} }

View File

@ -2,9 +2,10 @@
namespace PhpOffice\PhpSpreadsheet\Shared; namespace PhpOffice\PhpSpreadsheet\Shared;
use DateTime;
use DateTimeInterface; use DateTimeInterface;
use DateTimeZone; use DateTimeZone;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
@ -154,7 +155,7 @@ class Date
* if you don't want to treat it as a UTC value * if you don't want to treat it as a UTC value
* Use the default (UST) unless you absolutely need a conversion * Use the default (UST) unless you absolutely need a conversion
* *
* @return \DateTime PHP date/time object * @return DateTime PHP date/time object
*/ */
public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) public static function excelToDateTimeObject($excelTimestamp, $timeZone = null)
{ {
@ -162,18 +163,18 @@ class Date
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) { if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {
if ($excelTimestamp < 1 && self::$excelCalendar === self::CALENDAR_WINDOWS_1900) { if ($excelTimestamp < 1 && self::$excelCalendar === self::CALENDAR_WINDOWS_1900) {
// Unix timestamp base date // Unix timestamp base date
$baseDate = new \DateTime('1970-01-01', $timeZone); $baseDate = new DateTime('1970-01-01', $timeZone);
} else { } else {
// MS Excel calendar base dates // MS Excel calendar base dates
if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) { if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) {
// Allow adjustment for 1900 Leap Year in MS Excel // Allow adjustment for 1900 Leap Year in MS Excel
$baseDate = ($excelTimestamp < 60) ? new \DateTime('1899-12-31', $timeZone) : new \DateTime('1899-12-30', $timeZone); $baseDate = ($excelTimestamp < 60) ? new DateTime('1899-12-31', $timeZone) : new DateTime('1899-12-30', $timeZone);
} else { } else {
$baseDate = new \DateTime('1904-01-01', $timeZone); $baseDate = new DateTime('1904-01-01', $timeZone);
} }
} }
} else { } else {
$baseDate = new \DateTime('1899-12-30', $timeZone); $baseDate = new DateTime('1899-12-30', $timeZone);
} }
$days = floor($excelTimestamp); $days = floor($excelTimestamp);
@ -262,7 +263,7 @@ class Date
return false; return false;
} }
return self::dateTimeToExcel(new \DateTime('@' . $dateValue)); return self::dateTimeToExcel(new DateTime('@' . $dateValue));
} }
/** /**
@ -436,14 +437,14 @@ class Date
return false; return false;
} }
$dateValueNew = DateTime::DATEVALUE($dateValue); $dateValueNew = DateTimeExcel\DateValue::funcDateValue($dateValue);
if ($dateValueNew === Functions::VALUE()) { if ($dateValueNew === Functions::VALUE()) {
return false; return false;
} }
if (strpos($dateValue, ':') !== false) { if (strpos($dateValue, ':') !== false) {
$timeValue = DateTime::TIMEVALUE($dateValue); $timeValue = DateTimeExcel\TimeValue::funcTimeValue($dateValue);
if ($timeValue === Functions::VALUE()) { if ($timeValue === Functions::VALUE()) {
return false; return false;
} }

View File

@ -3,7 +3,7 @@
namespace PhpOffice\PhpSpreadsheet\Worksheet; namespace PhpOffice\PhpSpreadsheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\DateTime; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;
use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
@ -472,7 +472,7 @@ class AutoFilter
$val = $maxVal = null; $val = $maxVal = null;
$ruleValues = []; $ruleValues = [];
$baseDate = DateTime::DATENOW(); $baseDate = DateTimeExcel\Now::funcNow();
// Calculate start/end dates for the required date range based on current date // Calculate start/end dates for the required date range based on current date
switch ($dynamicRuleType) { switch ($dynamicRuleType) {
case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK: case AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK: