Skip to content

Commit

Permalink
Apply PhpCsFixer phpdoc_to_property_type
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Dec 10, 2023
1 parent 3c0350e commit 77e6cc5
Show file tree
Hide file tree
Showing 264 changed files with 1,909 additions and 2,385 deletions.
25 changes: 5 additions & 20 deletions infra/LocaleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,23 @@ class LocaleGenerator
private const ENGLISH_REFERENCE_COLUMN = 'B';
private const EOL = "\n"; // not PHP_EOL

/**
* @var string
*/
protected $translationSpreadsheetName;
protected string $translationSpreadsheetName;

/**
* @var string
*/
protected $translationBaseFolder;
protected string $translationBaseFolder;

protected $phpSpreadsheetFunctions;

/**
* @var Spreadsheet
*/
protected $translationSpreadsheet;
protected Spreadsheet $translationSpreadsheet;

protected $verbose;

/**
* @var Worksheet
*/
protected $localeTranslations;
protected Worksheet $localeTranslations;

protected $localeLanguageMap = [];

protected $errorCodeMap = [];

/**
* @var Worksheet
*/
private $functionNameTranslations;
private Worksheet $functionNameTranslations;

protected $functionNameLanguageMap = [];

Expand Down
972 changes: 966 additions & 6 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions src/PhpSpreadsheet/Calculation/ArrayEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

