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.
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
Comment #1
YesCT CreditAttribution: YesCT commentedused [#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?
Comment #2
TravisCarden CreditAttribution: TravisCarden commentedConfirming: 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.
Comment #5
klausiFixed in 8.x-2.x and 7.x-2.x, thanks for reporting!