Skip to content

The Squiz.Commenting.FunctionComment sniff doesn't detect incorrect types when @return tag has description #1018

@aik099

Description

@aik099

Example code:

/**  * Return description function + mixed return.  *  * @return string|int This is a description.  */ public function myFunction() { return 5; }

In above example the replacement of string|int into string|integer should be suggested, but this doesn't happen because instead of int the int This is a description. is parsed as data type.

Fixing this can be problematic, because on of supported data type format includes spaces: array(int => string) for example.

Most likely PHP_CodeSniffer::suggestType method needs to be changed to allow understanding that case OR a code added to separate description from return type as done for @param tag.

Related issue: #1015

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions