Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
base system
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
19 Nov 2015 at 20:50 UTC
Updated:
27 Jul 2020 at 14:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
joelpittetThere are some legit calls, I think I got all the outliers.
Comment #4
joelpittetNM, render arrays... that's why fails. These may be the only 3 hold outs.
Comment #5
joelpittetNope, I'm wrong:) They are all correct.
Comment #7
joelpittetYes I know testbot! chill out;)
Comment #8
cburschkaSorry if I misunderstand the purpose of this old issue. I was about to create one with basically the same subject, before looking it up. I think that the problem was (and is) valid; the approach just wasn't right.
We can't use the keyword 'static' inside a string, since it will not be resolved correctly. Instead of replacing
[get_called_class(), 'method']with'static::method'the patch should have replaced it withstatic::class . '::method', which is indeed already used in a lot of places in core.Per this StackOverflow answer,
get_called_class()is fully identical tostatic::class(in PHP 5.5+), and the latter has a minor performance benefit.in 9.0.x, get_called_class() is still used in 18 files (14 of them in the form
[get_called_class(), '...']), whilestatic::classis used in 51 files (11 of them in the formstatic::class . '::...').Just for consistency (if negligible performance), we might want to look at this again.
Comment #9
cburschkaComment #10
cburschkaBad patch.
This one replaces
get_called_class()withstatic::classeverywhere.A further replacement we might consider is replacing
static::class . '::method'with[static::class, 'method']everywhere. The two are semantically equivalent and the latter is used far more commonly in core.Comment #11
cburschkaget_class($this)can also be replaced withstatic::class.(There is no such replacement for
get_class()in general.)Comment #12
daffie commentedTalked to @alexpott on slack about this issue. He is ok with both changes:
get_called_class()tostatic::classandget_class($this)tostatic::class.The IS needs an update.
The changes in the patch look good. But when I do a code base search for "get_class($this)" I still get a 167 results after I applied the patch.
Comment #13
ankitsingh0188I am working on this.
Comment #14
ankitsingh0188Comment #15
siddhant.bhosale commentedComment #17
cburschkaThe webdriver tests have always been a bit brittle, might be a random failure. Retesting.
Comment #18
siddhant.bhosale commentedThe patch is applied successfully and looks good to be merged.
Comment #19
daffie commentedUpdated the IS.
Comment #20
cburschkaConfirmed that all changes in the patch replace instances of '
get_called_class()/get_class($this)withstatic::class, and that there aren't any of them left after applying it.Comment #21
catchNeeds a re-roll.
Comment #22
ravi.shankar commentedWorking on this.
Comment #23
ravi.shankar commentedAdded reroll of patch #14.
Comment #24
jungleNo leftovers.
Comment #25
catchCommitted eafefd8 and pushed to 9.1.x. Thanks!