diff --git a/src/Carbon/Traits/Options.php b/src/Carbon/Traits/Options.php index 6f021942ac..48f9739773 100644 --- a/src/Carbon/Traits/Options.php +++ b/src/Carbon/Traits/Options.php @@ -422,7 +422,7 @@ public function getSettings() foreach ($map as $property => $key) { $value = $this->$property ?? null; - if ($value !== null) { + if ($value !== null && ($key !== 'locale' || $value !== 'en' || $this->localTranslator)) { $settings[$key] = $value; } } @@ -437,7 +437,7 @@ public function getSettings() */ public function __debugInfo() { - $infos = array_filter(get_object_vars($this), function ($var) { + $infos = array_filter(get_object_vars($this), static function ($var) { return $var; }); diff --git a/tests/Carbon/MacroTest.php b/tests/Carbon/MacroTest.php index 9e63473836..5eb4e6ab99 100644 --- a/tests/Carbon/MacroTest.php +++ b/tests/Carbon/MacroTest.php @@ -308,8 +308,12 @@ public function testMutabilityOfMixinMethodReturnedValue() $now = Carbon::now(); + $this->assertSame('Monday', $now->copy()->startOfWeek()->dayName); + $copy = $now->copyWithAppTz(false, 'Europe/Paris'); + $this->assertSame('Monday', $copy->copy()->startOfWeek()->dayName); + $this->assertSame('Europe/Paris', $copy->format('e')); $this->assertSame('UTC', $now->format('e'));