From 14e980625fa28c930faa817fd2297e8c67b2fc25 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 23 Jun 2019 16:50:45 +0200 Subject: [PATCH] Yet more minor improvements (#1030) --- src/PhpSpreadsheet/Shared/Date.php | 14 +++++++------- .../Shared/Trend/ExponentialBestFit.php | 4 +++- src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php | 4 +++- .../Shared/Trend/LogarithmicBestFit.php | 4 +++- .../Shared/Trend/PolynomialBestFit.php | 4 +++- src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php | 4 +++- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 11293136..5d2deb32 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -192,7 +192,7 @@ class Date $interval = $days . ' days'; return $baseDate->modify($interval) - ->setTime($hours, $minutes, $seconds); + ->setTime((int) $hours, (int) $minutes, (int) $seconds); } /** @@ -244,12 +244,12 @@ class Date public static function dateTimeToExcel(DateTimeInterface $dateValue) { return self::formattedPHPToExcel( - $dateValue->format('Y'), - $dateValue->format('m'), - $dateValue->format('d'), - $dateValue->format('H'), - $dateValue->format('i'), - $dateValue->format('s') + (int) $dateValue->format('Y'), + (int) $dateValue->format('m'), + (int) $dateValue->format('d'), + (int) $dateValue->format('H'), + (int) $dateValue->format('i'), + (int) $dateValue->format('s') ); } diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 03723d84..5b57f4b7 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -113,7 +113,9 @@ class ExponentialBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->exponentialRegression($yValues, $xValues, $const); } } diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 367e9d6e..217f0964 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -72,7 +72,9 @@ class LinearBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->linearRegression($yValues, $xValues, $const); } } diff --git a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 9092cef8..96ca2ed8 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -81,7 +81,9 @@ class LogarithmicBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->logarithmicRegression($yValues, $xValues, $const); } } diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index afcf5f47..a1510491 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -182,7 +182,9 @@ class PolynomialBestFit extends BestFit */ public function __construct($order, $yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { if ($order < $this->valueCount) { $this->bestFitType .= '_' . $order; $this->order = $order; diff --git a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index e1b3b829..4eefec82 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -105,7 +105,9 @@ class PowerBestFit extends BestFit */ public function __construct($yValues, $xValues = [], $const = true) { - if (parent::__construct($yValues, $xValues) !== false) { + parent::__construct($yValues, $xValues); + + if (!$this->error) { $this->powerRegression($yValues, $xValues, $const); } }