Skip to content

Commit

Permalink
Exclude locale from getSetting() if set by default
Browse files Browse the repository at this point in the history
Fix #2820
  • Loading branch information
kylekatarnls committed Jul 11, 2023
1 parent 075ee12 commit 936a216
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Carbon/Traits/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
});

Expand Down
4 changes: 4 additions & 0 deletions tests/Carbon/MacroTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down

0 comments on commit 936a216

Please sign in to comment.