Skip to content

Commit 63b2b84

Browse files
committed
Fix PhpStan error.
1 parent b3b2e90 commit 63b2b84

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Type/Translation.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ public function __construct(?string $data, ?string $language = null)
5656
$language = LocalizationHelper::getLocale(true);
5757
}
5858
}
59-
60-
$this->storage[$language] = $data;
59+
if ($data !== null) {
60+
$this->storage[$language] = $data;
61+
} elseif (isset($this->storage[$language])) {
62+
unset($this->storage[$language]);
63+
}
6164
}
6265
}
6366

@@ -102,12 +105,17 @@ public function addTranslate(?string $haystack, ?string $language = null): bool
102105
if ($language === null) {
103106
$language = LocalizationHelper::getLocale(true);
104107
}
105-
if (isset($this->storage[$language]) === true && $this->storage[$language] === $haystack) {
106-
return false;
108+
if (isset($this->storage[$language]) === true) {
109+
if ($haystack === null) {
110+
unset($this->storage[$language]);
111+
} elseif ($this->storage[$language] === $haystack) {
112+
return false;
113+
}
114+
}
115+
if ($haystack !== null) {
116+
$this->storage[$language] = $haystack;
107117
}
108118

109-
$this->storage[$language] = $haystack;
110-
111119
return true;
112120
}
113121

0 commit comments

Comments
 (0)