Problem/Motivation

Currently in https://drupal.org/node/1354#types it's said that $this can be used
in @return when a main class is being returned but the sniff don't allow it.

Checking the code I see that if there is an $ will be return an error:

if (strpos($return->getValue(), '$') !== false) {
                    $error = '@return data type must not contain "$"';
                    $this->currentFile->addError($error, $errorPos, '$InReturnType');
}

Here is the issue (#1533250-36: Many coding standards clean-ups in locale module) where has been detected that the phpcs don't allow $this to be used in @return

Proposed resolution

Change the rules to allow $this for a @return

Remaining tasks

?

User interface changes

None

API changes

None

Comments

YesCT’s picture

used [#NNNN-CC] format to link to the issue in the issue summary.

--
Should we also open an issue in
https://github.com/TravisCarden/coder
which is mentioned in the meta for the core issue?

TravisCarden’s picture

Component: Coder Review » Coder Sniffer
Category: Task » Bug report

Confirming: Per our coding standards, "The @return tag is followed by an optional data type indicator, and then a newline", and $this is explicitly listed as an example of a valid indicator.

@YesCT: No, there's no need to open an issue in https://github.com/TravisCarden/coder. If you have an actual fix and it's not getting committed here fast enough, you can submit a pull request there, and I'll merge it in the meantime.

  • Commit cfe9b3e on 8.x-2.x by klausi:
    Issue #2270551 : Allow $this as data type in @return docs.
    

  • Commit 67620fe on 7.x-2.x by klausi:
    Issue #2270551 : Allow $this as data type in @return docs.
    
    Conflicts:...
klausi’s picture

Status: Active » Fixed

Fixed in 8.x-2.x and 7.x-2.x, thanks for reporting!

Status: Fixed » Closed (fixed)

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