This is a spin-off from #1820082: Ensure @param array type used in function definition (as appropriate) after thinking about how the sniff/rules for an array type will be simpler than those for an object type. What we want to flag in this issue are the three following types of code examples:

/**
 * Returns the ID of object Foo.
 *
 * @param object $foo
 *   A Foo object.
 *
 * @return string
 *   The ID of this Foo object as a string.
 */
function mymodule_foo_get_id($foo) {
/**
 * Returns the ID of object Foo.
 *
 * @param $foo
 *   A Foo object.
 *
 * @return string
 *   The ID of this Foo object as a string.
 */
function mymodule_foo_get_id(stdClass $foo) {

and/or

/**
 * Returns the ID of object Foo.
 *
 * @param stdClass $foo
 *   A Foo object.
 *
 * @return string
 *   The ID of this Foo object as a string.
 */
function mymodule_foo_get_id(object $foo) {

The purpose of this issue is create a sniff that will identify this type of inconsistency in the future.

Comments

Lars Toomre’s picture

We need a sniff to check for namespaced objects use in docblocks.

[Add common bad example].

Lars Toomre’s picture

Actually, as I think about it further, the namespaced object probably should be a different sniff. Hence, I am going to open up a separate new issue.

Liam Morland’s picture

Component: Code Sniffer » Coder Sniffer
Issue summary: View changes
Related issues: +#1820082: Ensure @param array type used in function definition (as appropriate)
klausi’s picture

Version: 7.x-2.x-dev » 8.x-2.x-dev
Status: Active » Fixed

This is already working in Coder 8.x-2.x, please test with that version.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.