From dc9cf0e21acd9db2998163ade6ce7eaec203526d Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sat, 14 Feb 2026 00:49:57 +0300 Subject: [PATCH] [4.x] Fix `compare` method callback handling and enforce stricter PHPUnit configuration - Update `compare` method to properly check for null array keys before determining callback handling logic - Enable `failOnWarning` and `failOnRisky` in `phpunit.xml` configuration to improve test reliability --- phpunit.xml | 2 ++ src/Benchmark.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index e6577f3..d3901cc 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,6 +3,8 @@ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" + failOnWarning="true" + failOnRisky="true" > diff --git a/src/Benchmark.php b/src/Benchmark.php index dcc2ba9..4696f62 100644 --- a/src/Benchmark.php +++ b/src/Benchmark.php @@ -85,9 +85,9 @@ public function round(?int $precision): self public function compare(array|Closure ...$callbacks): static { $values = match (true) { - is_array($callbacks[0]) => $callbacks[0], - is_array($callbacks) => $callbacks, - default => func_get_args() + is_array($callbacks[0] ?? null) => $callbacks[0], + is_array($callbacks) => $callbacks, + default => func_get_args() }; $this->clear();