Skip to content

Commit 09c8434

Browse files
author
MarkBaker
committed
Apply some coercive type-hinting
1 parent 67f87c8 commit 09c8434

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ public function setLocale(string $locale)
30883088
}
30893089

30903090
// Test whether we have any language data for this language (any locale)
3091-
if (in_array($language, self::$validLocaleLanguages)) {
3091+
if (in_array($language, self::$validLocaleLanguages, true)) {
30923092
// initialise language/locale settings
30933093
self::$localeFunctions = [];
30943094
self::$localeArgumentSeparator = ',';

src/PhpSpreadsheet/Calculation/Functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static function ifCondition($condition)
152152
if ($condition === '') {
153153
return '=""';
154154
}
155-
if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='])) {
155+
if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='], true)) {
156156
$condition = self::operandSpecialHandling($condition);
157157
if (is_bool($condition)) {
158158
return '=' . ($condition ? 'TRUE' : 'FALSE');

src/PhpSpreadsheet/Calculation/Information/ErrorValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function isError($value = '')
4747
return false;
4848
}
4949

50-
return in_array($value, ExcelError::$errorCodes) || $value === ExcelError::CALC();
50+
return in_array($value, ExcelError::$errorCodes, true) || $value === ExcelError::CALC();
5151
}
5252

5353
/**

src/PhpSpreadsheet/Calculation/Information/ExcelError.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ExcelError
1111
/**
1212
* List of error codes.
1313
*
14-
* @var array
14+
* @var array<string, string>
1515
*/
1616
public static $errorCodes = [
1717
'null' => '#NULL!',
@@ -60,7 +60,7 @@ public static function type($value = '')
6060
*
6161
* @return string #NULL!
6262
*/
63-
public static function null()
63+
public static function null(): string
6464
{
6565
return self::$errorCodes['null'];
6666
}
@@ -72,7 +72,7 @@ public static function null()
7272
*
7373
* @return string #NUM!
7474
*/
75-
public static function NAN()
75+
public static function NAN(): string
7676
{
7777
return self::$errorCodes['num'];
7878
}
@@ -84,7 +84,7 @@ public static function NAN()
8484
*
8585
* @return string #REF!
8686
*/
87-
public static function REF()
87+
public static function REF(): string
8888
{
8989
return self::$errorCodes['reference'];
9090
}
@@ -100,7 +100,7 @@ public static function REF()
100100
*
101101
* @return string #N/A!
102102
*/
103-
public static function NA()
103+
public static function NA(): string
104104
{
105105
return self::$errorCodes['na'];
106106
}
@@ -112,7 +112,7 @@ public static function NA()
112112
*
113113
* @return string #VALUE!
114114
*/
115-
public static function VALUE()
115+
public static function VALUE(): string
116116
{
117117
return self::$errorCodes['value'];
118118
}
@@ -124,7 +124,7 @@ public static function VALUE()
124124
*
125125
* @return string #NAME?
126126
*/
127-
public static function NAME()
127+
public static function NAME(): string
128128
{
129129
return self::$errorCodes['name'];
130130
}
@@ -134,17 +134,17 @@ public static function NAME()
134134
*
135135
* @return string #DIV/0!
136136
*/
137-
public static function DIV0()
137+
public static function DIV0(): string
138138
{
139139
return self::$errorCodes['divisionbyzero'];
140140
}
141141

142142
/**
143143
* CALC.
144144
*
145-
* @return string #Not Yet Implemented
145+
* @return string #CALC!
146146
*/
147-
public static function CALC()
147+
public static function CALC(): string
148148
{
149149
return '#CALC!';
150150
}

src/PhpSpreadsheet/Cell/DataType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DataType
2121
/**
2222
* List of error codes.
2323
*
24-
* @var array
24+
* @var array<string, int>
2525
*/
2626
private static $errorCodes = [
2727
'#NULL!' => 0,
@@ -36,7 +36,7 @@ class DataType
3636
/**
3737
* Get list of error codes.
3838
*
39-
* @return array
39+
* @return array<string, int>
4040
*/
4141
public static function getErrorCodes()
4242
{

src/PhpSpreadsheet/ReferenceHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public function insertNewBefore(
399399
return $highestColumn . $row;
400400
}, range(1, $highestRow)),
401401
function ($coordinate) use ($allCoordinates) {
402-
return !in_array($coordinate, $allCoordinates);
402+
return in_array($coordinate, $allCoordinates, true) === false;
403403
}
404404
);
405405

@@ -929,7 +929,7 @@ private function clearColumnStrips(int $highestRow, int $beforeColumn, int $numb
929929
$coordinate = Coordinate::stringFromColumnIndex($j + 1) . $i;
930930
$worksheet->removeConditionalStyles($coordinate);
931931
if ($worksheet->cellExists($coordinate)) {
932-
$worksheet->getCell($coordinate)->setValueExplicit('', DataType::TYPE_NULL);
932+
$worksheet->getCell($coordinate)->setValueExplicit(null, DataType::TYPE_NULL);
933933
$worksheet->getCell($coordinate)->setXfIndex(0);
934934
}
935935
}
@@ -945,7 +945,7 @@ private function clearRowStrips(string $highestColumn, int $beforeColumn, int $b
945945
$coordinate = Coordinate::stringFromColumnIndex($i + 1) . $j;
946946
$worksheet->removeConditionalStyles($coordinate);
947947
if ($worksheet->cellExists($coordinate)) {
948-
$worksheet->getCell($coordinate)->setValueExplicit('', DataType::TYPE_NULL);
948+
$worksheet->getCell($coordinate)->setValueExplicit(null, DataType::TYPE_NULL);
949949
$worksheet->getCell($coordinate)->setXfIndex(0);
950950
}
951951
}

src/PhpSpreadsheet/Shared/TimeZone.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class TimeZone
2121
*
2222
* @return bool Success or failure
2323
*/
24-
private static function validateTimeZone($timezoneName)
24+
private static function validateTimeZone(string $timezoneName): bool
2525
{
26-
return in_array($timezoneName, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC));
26+
return in_array($timezoneName, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC), true);
2727
}
2828

