From c4a9caf97cfc53adfc219043bcecf42bc663acee Mon Sep 17 00:00:00 2001 From: KyleKatarn Date: Fri, 23 Oct 2020 08:02:30 +0200 Subject: [PATCH] #2229 Declare $previousCount only if a rounding is proceeded --- src/Carbon/CarbonInterval.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Carbon/CarbonInterval.php b/src/Carbon/CarbonInterval.php index 00ee49c0df..8cb60cedf4 100644 --- a/src/Carbon/CarbonInterval.php +++ b/src/Carbon/CarbonInterval.php @@ -1541,9 +1541,10 @@ public function forHumans($syntax = null, $short = false, $parts = -1, $options $intervalValues = $this; $method = static::getRoundingMethodFromOptions($options); - $previousCount = INF; if ($method) { + $previousCount = INF; + while ( \count($intervalValues->getNonZeroValues()) > $parts && ($count = \count($keys = array_keys($intervalValues->getValuesSequence()))) > 1