Discovered as part of #2935947: Comply with code standards

HttpExceptionNormalizer and others should type hint to AccountInterface, not AccountProxyInterface.

CommentFileSizeAuthor
#5 2936185-5.patch5.47 KBgabesullice

Comments

gabesullice created an issue. See original summary.

e0ipso’s picture

I am missing the why here. Can you elaborate?

gabesullice’s picture

Assigned: Unassigned » gabesullice
wim leers’s picture

My guess: because interface AccountProxyInterface extends AccountInterface {…} — i.e. AccountInterface is the base interface. Unless JSON API calls any of the methods that AccountProxyInterface layers on top, we should just typehint to the base interface.

gabesullice’s picture

Status: Active » Needs review
StatusFileSize
new5.47 KB

@Wim Leers, yep. And I admit it's a knee-jerk reaction that I've built up working (and testing) a lot access related code that isn't obviously valuable in this module. Just a best-practice earned from experience.

The practical reason is this:

  1. AccountProxy is the only class that implements AccountProxyInterface.
  2. But both AccountProxyInterface and UserInterface implement AccountInterface.
  3. Therefore, when you use AccountInterface, you can either pass the account you have or a user entity... which is the whole point of interfaces in the first place :)
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

#5 is correct. And this would definitely also come up when we try to move this module into Drupal core!

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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