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.
Patch adds typehints and removes obsolete reference indicators for objects.
Typehints is great to get more feedback in your IDE.
Comment | File | Size | Author |
---|---|---|---|
#19 | 1199328-remove-obsolete-references.patch | 57.99 KB | bojanz |
#18 | 1199328-followup.patch | 2.06 KB | bojanz |
#17 | 1199328-followup.patch | 1.49 KB | bojanz |
#15 | 1199328-remove-obsolete-references.patch | 56.71 KB | bojanz |
#14 | 1199328-remove-obsolete-references.patch | 57.04 KB | bojanz |
Comments
Comment #1
casey CreditAttribution: casey commentedShould have tested the changes.
typehints are also useful as a test for improper hook implementations. I found out that hook_views_query_substitutions() was missing an argument and that views_plugin_query_default#query() was passing the wrong argument; itself instead of $view. views_plugin_query_default#execute() invokes the same hook but passes $view and the implementation user_views_query_substitutions() has $view as an argument.
Another, somewhat untidy but not disastrous, thing is that views_handler#init() sets a reference on $view->query, while that property doesn't contain an object yet. So I kept the reference indicator there, but added a comment.
Now I used 'view' and 'view_display' as typehint but it might be nicer to have an interface. You never know if someone wants to use its own view class.
Comment #2
dawehnerIn general this is cool, but doesn't this lead to notices?
Comment #3
casey CreditAttribution: casey commentedI am not entirely sure where you expect notices from?
Comment #4
dawehnerIf someone else extends
the signature changes. We had this thousand times when porting to drupal7.
Comment #5
casey CreditAttribution: casey commentedOww of course. Well then I am not sure if it is a good idea. You decide :)
Comment #6
dawehnerNo idea whether it cause notices or not, but just want to be sure about it :)
Comment #7
casey CreditAttribution: casey commentedYes it will. Thats a good thing, but not very much in our case as all contrib modules indeed need to be updated as well.
Comment #8
bojanz CreditAttribution: bojanz commentedI think it's too late in the release cycle to break all contrib handler implementations :/
But the patch has plenty of nice fixes that don't (shouldn't) break anything. Let's at least get that in.
Comment #9
bojanz CreditAttribution: bojanz commentedRerolled.
Comment #10
bojanz CreditAttribution: bojanz commentedReverted one wrong change caught by dereine (don't typehint $views)
Comment #11
dawehnerdisplay_id isn't a object, so it shouldn't be changed.
I personally like the & sign here, because it shows that this will be altered, as php doesn't have a const keyword, but i'm open for doing the change.
Comment #12
bojanz CreditAttribution: bojanz commentedRead the line again, I'm not touching $display_id :)
As for &$handler, the phpdoc above it says:
so it should be obvious enough.
Comment #13
dawehnerWord-diff doesn't lie :)
Good point
Comment #14
bojanz CreditAttribution: bojanz commentedYou're right, I suck :)
Comment #15
bojanz CreditAttribution: bojanz commentedReroll.
Comment #16
dawehnerHuge thanks here! Commited to 7.x-3.x
Comment #17
bojanz CreditAttribution: bojanz commentedSo I'm stupid tonight, which makes me wonder why I'm attempting patches this big.
Comment #18
bojanz CreditAttribution: bojanz commentedRemoved an old comment as well.
Comment #19
bojanz CreditAttribution: bojanz commentedSo we had to revert the whole thing....
Here's a patch from scratch. Probably needs work. Sigh.
Comment #20
dawehnerThis is a change from another patch, which shouldn't be done here.
Comment #21
dawehnerThis is still wrong here...
dito
Don't do any risk thing here.
Comment #22
bojanz CreditAttribution: bojanz commentedThis cleanup makes sense in 8.x-3.x.
I realize much of the code will be touched, cleaned-up and reworked, but this is a simple enough (if not frustrating) change to do upfront.
Comment #23
tim.plunkettComment #24
dawehner#1792454: Add type hinting to function signatures for $view