Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
There are several typehints missing in \Drupal\Core\Entity\Element\EntityAutocomplete. Attached patch adds those type hints.
Comment | File | Size | Author |
---|---|---|---|
#8 | add_missing_typehints-2637304-8.patch | 3.18 KB | legolasbo |
#8 | interdiff-5-8.txt | 3.02 KB | legolasbo |
#5 | add_missing_typehints-2637304-5.patch | 3.03 KB | legolasbo |
Comments
Comment #2
cilefen CreditAttribution: cilefen commented"int" was correct here.
Comment #3
legolasbo@cilifen
Is that a coding standards thing?
Comment #4
cilefen CreditAttribution: cilefen commentedYes.
Comment #5
legolasboChanged
integer
back toint
as suggested in #2Comment #6
heykarthikwithuqueueing this for testing.
Comment #7
XanoMissing namespace.
Missing namespace.
\Drupal\Core\Entity\EntityInterface
.We integrate with interfaces, not classes, unless no interfaces exist.
Missing namespace.
$element
needs a type hint.$element
in::valueCallback()
needs a type hint as well.What is #DrupalBoyScout?
Comment #8
legolasboThanks for the review Xano,
I have fixed your suggestions and for future patches like these I will keep in mind that we use full namespace paths for type hints.
I will open a follow up for this because the added type hint requires the parent interface and all it's children to be type hinted as well.
The boyscout principle states that you always leave your code a little cleaner than you found it. Since Drupal's code base is full of things that can be a lot cleaner I want to initiate a movement to always clean Drupal's code whenever you encounter a possibility to do so. I therefor introduced this tag to keep track of any issues created with the sole purpose of cleaning up Drupal's codebase.
Comment #9
legolasboAdded #2643890: Add missing typehint for FormElementInterface::valueCallback() as a follow-up.
Comment #10
XanoDuh. Never mind the follow-up even, as that would be a BC break. Thanks for pointing out!
I like the initiative, but let's come up with a gender-inclusive name. We're both from a country where scouts don't distinguish between genders ;-)
Comment #11
legolasboToo late, already opened + patch added. Also we could argue (in the other issue) that the BC break is limited and/or not a big deal because everyone is (should be) passing an array and every implementation should break if a non-array is passed.
How about DrupalCodeScouts, DrupalCleanCoders, DrupalCodeCleanup or something like that?
Back on-topic. RTBC?
Comment #12
XanoThere's clean-up as well.
Comment #13
alexpottI pondered if this should be allowed in 8.0.x but given the call to getReferenceableEntities this makes a lot of sense.
Committed 5ce93e8 and pushed to 8.0.x and 8.1.x. Thanks!