From 98ac2738abc3f9ce8d0a29c1ad1d3d552b4d174f Mon Sep 17 00:00:00 2001 From: Rudolph Gottesheim Date: Mon, 9 Oct 2023 13:55:35 +0200 Subject: [PATCH] Allow `@var mixed` annotations (#30) --- php-cs-fixer-rules.php | 5 ++++- tests/fixtures/valid/mixed-assignment.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/valid/mixed-assignment.php diff --git a/php-cs-fixer-rules.php b/php-cs-fixer-rules.php index eafbe11..fe6ac8e 100644 --- a/php-cs-fixer-rules.php +++ b/php-cs-fixer-rules.php @@ -48,7 +48,10 @@ ], 'no_multiline_whitespace_around_double_arrow' => true, 'no_superfluous_elseif' => true, - 'no_superfluous_phpdoc_tags' => true, + 'no_superfluous_phpdoc_tags' => [ + // Psalm wants us to have an explicit type annotation whenever we assign `mixed` to a variable. + 'allow_mixed' => true, + ], 'no_trailing_comma_in_singleline' => true, 'no_unused_imports' => true, 'no_useless_else' => true, diff --git a/tests/fixtures/valid/mixed-assignment.php b/tests/fixtures/valid/mixed-assignment.php new file mode 100644 index 0000000..9ff4ee1 --- /dev/null +++ b/tests/fixtures/valid/mixed-assignment.php @@ -0,0 +1,13 @@ + $struct + */ +function getFoo(array $struct): void +{ + /** @var mixed $foo */ + $foo = $struct['foo']; + echo $foo; +}