Skip to content

Commit

Permalink
Apply PhpCsFixer phpdoc_to_return_type
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Dec 10, 2023
1 parent 77e6cc5 commit 5d716b7
Show file tree
Hide file tree
Showing 143 changed files with 563 additions and 1,238 deletions.
25 changes: 20 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,6 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php

-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues\\:\\:getDataValues\\(\\) should return array but returns array\\|null\\.$#"
count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php

-
message: "#^Offset 0 does not exist on array\\|null\\.$#"
count: 1
Expand All @@ -1180,6 +1175,11 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php

-
message: "#^Cannot access property \\$color on SimpleXMLElement\\|null\\.$#"
count: 2
path: src/PhpSpreadsheet/Reader/Xlsx/Styles.php

-
message: "#^Cannot call method beforeCellAddress\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\CellReferenceHelper\\|null\\.$#"
count: 1
Expand All @@ -1205,11 +1205,26 @@ parameters:
count: 1
path: src/PhpSpreadsheet/Worksheet/Validations.php

-
message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#"
count: 3
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php

-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:getChartType\\(\\) should return array\\<string\\> but returns array\\<int\\<0, max\\>, string\\|null\\>\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php

-
message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\|null given\\.$#"
count: 1
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php

-
message: "#^Offset 0 does not exist on array\\|null\\.$#"
count: 1
path: tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3767Test.php

-
message: "#^Parameter \\#2 \\$value of function ini_set expects string, int given\\.$#"
count: 1
Expand Down
4 changes: 1 addition & 3 deletions samples/Pdf/mpdf2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ class Mpdf2 extends Mpdf
* Other configuration options may be specified here.
*
* @param array $config Configuration array
*
* @return \Mpdf\Mpdf implementation
*/
protected function createExternalWriterInstance($config)
protected function createExternalWriterInstance($config): \Mpdf\Mpdf
{
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
Expand Down
61 changes: 16 additions & 45 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ public static function keyInExcelConstants(string $key): bool
return array_key_exists($key, self::$excelConstants);
}

/** @return mixed */
public static function getExcelConstants(string $key)
public static function getExcelConstants(string $key): mixed
{
return self::$excelConstants[$key];
}
Expand Down Expand Up @@ -2938,10 +2937,8 @@ public function flushInstance(): void

/**
* Get the Logger for this calculation engine instance.
*
* @return Logger
*/
public function getDebugLog()
public function getDebugLog(): Logger
{
return $this->debugLog;
}
Expand Down Expand Up @@ -3001,17 +2998,15 @@ public static function setArrayReturnType($returnType): bool
*
* @return string $returnType Array return type
*/
public static function getArrayReturnType()
public static function getArrayReturnType(): string
{
return self::$returnArrayAsType;
}

/**
* Is calculation caching enabled?
*
* @return bool
*/
public function getCalculationCacheEnabled()
public function getCalculationCacheEnabled(): bool
{
return $this->calculationCacheEnabled;
}
Expand Down Expand Up @@ -3098,10 +3093,8 @@ public function disableBranchPruning(): void

/**
* Get the currently defined locale code.
*
* @return string
*/
public function getLocale()
public function getLocale(): string
{
return self::$localeLanguage;
}
Expand Down Expand Up @@ -3365,10 +3358,8 @@ public function _translateFormulaToEnglish(string $formula): string

