Skip to content

Commit

Permalink
TranslationInfoOfConstraintViolation: add type hint for $key in remov…
Browse files Browse the repository at this point in the history
…eCurlyBraces

Else psalm fails with:
ERROR: InvalidReturnType - src/Serializer/Normalizer/Error/TranslationInfoOfConstraintViolation.php:20:21 - The declared return type 'array<string, mixed>' for App\Serializer\Normalizer\Error\TranslationInfoOfConstraintViolation::removeCurlyBraces is incorrect, got 'array<array<array-key, string>|string, mixed>' (see https://psalm.dev/011)
    * @psalm-return array<string, mixed>
  • Loading branch information
BacLuc committed Jul 31, 2023
1 parent 8cb5c2e commit a21c685
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function extract(ConstraintViolation $constraintViolation): TranslationIn
public static function removeCurlyBraces(array $parameters): array {
$paramsWithoutCurlyBraces = [];
foreach ($parameters as $key => $value) {
/** @var int|string $key */
$key = str_replace('{{ ', '', $key);
$key = str_replace(' }}', '', $key);
$paramsWithoutCurlyBraces[$key] = $value;
Expand Down

0 comments on commit a21c685

Please sign in to comment.