Skip to content

Commit

Permalink
Fix further issues detected by psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
discordier committed Apr 17, 2024
1 parent 59c8647 commit e0d63d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/WritableXliffDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public function __construct(string $filename, ?string $sourceLanguage = null, ?s
}

if (!file_exists($filename)) {
if ($sourceLanguage) {
if ((bool) $sourceLanguage) {
$this->setSourceLanguage($sourceLanguage);
}
if ($targetLanguage) {
if ((bool) $targetLanguage) {
$this->setTargetLanguage($targetLanguage);
}
$this->markChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/XliffDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class XliffDictionary implements DictionaryInterface
public function __construct(?string $filename = null)
{
$this->xliff = new XliffFile();
if ($filename && is_readable($filename)) {
if ((bool) $filename && is_readable($filename)) {
$this->xliff->load($filename);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Xml/XliffFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
use RuntimeException;

/**
* This is an xliff implementation.
* This is a xliff implementation.
*
* @internal Only to be used within this abstraction.
*
* @psalm-suppress PropertyNotSetInConstructor The properties are inherited from the parent class and set by loading.
*/
final class XliffFile extends DOMDocument
{
Expand Down Expand Up @@ -200,7 +202,7 @@ public function searchTranslationUnit(string $identifier): ?XmlElement
}

if (
$this->documentElement->isDefaultNamespace(self::XLIFF_NS)
$this->documentElement?->isDefaultNamespace(self::XLIFF_NS)
&& $transUnit = $this->getXPathFirstItem(
'/xlf:xliff/xlf:file/xlf:body/xlf:trans-unit[@id=\'' . $identifier . '\']'
)
Expand Down

0 comments on commit e0d63d6

Please sign in to comment.