Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Lars Toomre CreditAttribution: Lars Toomre commentedWe need a sniff to check for namespaced objects use in docblocks.
[Add common bad example].
Comment #2
Lars Toomre CreditAttribution: Lars Toomre commentedActually, 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.
Comment #3
Liam MorlandComment #4
klausiThis is already working in Coder 8.x-2.x, please test with that version.