Apply some coercive type-hinting

This commit is contained in:
MarkBaker 2022-06-12 19:21:43 +02:00
parent 67f87c87c2
commit 09c843427f
8 changed files with 24 additions and 24 deletions

View File

@ -3088,7 +3088,7 @@ class Calculation
}
// Test whether we have any language data for this language (any locale)
if (in_array($language, self::$validLocaleLanguages)) {
if (in_array($language, self::$validLocaleLanguages, true)) {
// initialise language/locale settings
self::$localeFunctions = [];
self::$localeArgumentSeparator = ',';

View File

@ -152,7 +152,7 @@ class Functions
if ($condition === '') {
return '=""';
}
if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='])) {
if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='], true)) {
$condition = self::operandSpecialHandling($condition);
if (is_bool($condition)) {
return '=' . ($condition ? 'TRUE' : 'FALSE');

View File

@ -47,7 +47,7 @@ class ErrorValue
return false;
}
return in_array($value, ExcelError::$errorCodes) || $value === ExcelError::CALC();
return in_array($value, ExcelError::$errorCodes, true) || $value === ExcelError::CALC();
}
/**

View File

@ -11,7 +11,7 @@ class ExcelError
/**
* List of error codes.
*
* @var array
* @var array<string, string>
*/
public static $errorCodes = [
'null' => '#NULL!',
@ -60,7 +60,7 @@ class ExcelError
*
* @return string #NULL!
*/
public static function null()
public static function null(): string
{
return self::$errorCodes['null'];
}
@ -72,7 +72,7 @@ class ExcelError
*
* @return string #NUM!
*/
public static function NAN()
public static function NAN(): string
{
return self::$errorCodes['num'];
}
@ -84,7 +84,7 @@ class ExcelError
*
* @return string #REF!
*/
public static function REF()
public static function REF(): string
{
return self::$errorCodes['reference'];
}
@ -100,7 +100,7 @@ class ExcelError
*
* @return string #N/A!
*/
public static function NA()
public static function NA(): string
{
return self::$errorCodes['na'];
}
@ -112,7 +112,7 @@ class ExcelError
*
* @return string #VALUE!
*/
public static function VALUE()
public static function VALUE(): string
{
return self::$errorCodes['value'];
}
@ -124,7 +124,7 @@ class ExcelError
*
* @return string #NAME?
*/
public static function NAME()
public static function NAME(): string
{
return self::$errorCodes['name'];
}
@ -134,7 +134,7 @@ class ExcelError
*
* @return string #DIV/0!
*/
public static function DIV0()
public static function DIV0(): string
{
return self::$errorCodes['divisionbyzero'];
}
@ -142,9 +142,9 @@ class ExcelError
/**
* CALC.
*
* @return string #Not Yet Implemented
* @return string #CALC!
*/
public static function CALC()
public static function CALC(): string
{
return '#CALC!';
}

View File

@ -21,7 +21,7 @@ class DataType
/**
* List of error codes.
*
* @var array
* @var array<string, int>
*/
private static $errorCodes = [
'#NULL!' => 0,
@ -36,7 +36,7 @@ class DataType
/**
* Get list of error codes.
*
* @return array
* @return array<string, int>
*/
public static function getErrorCodes()
{

View File

@ -399,7 +399,7 @@ class ReferenceHelper
return $highestColumn . $row;
}, range(1, $highestRow)),
function ($coordinate) use ($allCoordinates) {
return !in_array($coordinate, $allCoordinates);
return in_array($coordinate, $allCoordinates, true) === false;
}
);
@ -929,7 +929,7 @@ class ReferenceHelper
$coordinate = Coordinate::stringFromColumnIndex($j + 1) . $i;
$worksheet->removeConditionalStyles($coordinate);
if ($worksheet->cellExists($coordinate)) {
$worksheet->getCell($coordinate)->setValueExplicit('', DataType::TYPE_NULL);
$worksheet->getCell($coordinate)->setValueExplicit(null, DataType::TYPE_NULL);
$worksheet->getCell($coordinate)->setXfIndex(0);
}
}
@ -945,7 +945,7 @@ class ReferenceHelper
$coordinate = Coordinate::stringFromColumnIndex($i + 1) . $j;
$worksheet->removeConditionalStyles($coordinate);
if ($worksheet->cellExists($coordinate)) {
$worksheet->getCell($coordinate)->setValueExplicit('', DataType::TYPE_NULL);
$worksheet->getCell($coordinate)->setValueExplicit(null, DataType::TYPE_NULL);
$worksheet->getCell($coordinate)->setXfIndex(0);
}
}

View File

@ -21,9 +21,9 @@ class TimeZone
*
* @return bool Success or failure
*/
private static function validateTimeZone($timezoneName)
private static function validateTimeZone(string $timezoneName): bool
{
return in_array($timezoneName, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC));
return in_array($timezoneName, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC), true);
}
/**
@ -33,7 +33,7 @@ class TimeZone
*
* @return bool Success or failure
*/
public static function setTimeZone($timezoneName)
public static function setTimeZone(string $timezoneName): bool
{
if (self::validateTimezone($timezoneName)) {
self::$timezone = $timezoneName;
@ -49,7 +49,7 @@ class TimeZone
*
* @return string Timezone (e.g. 'Europe/London')
*/
public static function getTimeZone()
public static function getTimeZone(): string
{
return self::$timezone;
}
@ -63,7 +63,7 @@ class TimeZone
*
* @return int Number of seconds for timezone adjustment
*/
public static function getTimeZoneAdjustment($timezoneName, $timestamp)
public static function getTimeZoneAdjustment(?string $timezoneName, $timestamp): int
{
$timezoneName = $timezoneName ?? self::$timezone;
$dtobj = Date::dateTimeFromTimestamp("$timestamp");

View File

@ -1744,7 +1744,7 @@ class Html extends BaseWriter
while ($c++ < $e) {
$baseCell = $this->isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
if (!in_array($baseCell, $adjustedBaseCells)) {
if (!in_array($baseCell, $adjustedBaseCells, true)) {
// subtract rowspan by 1
--$this->isBaseCell[$sheetIndex][$baseCell[0]][$baseCell[1]]['rowspan'];
$adjustedBaseCells[] = $baseCell;