2929
/**
@@ -33,7 +33,7 @@ private static function validateTimeZone($timezoneName)
3333
*
3434
* @return bool Success or failure
3535
*/
36-
public static function setTimeZone($timezoneName)
36+
public static function setTimeZone(string $timezoneName): bool
3737
{
3838
if (self::validateTimezone($timezoneName)) {
3939
self::$timezone = $timezoneName;
@@ -49,7 +49,7 @@ public static function setTimeZone($timezoneName)
4949
*
5050
* @return string Timezone (e.g. 'Europe/London')
5151
*/
52-
public static function getTimeZone()
52+
public static function getTimeZone(): string
5353
{
5454
return self::$timezone;
5555
}
@@ -63,7 +63,7 @@ public static function getTimeZone()
6363
*
6464
* @return int Number of seconds for timezone adjustment
6565
*/
66-
public static function getTimeZoneAdjustment($timezoneName, $timestamp)
66+
public static function getTimeZoneAdjustment(?string $timezoneName, $timestamp): int
6767
{
6868
$timezoneName = $timezoneName ?? self::$timezone;
6969
$dtobj = Date::dateTimeFromTimestamp("$timestamp");

src/PhpSpreadsheet/Writer/Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ private function calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRo
17441744
while ($c++ < $e) {
17451745
$baseCell = $this->isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
17461746

1747-
if (!in_array($baseCell, $adjustedBaseCells)) {
1747+
if (!in_array($baseCell, $adjustedBaseCells, true)) {
17481748
// subtract rowspan by 1
17491749
--$this->isBaseCell[$sheetIndex][$baseCell[0]][$baseCell[1]]['rowspan'];
17501750
$adjustedBaseCells[] = $baseCell;

0 commit comments

Comments
 (0)