Postponed
Project:
Coder
Version:
8.x-2.x-dev
Component:
Coder Sniffer
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Jan 2017 at 22:03 UTC
Updated:
5 Feb 2017 at 20:08 UTC
Jump to comment: Most recent
When hinting an array that can contain multiple types, FunctionCommentSniff gives a warning
class MyClass {
/**
* @return (A|B)[]
*/
public function foo() {}
}
Expected A|B[] but found (A|B)[] for function return type
This can be avoided by using the type hint A[]|B[] instead, but implies a slightly different meaning (an array containing only items of one of the types, versus containing items of either type).
PhpDocumentor: https://www.phpdoc.org/docs/latest/references/phpdoc/types.html#arrays
Comments
Comment #2
klausiThis is a bit undefined in Drupal standards: https://www.drupal.org/docs/develop/coding-standards/api-documentation-a...
Usually we don't use "()" characters at all in data types, that's why Coder complains. The question is whether we want to adopt phpdoc's version or not. So this probably needs a proposal and approval in the coding standards first, please file that in https://www.drupal.org/project/coding_standards
Thanks!