Squiz.Commenting.FunctionComment does not work with generics or union types

Author: simPodCreated May 21, 2019Updated Mar 2, 2026
php
    /**
     * @param string $namespace e.g. cms
     * @param string $name      e.g. duration_seconds
     * @param string $help      e.g. The duration something took in seconds.
     * @param iterable<string> $labels e.g. ['controller', 'action']
     */

Last line says

Expected 4 spaces after parameter name; 1 found (Squiz.Commenting.FunctionComment.SpacingAfterParamName)

Expected working example is this

php
    /**
     * @param string $namespace        e.g. cms
     * @param string $name             e.g. duration_seconds
     * @param string $help             e.g. The duration something took in seconds.
     * @param iterable<string> $labels e.g. ['controller', 'action']
     */

But that complains:

Expected 1 spaces after parameter name; 8 found (Squiz.Commenting.FunctionComment.SpacingAfterParamName) Expected 6 spaces after parameter name; 13 found (Squiz.Commenting.FunctionComment.SpacingAfterParamName) Expected 6 spaces after parameter name; 13 found (Squiz.Commenting.FunctionComment.SpacingAfterParamName) Expected 4 spaces after parameter name; 1 found (Squiz.Commenting.FunctionComment.SpacingAfterParamName)

IMO it ignores iterable<> token and counts string token only

Source: squizlabs/PHP_CodeSniffer