- Issue created by @bradjones1
- π¦πΊAustralia mstrelan
FWIW there is a rector rule AddOverrideAttributeToOverriddenMethodsRector for adding the attribute. It won't remove the @inheritdoc annotation though.
- π¬π§United Kingdom longwave UK
I am not sure we could do this until Drupal 10 EOL because it feels like it would make cherry-picking backports from 11 to 10 much more difficult.
- π¬π§United Kingdom joachim
It's worth mentioning the opinion here: https://stitcher.io/blog/override-in-php-83
> we're adding runtime checks for something that could be determined by static analysers.
- πΊπΈUnited States bradjones1 Digital Nomad Life
I don't feel particularly strongly about this, mostly created the issue from a thread in Slack proposing this change.
From Brandt's blog, as pointed out in #5 -
Once again we're adding runtime checks for something that could be determined by static analysers.
I'm not sure I actually follow this. One of the main reasons for using the annotation is to identify where you _think_ you are overriding a method on a parent class or implementing an interface. If the parent class(es) or interface change, then you will get an error (and static analysis failure and/or notification in your IDE.) I think you would have to implement specific static analysis rules to do the same, and that seems a bit more complex than replacing a rather useless/outdated @inheritdoc with something that is more meaningful in modern PHP with Override.
- Assigned to niharika.s
- π³πΏNew Zealand quietone
@niharika.s, Hi, Welcome to Drupal! For Drupal core, it is preferred that contributors add a comment that they are working on an issue instead of assigning it to themselves. See Assigning ownership of a Drupal core issue β . After reading the comments this particular issue is still in discussion and not ready for an MR.
This will also conflict with existing Drupal core coding standards requirement for a doc block on a method. I think it would be sniff Drupal.Commenting.FunctionComment.Missing which is being worked on in π Fix Drupal.Commenting.FunctionComment.Missing in modules but not tests Active .
I reviewed the code where @inheritdoc annotations were used, and I noticed that the @inheritdoc is currently commented out. Since itβs not being utilized actively, I believe there's no immediate impact of leaving it as is. please Let me know if you need any further updates or clarifications.
- πΊπΈUnited States nicxvan
Yeah I don't think this adds value, since we have phpstan already running that can catch things like this.
Further this would add thousands of Attributes which do get checked.
My IDE already will show a message if you're not matching the interface.
- πΊπΈUnited States bradjones1 Digital Nomad Life
Back to NW as it seems the broader question is whether this should happen at all.
Re: #10, I think this is a misunderstanding of how doxygen works. They are commented out by virtue of being doxygen.
Re: #11:
Further this would add thousands of Attributes which do get checked.
I think this is a feature, not a bug?
My IDE already will show a message if you're not matching the interface.
Sure, but as noted above - I do not believe it will necessarily catch the situation where you intend to override a method that is no longer there. That's the real benefit of
Override
.