/**
* @param string $function
*
* @return string
*/
public static function localeFunc($function)
public static function localeFunc($function): string
{
if (self::$localeLanguage !== 'en_us') {
$functionName = trim($function, '(');
Expand All @@ -3386,10 +3377,8 @@ public static function localeFunc($function)

/**
* Wrap string values in quotes.
*
* @return mixed
*/
public static function wrapResult(mixed $value)
public static function wrapResult(mixed $value): mixed
{
if (is_string($value)) {
// Error values cannot be "wrapped"
Expand All @@ -3410,10 +3399,8 @@ public static function wrapResult(mixed $value)

/**
* Remove quotes used as a wrapper to identify string values.
*
* @return mixed
*/
public static function unwrapResult(mixed $value)
public static function unwrapResult(mixed $value): mixed
{
if (is_string($value)) {
if ((isset($value[0])) && ($value[0] == self::FORMULA_STRING_QUOTE) && (substr($value, -1) == self::FORMULA_STRING_QUOTE)) {
Expand All @@ -3432,10 +3419,8 @@ public static function unwrapResult(mixed $value)
* Retained for backward compatibility.
*
* @param Cell $cell Cell to calculate
*
* @return mixed
*/
public function calculate(?Cell $cell = null)
public function calculate(?Cell $cell = null): mixed
{
try {
return $this->calculateCellValue($cell);
Expand All @@ -3449,10 +3434,8 @@ public function calculate(?Cell $cell = null)
*
* @param Cell $cell Cell to calculate
* @param bool $resetLog Flag indicating whether the debug log should be reset or not
*
* @return mixed
*/
public function calculateCellValue(?Cell $cell = null, $resetLog = true)
public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed
{
if ($cell === null) {
return null;
Expand Down Expand Up @@ -3572,10 +3555,8 @@ public function parseFormula($formula)
* @param string $formula Formula to parse
* @param string $cellID Address of the cell to calculate
* @param Cell $cell Cell to calculate
*
* @return mixed
*/
public function calculateFormula($formula, $cellID = null, ?Cell $cell = null)
public function calculateFormula($formula, $cellID = null, ?Cell $cell = null): mixed
{
// Initialise the logging settings
$this->formulaError = null;
Expand Down Expand Up @@ -3641,10 +3622,8 @@ public function saveValueToCache($cellReference, mixed $cellValue): void
* @param string $cellID The ID (e.g. A3) of the cell that we are calculating
* @param Cell $cell Cell to calculate
* @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed
*
* @return mixed
*/
public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false)
public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed
{
$cellValue = null;

Expand Down Expand Up @@ -3875,10 +3854,8 @@ private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $
* Format details of an operand for display in the log (based on operand type).
*
* @param mixed $value First matrix operand
*
* @return mixed
*/
private function showValue(mixed $value)
private function showValue(mixed $value): mixed
{
if ($this->debugLog->getWriteDebugLog()) {
$testArray = Functions::flattenArray($value);
Expand Down Expand Up @@ -4536,10 +4513,7 @@ private function internalParseFormula($formula, ?Cell $cell = null): bool|array
return $output;
}

/**
* @return mixed
*/
private static function dataTestReference(array &$operandData)
private static function dataTestReference(array &$operandData): mixed
{
$operand = $operandData['value'];
if (($operandData['reference'] === null) && (is_array($operand))) {
Expand Down Expand Up @@ -5565,7 +5539,7 @@ private function addDefaultArgumentValues(array $functionCall, array $args, arra
/**
* @return null|mixed
*/
private function getArgumentDefaultValue(ReflectionParameter $methodArgument)
private function getArgumentDefaultValue(ReflectionParameter $methodArgument): mixed
{
$defaultValue = null;

Expand Down Expand Up @@ -5678,10 +5652,7 @@ public function getSuppressFormulaErrors(): bool
return $this->suppressFormulaErrorsNew;
}

/**
* @return mixed
*/
private static function boolToString(mixed $operand1)
private static function boolToString(mixed $operand1): mixed
{
if (is_bool($operand1)) {
$operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];
Expand Down
4 changes: 1 addition & 3 deletions src/PhpSpreadsheet/Calculation/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ public static function DCOUNTA($database, $field, $criteria): string|int
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
*
* @return mixed
*/
public static function DGET($database, $field, $criteria)
public static function DGET($database, $field, $criteria): mixed
{
return Database\DGet::evaluate($database, $field, $criteria);
}
Expand Down
14 changes: 7 additions & 7 deletions src/PhpSpreadsheet/Calculation/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function getDateValue(mixed $dateValue): float|string
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATETIMENOW()
public static function DATETIMENOW(): mixed
{
return DateTimeExcel\Current::now();
}
Expand All @@ -90,7 +90,7 @@ public static function DATETIMENOW()
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATENOW()
public static function DATENOW(): mixed
{
return DateTimeExcel\Current::today();
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public static function DATENOW()
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATE($year = 0, $month = 1, $day = 1)
public static function DATE($year = 0, $month = 1, $day = 1): mixed
{
return DateTimeExcel\Date::fromYMD($year, $month, $day);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ public static function TIME($hour = 0, $minute = 0, $second = 0): string|float|i
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function DATEVALUE($dateValue)
public static function DATEVALUE($dateValue): mixed
{
return DateTimeExcel\DateValue::fromString($dateValue);
}
Expand Down Expand Up @@ -424,7 +424,7 @@ public static function NETWORKDAYS(mixed $startDate, mixed $endDate, mixed ...$d
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function WORKDAY(mixed $startDate, $endDays, mixed ...$dateArgs)
public static function WORKDAY(mixed $startDate, $endDays, mixed ...$dateArgs): mixed
{
return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs);
}
Expand Down Expand Up @@ -851,7 +851,7 @@ public static function SECOND(mixed $timeValue = 0): string|int|array
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0)
public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0): mixed
{
return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths);
}
Expand Down Expand Up @@ -879,7 +879,7 @@ public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0)
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function EOMONTH(mixed $dateValue = 1, $adjustmentMonths = 0)
public static function EOMONTH(mixed $dateValue = 1, $adjustmentMonths = 0): mixed
{
return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths);
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Current
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function today()
public static function today(): mixed
{
$dti = new DateTimeImmutable();
$dateArray = Helpers::dateParse($dti->format('c'));
Expand All @@ -49,7 +49,7 @@ public static function today()
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
public static function now()
public static function now(): mixed
{
$dti = new DateTimeImmutable();
$dateArray = Helpers::dateParse($dti->format('c'));
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Date
* If an array of numbers is passed as the argument, then the returned result will also be an array
* with the same dimensions
*/
public static function fromYMD($year, $month, $day)
public static function fromYMD($year, $month, $day): mixed
{
if (is_array($year) || is_array($month) || is_array($day)) {
return self::evaluateArrayArguments([self::class, __FUNCTION__], $year, $month, $day);
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DateValue
* If an array of numbers is passed as the argument, then the returned result will also be an array
* with the same dimensions
*/
public static function fromString($dateValue)
public static function fromString($dateValue): mixed
{
if (is_array($dateValue)) {
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue);
Expand Down Expand Up @@ -134,7 +134,7 @@ private static function setUpArray(string $dateValue, DateTimeImmutable $dti): a
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
* depending on the value of the ReturnDateType flag
*/
private static function finalResults(array $PHPDateArray, DateTimeImmutable $dti, int $baseYear)
private static function finalResults(array $PHPDateArray, DateTimeImmutable $dti, int $baseYear): mixed
{
$retValue = ExcelError::Value();
if (Helpers::dateParseSucceeded($PHPDateArray)) {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function getDateValue(mixed $dateValue, bool $allowBool = true): f
*
* @return mixed Excel date/time serial value, or string if error
*/
public static function getTimeValue($timeValue)
public static function getTimeValue($timeValue): mixed
{
$saveReturnDateType = Functions::getReturnDateType();
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function clear(): void
*
* @return mixed[]
*/
public function showStack()
public function showStack(): array
{
return $this->stack;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Engine/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function clearLog(): void
*
* @return string[]
*/
public function getLog()
public function getLog(): array
{
return $this->debugLog;
}
Expand Down
Loading

0 comments on commit 5d716b7

Please sign in to comment.