Skip to content

Commit

Permalink
Fix possible array-assignement from ini-files
Browse files Browse the repository at this point in the history
This is a theoretical issue but Psalm has recommendet to fix that.
  • Loading branch information
heiglandreas committed Feb 12, 2024
1 parent dc93aa1 commit 12ce9db
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Dictionary/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public static function fromFile(string $file): Dictionary
$dictionary = new Dictionary();

foreach (parse_ini_file($file) as $key => $val) {
if (is_array($val)) {
continue;
}
$dictionary->dictionary[str_replace('@:', '', $key)] = $val;

Check failure on line 117 in src/Dictionary/Dictionary.php

View workflow job for this annotation

GitHub Actions / analyze

InvalidPropertyAssignmentValue

src/Dictionary/Dictionary.php:117:13: InvalidPropertyAssignmentValue: $dictionary->dictionary with declared type 'array<array-key, mixed>' cannot be assigned type 'non-empty-array<array-key|array<array-key, string>, mixed>' (see https://psalm.dev/145)
}

Expand All @@ -133,6 +136,9 @@ public function load($locale)
return $this;
}
foreach (parse_ini_file($file) as $key => $val) {
if (is_array($val)) {
continue;
}
$this->dictionary[str_replace('@:', '', $key)] = $val;

Check failure on line 142 in src/Dictionary/Dictionary.php

View workflow job for this annotation

GitHub Actions / analyze

InvalidPropertyAssignmentValue

src/Dictionary/Dictionary.php:142:13: InvalidPropertyAssignmentValue: $this->dictionary with declared type 'array<array-key, mixed>' cannot be assigned type 'non-empty-array<array<array-key, string>|string, mixed>' (see https://psalm.dev/145)
}

Expand Down

0 comments on commit 12ce9db

Please sign in to comment.