Rule phpdoc_array_type
¶
PHPDoc array<T>
type must be used instead of T[]
.
Warning¶
Using this rule is risky¶
Risky when using T[]
in union types.
Examples¶
Example #1¶
--- Original
+++ New
<?php
/**
- * @param int[] $x
- * @param string[][] $y
+ * @param array<int> $x
+ * @param array<array<string>> $y
*/
References¶
Fixer class: PhpCsFixer\Fixer\Phpdoc\PhpdocArrayTypeFixer
Test class: PhpCsFixer\Tests\Fixer\Phpdoc\PhpdocArrayTypeFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.