Skip to content

Commit 14e9806

Browse files
author
Mark Baker
authored
Yet more minor improvements (#1030)
1 parent 1b00fac commit 14e9806

File tree

6 files changed

+22
-12
lines changed

6 files changed

+22
-12
lines changed

src/PhpSpreadsheet/Shared/Date.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null)
192192
$interval = $days . ' days';
193193

194194
return $baseDate->modify($interval)
195-
->setTime($hours, $minutes, $seconds);
195+
->setTime((int) $hours, (int) $minutes, (int) $seconds);
196196
}
197197

198198
/**
@@ -244,12 +244,12 @@ public static function PHPToExcel($dateValue)
244244
public static function dateTimeToExcel(DateTimeInterface $dateValue)
245245
{
246246
return self::formattedPHPToExcel(
247-
$dateValue->format('Y'),
248-
$dateValue->format('m'),
249-
$dateValue->format('d'),
250-
$dateValue->format('H'),
251-
$dateValue->format('i'),
252-
$dateValue->format('s')
247+
(int) $dateValue->format('Y'),
248+
(int) $dateValue->format('m'),
249+
(int) $dateValue->format('d'),
250+
(int) $dateValue->format('H'),
251+
(int) $dateValue->format('i'),
252+
(int) $dateValue->format('s')
253253
);
254254
}
255255

src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ private function exponentialRegression($yValues, $xValues, $const)
113113
*/
114114
public function __construct($yValues, $xValues = [], $const = true)
115115
{
116-
if (parent::__construct($yValues, $xValues) !== false) {
116+
parent::__construct($yValues, $xValues);
117+
118+
if (!$this->error) {
117119
$this->exponentialRegression($yValues, $xValues, $const);
118120
}
119121
}

src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ private function linearRegression($yValues, $xValues, $const)
7272
*/
7373
public function __construct($yValues, $xValues = [], $const = true)
7474
{
75-
if (parent::__construct($yValues, $xValues) !== false) {
75+
parent::__construct($yValues, $xValues);
76+
77+
if (!$this->error) {
7678
$this->linearRegression($yValues, $xValues, $const);
7779
}
7880
}

src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ private function logarithmicRegression($yValues, $xValues, $const)
8181
*/
8282
public function __construct($yValues, $xValues = [], $const = true)
8383
{
84-
if (parent::__construct($yValues, $xValues) !== false) {
84+
parent::__construct($yValues, $xValues);
85+
86+
if (!$this->error) {
8587
$this->logarithmicRegression($yValues, $xValues, $const);
8688
}
8789
}

src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ private function polynomialRegression($order, $yValues, $xValues)
182182
*/
183183
public function __construct($order, $yValues, $xValues = [], $const = true)
184184
{
185-
if (parent::__construct($yValues, $xValues) !== false) {
185+
parent::__construct($yValues, $xValues);
186+
187+
if (!$this->error) {
186188
if ($order < $this->valueCount) {
187189
$this->bestFitType .= '_' . $order;
188190
$this->order = $order;

src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private function powerRegression($yValues, $xValues, $const)
105105
*/
106106
public function __construct($yValues, $xValues = [], $const = true)
107107
{
108-
if (parent::__construct($yValues, $xValues) !== false) {
108+
parent::__construct($yValues, $xValues);
109+
110+
if (!$this->error) {
109111
$this->powerRegression($yValues, $xValues, $const);
110112
}
111113
}

0 commit comments

Comments
 (0)