From 14c6446715ce643e9d4e511e3ad830b77a8948ee Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:26:41 -0800 Subject: [PATCH] Upgrade php-cs-fixer Dependabot wanted to do this (PR #4296), but code changes were needed to pass. --- composer.lock | 14 +++++++------- .../Calculation/Engine/ArrayArgumentHelper.php | 6 ++---- src/PhpSpreadsheet/Calculation/MathTrig/Random.php | 6 ++---- .../Statistical/Distributions/ChiSquared.php | 4 +--- src/PhpSpreadsheet/Calculation/TextData/Text.php | 6 ++---- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/composer.lock b/composer.lock index 6ad165f9ea..3025170cb3 100644 --- a/composer.lock +++ b/composer.lock @@ -1051,16 +1051,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.65.0", + "version": "v3.66.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f" + "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f", - "reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/5f5f2a142ff36b93c41885bca29cc5f861c013e6", + "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6", "shasum": "" }, "require": { @@ -1086,7 +1086,7 @@ "symfony/polyfill-mbstring": "^1.28", "symfony/polyfill-php80": "^1.28", "symfony/polyfill-php81": "^1.28", - "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/process": "^5.4 || ^6.0 || ^7.0 <7.2", "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { @@ -1142,7 +1142,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.66.0" }, "funding": [ { @@ -1150,7 +1150,7 @@ "type": "github" } ], - "time": "2024-11-25T00:39:24+00:00" + "time": "2024-12-29T13:46:23+00:00" }, { "name": "masterminds/html5", diff --git a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php index 0107f40453..aa2019e2bb 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php +++ b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php @@ -145,11 +145,9 @@ private function rows(array $arguments): array private function columns(array $arguments): array { return array_map( - function (mixed $argument): int { - return is_array($argument) && is_array($argument[array_keys($argument)[0]]) + fn (mixed $argument): int => is_array($argument) && is_array($argument[array_keys($argument)[0]]) ? count($argument[array_keys($argument)[0]]) - : 1; - }, + : 1, $arguments ); } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php index 5d3516777a..80d4caa7f3 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php @@ -86,11 +86,9 @@ public static function randArray(mixed $rows = 1, mixed $columns = 1, mixed $min return array_chunk( array_map( - function () use ($min, $max, $wholeNumber): int|float { - return $wholeNumber + fn (): int|float => $wholeNumber ? mt_rand((int) $min, (int) $max) - : (mt_rand() / mt_getrandmax()) * ($max - $min) + $min; - }, + : (mt_rand() / mt_getrandmax()) * ($max - $min) + $min, array_fill(0, $rows * $columns, $min) ), max($columns, 1) diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index 49b0dfc924..edc50ad7aa 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -133,10 +133,8 @@ public static function inverseRightTail(mixed $probability, mixed $degrees) return ExcelError::NAN(); } - $callback = function ($value) use ($degrees): float { - return 1 - (Gamma::incompleteGamma($degrees / 2, $value / 2) + $callback = fn ($value): float => 1 - (Gamma::incompleteGamma($degrees / 2, $value / 2) / Gamma::gammaValue($degrees / 2)); - }; $newtonRaphson = new NewtonRaphson($callback); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Text.php b/src/PhpSpreadsheet/Calculation/TextData/Text.php index f988a6c199..03691a8f27 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Text.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Text.php @@ -171,11 +171,9 @@ private static function applyPadding(array $rows, mixed $padding): array ); return array_map( - function (array $row) use ($columnCount, $padding): array { - return (count($row) < $columnCount) + fn (array $row): array => (count($row) < $columnCount) ? array_merge($row, array_fill(0, $columnCount - count($row), $padding)) - : $row; - }, + : $row, $rows ); }