Not sure why the methods are abstract ? If my class only needs to react to a couple events handled by the trait, it still needs to explicitly provide empty implementations for all the others. Couldn't the traits provide empty base implementations, with consumer classes only having to override the ones they're actually interested in ?

Original report by yched

The phpdocs for the various onEntityType*() / onField*() methods only state {@inheritdoc}, but that's a lie : the there's no parent to inherit a doc from :-)

Also, not sure why the methods are abstract

Comments

plach’s picture

Status: Active » Needs review
StatusFileSize
new2.32 KB

Well, actually those traits are supposed to be used by classes implementing EntityTypeListenerInterface and/or FieldStorageDefinitionListenerInterface, which are linked in the doc blocks. That's why those methods are not documented on the traits.

Good point about method implementations, anyway.

Status: Needs review » Needs work

The last submitted patch, 1: entity-listener_traits-2411791-1.patch, failed testing.

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The phpdocs for the various onEntityType*() / onField*() methods only state {@inheritdoc}, but that's a lie : the there's no parent to inherit a doc from :-)

Good trick!

Also : not sure why the methods are abstract ?

In case you would have just method I'd like it to abstract, because your IDE will tell you, what you need to implement, basically similar to interfaces.

yched’s picture

OK, so I'm not sure what we RTBC here :-)

- The patch doesn't fix the {@inheritdocs} because, if I read #1 correctly they're kind of "by design" ? (a trait doesn't implement an interface, it is classes that can use the trait to implement some interfaces)

- It removes the "abstract" keywords on methods, which, if I read #4 correctly, was intentional ?

plach’s picture

Yep, {@inheritdocs} were by design, while methods were abstract because I wrongly assumed that an implementation would need them all.

yched’s picture

Title: Wrong @inheritdocs in EntityTypeEventSubscriberTrait / FieldStorageDefinitionEventSubscriberTrait » Provide empty methods rather than abstract methods in EntityTypeEventSubscriberTrait / FieldStorageDefinitionEventSubscriberTrait
Issue summary: View changes
Issue tags: -Documentation

OK - updating the issue title and summary accordingly then :-)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

So can the traits implement the interfaces then? Nope traits can not implement interfaces

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Not sure what to do about the inheritdoc

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: entity-listener_traits-2411791-1.patch, failed testing.

plach’s picture

Status: Needs work » Reviewed & tested by the community

Bot fluke, I guess

yched’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.99 KB
new683 bytes

We can remove an empty implementation now :-)

plach’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

The {@inheritdoc} issue is not created by this patch. And this patch makes it easier to work with the trait. This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 23ced28 and pushed to 8.0.x. Thanks!

  • alexpott committed 23ced28 on 8.0.x
    Issue #2411791 by yched, plach: Provide empty methods rather than...

Status: Fixed » Closed (fixed)

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