Skip to content

Commit

Permalink
Apply PhpCsFixer phpdoc_to_param_type
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Dec 10, 2023
1 parent 5d716b7 commit 959719a
Show file tree
Hide file tree
Showing 172 changed files with 838 additions and 1,406 deletions.
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/BinaryComparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BinaryComparison
* @param null|string $str1 First string value for the comparison
* @param null|string $str2 Second string value for the comparison
*/
private static function strcmpLowercaseFirst($str1, $str2): int
private static function strcmpLowercaseFirst(?string $str1, ?string $str2): int
{
$inversedStr1 = StringHelper::strCaseReverse($str1 ?? '');
$inversedStr2 = StringHelper::strCaseReverse($str2 ?? '');
Expand All @@ -31,7 +31,7 @@ private static function strcmpLowercaseFirst($str1, $str2): int
* @param null|string $str1 First string value for the comparison
* @param null|string $str2 Second string value for the comparison
*/
private static function strcmpAllowNull($str1, $str2): int
private static function strcmpAllowNull(?string $str1, ?string $str2): int
{
return strcmp($str1 ?? '', $str2 ?? '');
}
Expand Down
56 changes: 18 additions & 38 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2978,7 +2978,7 @@ public static function getFALSE(): string
*
* @return bool Success or failure
*/
public static function setArrayReturnType($returnType): bool
public static function setArrayReturnType(string $returnType): bool
{
if (
($returnType == self::RETURN_ARRAY_AS_VALUE)
Expand Down Expand Up @@ -3013,10 +3013,8 @@ public function getCalculationCacheEnabled(): bool

/**
* Enable/disable calculation cache.
*
* @param bool $calculationCacheEnabled
*/
public function setCalculationCacheEnabled($calculationCacheEnabled): void
public function setCalculationCacheEnabled(bool $calculationCacheEnabled): void
{
$this->calculationCacheEnabled = $calculationCacheEnabled;
$this->clearCalculationCache();
Expand Down Expand Up @@ -3048,10 +3046,8 @@ public function clearCalculationCache(): void

/**
* Clear calculation cache for a specified worksheet.
*
* @param string $worksheetName
*/
public function clearCalculationCacheForWorksheet($worksheetName): void
public function clearCalculationCacheForWorksheet(string $worksheetName): void
{
if (isset($this->calculationCache[$worksheetName])) {
unset($this->calculationCache[$worksheetName]);
Expand All @@ -3060,11 +3056,8 @@ public function clearCalculationCacheForWorksheet($worksheetName): void

/**
* Rename calculation cache for a specified worksheet.
*
* @param string $fromWorksheetName
* @param string $toWorksheetName
*/
public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void
public function renameCalculationCacheForWorksheet(string $fromWorksheetName, string $toWorksheetName): void
{
if (isset($this->calculationCache[$fromWorksheetName])) {
$this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName];
Expand Down Expand Up @@ -3356,10 +3349,7 @@ public function _translateFormulaToEnglish(string $formula): string
return self::translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$localeArgumentSeparator, ',');
}

/**
* @param string $function
*/
public static function localeFunc($function): string
public static function localeFunc(string $function): string
{
if (self::$localeLanguage !== 'en_us') {
$functionName = trim($function, '(');
Expand Down Expand Up @@ -3435,7 +3425,7 @@ public function calculate(?Cell $cell = null): mixed
* @param Cell $cell Cell to calculate
* @param bool $resetLog Flag indicating whether the debug log should be reset or not
*/
public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed
public function calculateCellValue(?Cell $cell = null, bool $resetLog = true): mixed
{
if ($cell === null) {
return null;
Expand Down Expand Up @@ -3532,7 +3522,7 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed
*
* @return array|bool
*/
public function parseFormula($formula)
public function parseFormula(string $formula)
{
// Basic validation that this is indeed a formula
// We return an empty array if not
Expand All @@ -3556,7 +3546,7 @@ public function parseFormula($formula)
* @param string $cellID Address of the cell to calculate
* @param Cell $cell Cell to calculate
*/
public function calculateFormula($formula, $cellID = null, ?Cell $cell = null): mixed
public function calculateFormula(string $formula, ?string $cellID = null, ?Cell $cell = null): mixed
{
// Initialise the logging settings
$this->formulaError = null;
Expand Down Expand Up @@ -3605,10 +3595,7 @@ public function getValueFromCache(string $cellReference, mixed &$cellValue): boo
return false;
}

/**
* @param string $cellReference
*/
public function saveValueToCache($cellReference, mixed $cellValue): void
public function saveValueToCache(string $cellReference, mixed $cellValue): void
{
if ($this->calculationCacheEnabled) {
$this->calculationCache[$cellReference] = $cellValue;
Expand All @@ -3623,7 +3610,7 @@ public function saveValueToCache($cellReference, mixed $cellValue): void
* @param Cell $cell Cell to calculate
* @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed
*/
public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed
public function _calculateFormulaValue(string $formula, ?string $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed
{
$cellValue = null;

Expand Down Expand Up @@ -3704,7 +3691,7 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = n
* 1 = shrink to fit
* 2 = extend to fit
*/
private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, $resize = 1): array
private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, int $resize = 1): array
{
// Examine each of the two operands, and turn them into an array if they aren't one already
// Note that this function should only be called if one or both of the operand is already an array
Expand Down Expand Up @@ -3770,7 +3757,7 @@ public static function getMatrixDimensions(array &$matrix): array
* @param int $matrix2Rows Row size of second matrix operand
* @param int $matrix2Columns Column size of second matrix operand
*/
private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void
private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, int $matrix1Rows, int $matrix1Columns, int $matrix2Rows, int $matrix2Columns): void
{
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Rows < $matrix1Rows) {
Expand Down Expand Up @@ -3813,7 +3800,7 @@ private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, $
* @param int $matrix2Rows Row size of second matrix operand
* @param int $matrix2Columns Column size of second matrix operand
*/
private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void
private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, int $matrix1Rows, int $matrix1Columns, int $matrix2Rows, int $matrix2Columns): void
{
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Columns < $matrix1Columns) {
Expand Down Expand Up @@ -4022,11 +4009,9 @@ private function convertMatrixReferences(string $formula): false|string
// Convert infix to postfix notation

/**
* @param string $formula
*
* @return array<int, mixed>|false
*/
private function internalParseFormula($formula, ?Cell $cell = null): bool|array
private function internalParseFormula(string $formula, ?Cell $cell = null): bool|array
{
if (($formula = $this->convertMatrixReferences(trim($formula))) === false) {
return false;
Expand Down Expand Up @@ -4536,11 +4521,9 @@ private static function dataTestReference(array &$operandData): mixed
}

/**
* @param null|string $cellID
*
* @return array<int, mixed>|false
*/
private function processTokenStack(mixed $tokens, $cellID = null, ?Cell $cell = null)
private function processTokenStack(mixed $tokens, ?string $cellID = null, ?Cell $cell = null)
{
if ($tokens === false) {
return false;
Expand Down Expand Up @@ -5211,12 +5194,9 @@ private function executeBinaryComparisonOperation(mixed $operand1, mixed $operan
}

/**
* @param string $operation
* @param Stack $stack
*
* @return bool|mixed
*/
private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, $operation, &$stack)
private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, string $operation, Stack &$stack)
{
// Validate the two operands
if (
Expand Down Expand Up @@ -5369,7 +5349,7 @@ protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throw
*
* @return array Array of values in range if range contains more than one element. Otherwise, a single value is returned.
*/
public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, bool $resetLog = true): array
public function extractCellRange(string &$range = 'A1', ?Worksheet $worksheet = null, bool $resetLog = true): array
{
// Return value
$returnValue = [];
Expand Down Expand Up @@ -5480,7 +5460,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet =
*
* @param string $function Function Name
*/
public function isImplemented($function): bool
public function isImplemented(string $function): bool
{
$function = strtoupper($function);
$notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'DUMMY');
Expand Down
24 changes: 12 additions & 12 deletions src/PhpSpreadsheet/Calculation/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Database
*
* @return float|string
*/
public static function DAVERAGE($database, $field, $criteria)
public static function DAVERAGE(array $database, $field, array $criteria)
{
return Database\DAverage::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public static function DAVERAGE($database, $field, $criteria)
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
* database that match the criteria.
*/
public static function DCOUNT($database, $field, $criteria): string|int
public static function DCOUNT(array $database, $field, array $criteria): string|int
{
return Database\DCount::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ public static function DCOUNT($database, $field, $criteria): string|int
* the column label in which you specify a condition for the
* column.
*/
public static function DCOUNTA($database, $field, $criteria): string|int
public static function DCOUNTA(array $database, $field, array $criteria): string|int
{
return Database\DCountA::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public static function DCOUNTA($database, $field, $criteria): string|int
* the column label in which you specify a condition for the
* column.
*/
public static function DGET($database, $field, $criteria): mixed
public static function DGET(array $database, $field, array $criteria): mixed
{
return Database\DGet::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public static function DGET($database, $field, $criteria): mixed
*
* @return null|float|string
*/
public static function DMAX($database, $field, $criteria)
public static function DMAX(array $database, $field, array $criteria)
{
return Database\DMax::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public static function DMAX($database, $field, $criteria)
*
* @return null|float|string
*/
public static function DMIN($database, $field, $criteria)
public static function DMIN(array $database, $field, array $criteria)
{
return Database\DMin::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public static function DMIN($database, $field, $criteria)
*
* @return float|string
*/
public static function DPRODUCT($database, $field, $criteria)
public static function DPRODUCT(array $database, $field, array $criteria)
{
return Database\DProduct::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public static function DPRODUCT($database, $field, $criteria)
*
* @return float|string
*/
public static function DSTDEV($database, $field, $criteria)
public static function DSTDEV(array $database, $field, array $criteria)
{
return Database\DStDev::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -313,7 +313,7 @@ public static function DSTDEV($database, $field, $criteria)
*
* @return float|string
*/
public static function DSTDEVP($database, $field, $criteria)
public static function DSTDEVP(array $database, $field, array $criteria)
{
return Database\DStDevP::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ public static function DSTDEVP($database, $field, $criteria)
*
* @return null|float|string
*/
public static function DSUM($database, $field, $criteria)
public static function DSUM(array $database, $field, array $criteria)
{
return Database\DSum::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -382,7 +382,7 @@ public static function DSUM($database, $field, $criteria)
*
* @return float|string (string if result is an error)
*/
public static function DVAR($database, $field, $criteria)
public static function DVAR(array $database, $field, array $criteria)
{
return Database\DVar::evaluate($database, $field, $criteria);
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public static function DVAR($database, $field, $criteria)
*
* @return float|string (string if result is an error)
*/
public static function DVARP($database, $field, $criteria)
public static function DVARP(array $database, $field, array $criteria)
{
return Database\DVarP::evaluate($database, $field, $criteria);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DAverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DAverage extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): string|int|float
public static function evaluate(array $database, $field, array $criteria): string|int|float
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DCount extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria, bool $returnError = true): string|int
public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): string|int
{
$field = self::fieldExtract($database, $field);
if ($returnError && $field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DCountA.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DCountA extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): string|int
public static function evaluate(array $database, $field, array $criteria): string|int
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DGet extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): null|float|int|string
public static function evaluate(array $database, $field, array $criteria): null|float|int|string
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DMax.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DMax extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria, bool $returnError = true): null|float|string
public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): null|float|string
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DMin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DMin extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria, bool $returnError = true): float|string|null
public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): float|string|null
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DProduct extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): string|float
public static function evaluate(array $database, $field, array $criteria): string|float
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DStDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DStDev extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): float|string
public static function evaluate(array $database, $field, array $criteria): float|string
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Database/DStDevP.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DStDevP extends DatabaseAbstract
* the column label in which you specify a condition for the
* column.
*/
public static function evaluate($database, $field, $criteria): float|string
public static function evaluate(array $database, $field, array $criteria): float|string
{
$field = self::fieldExtract($database, $field);
if ($field === null) {
Expand Down
Loading

0 comments on commit 959719a

Please sign in to comment.