trait ArrayEnabled
{
/**
* @var ArrayArgumentHelper
*/
private static $arrayArgumentHelper;
private static ?ArrayArgumentHelper $arrayArgumentHelper = null;

/**
* @param array|false $arguments Can be changed to array for Php8.1+
Expand Down
88 changes: 28 additions & 60 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ class Calculation
const FORMULA_CLOSE_MATRIX_BRACE = '}';
const FORMULA_STRING_QUOTE = '"';

/** @var string */
private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
private static string $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;

/**
* Instance of this class.
*
* @var ?Calculation
*/
private static $instance;
private static ?Calculation $instance = null;

/**
* Instance of the spreadsheet this Calculation Engine is using.
Expand All @@ -79,24 +78,17 @@ class Calculation

/**
* Calculation cache.
*
* @var array
*/
private $calculationCache = [];
private array $calculationCache = [];

/**
* Calculation cache enabled.
*
* @var bool
*/
private $calculationCacheEnabled = true;
private bool $calculationCacheEnabled = true;

private BranchPruner $branchPruner;

/**
* @var bool
*/
private $branchPruningEnabled = true;
private bool $branchPruningEnabled = true;

/**
* List of operators that can be used within formulae
Expand Down Expand Up @@ -134,17 +126,14 @@ class Calculation
*
* @deprecated 1.25.2 use setSuppressFormulaErrors() instead
*/
public $suppressFormulaErrors;
public ?bool $suppressFormulaErrors = null;

/** @var bool */
private $suppressFormulaErrorsNew = false;
private bool $suppressFormulaErrorsNew = false;

/**
* Error message for any error that was raised/thrown by the calculation engine.
*
* @var null|string
*/
public $formulaError;
public ?string $formulaError = null;

/**
* Reference Helper.
Expand All @@ -156,61 +145,50 @@ class Calculation
*/
private CyclicReferenceStack $cyclicReferenceStack;

/** @var array */
private $cellStack = [];
private array $cellStack = [];

/**
* Current iteration counter for cyclic formulae
* If the value is 0 (or less) then cyclic formulae will throw an exception,
* otherwise they will iterate to the limit defined here before returning a result.
*
* @var int
*/
private $cyclicFormulaCounter = 1;
private int $cyclicFormulaCounter = 1;

/** @var string */
private $cyclicFormulaCell = '';
private string $cyclicFormulaCell = '';

/**
* Number of iterations for cyclic formulae.
*
* @var int
*/
public $cyclicFormulaCount = 1;
public int $cyclicFormulaCount = 1;

/**
* The current locale setting.
*
* @var string
*/
private static $localeLanguage = 'en_us'; // US English (default locale)
private static string $localeLanguage = 'en_us'; // US English (default locale)

/**
* List of available locale settings
* Note that this is read for the locale subdirectory only when requested.
*
* @var string[]
*/
private static $validLocaleLanguages = [
private static array $validLocaleLanguages = [
'en', // English (default language)
];

/**
* Locale-specific argument separator for function arguments.
*
* @var string
*/
private static $localeArgumentSeparator = ',';
private static string $localeArgumentSeparator = ',';

/** @var array */
private static $localeFunctions = [];
private static array $localeFunctions = [];

/**
* Locale-specific translations for Excel constants (True, False and Null).
*
* @var array<string, string>
*/
private static $localeBoolean = [
private static array $localeBoolean = [
'TRUE' => 'TRUE',
'FALSE' => 'FALSE',
'NULL' => 'NULL',
Expand All @@ -227,7 +205,7 @@ public static function getLocaleBoolean(string $index): string
*
* @var array<string, mixed>
*/
private static $excelConstants = [
private static array $excelConstants = [
'TRUE' => true,
'FALSE' => false,
'NULL' => null,
Expand All @@ -248,10 +226,8 @@ public static function getExcelConstants(string $key)
* Array of functions usable on Spreadsheet.
* In theory, this could be const rather than static;
* however, Phpstan breaks trying to analyze it when attempted.
*
*@var array
*/
private static $phpSpreadsheetFunctions = [
private static array $phpSpreadsheetFunctions = [
'ABS' => [
'category' => Category::CATEGORY_MATH_AND_TRIG,
'functionCall' => [MathTrig\Absolute::class, 'evaluate'],
Expand Down Expand Up @@ -2891,10 +2867,8 @@ public static function getExcelConstants(string $key)

/**
* Internal functions used for special control purposes.
*
* @var array
*/
private static $controlFunctions = [
private static array $controlFunctions = [
'MKMATRIX' => [
'argumentCount' => '*',
'functionCall' => [Internal\MakeMatrix::class, 'make'],
Expand Down Expand Up @@ -2945,7 +2919,7 @@ public static function getInstance(?Spreadsheet $spreadsheet = null): self
}
}

if (!isset(self::$instance) || (self::$instance === null)) {
if (!self::$instance) {
self::$instance = new self();
}

Expand Down Expand Up @@ -3321,10 +3295,10 @@ private static function translateFormula(array $from, array $to, string $formula
}

/** @var ?array */
private static $functionReplaceFromExcel;
private static ?array $functionReplaceFromExcel;

/** @var ?array */
private static $functionReplaceToLocale;
private static ?array $functionReplaceToLocale;

public function _translateFormulaToLocale(string $formula): string
{
Expand Down Expand Up @@ -3359,10 +3333,10 @@ public function _translateFormulaToLocale(string $formula): string
}

/** @var ?array */
private static $functionReplaceFromLocale;
private static ?array $functionReplaceFromLocale;

/** @var ?array */
private static $functionReplaceToExcel;
private static ?array $functionReplaceToExcel;

public function _translateFormulaToEnglish(string $formula): string
{
Expand Down Expand Up @@ -4034,10 +4008,8 @@ private function convertMatrixReferences(string $formula): false|string
* Binary Operators.
* These operators always work on two values.
* Array key is the operator, the value indicates whether this is a left or right associative operator.
*
* @var array
*/
private static $operatorAssociativity = [
private static array $operatorAssociativity = [
'^' => 0, // Exponentiation
'*' => 0, '/' => 0, // Multiplication and Division
'+' => 0, '-' => 0, // Addition and Subtraction
Expand All @@ -4049,19 +4021,15 @@ private function convertMatrixReferences(string $formula): false|string
/**
* Comparison (Boolean) Operators.
* These operators work on two values, but always return a boolean result.
*
* @var array
*/
private static $comparisonOperators = ['>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true];
private static array $comparisonOperators = ['>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true];

/**
* Operator Precedence.
* This list includes all valid operators, whether binary (including boolean) or unary (such as %).
* Array key is the operator, the value is its precedence.
*
* @var array
*/
private static $operatorPrecedence = [
private static array $operatorPrecedence = [
':' => 9, // Range
'' => 8, // Intersect
'' => 7, // Union
Expand Down
33 changes: 9 additions & 24 deletions src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,15 @@

class ArrayArgumentHelper
{
/**
* @var int
*/
protected $indexStart = 0;

/**
* @var array
*/
protected $arguments;

/**
* @var int
*/
protected $argumentCount;

/**
* @var array
*/
protected $rows;

/**
* @var array
*/
protected $columns;
protected int $indexStart = 0;

protected array $arguments;

protected int $argumentCount;

protected array $rows;

protected array $columns;

public function initialise(array $arguments): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class ArrayArgumentProcessor
{
/**
* @var ArrayArgumentHelper
*/
private static $arrayArgumentHelper;
private static ArrayArgumentHelper $arrayArgumentHelper;

public static function processArguments(
ArrayArgumentHelper $arrayArgumentHelper,
Expand Down
Loading

0 comments on commit 77e6cc5

Please sign in to comment.