Closed (fixed)
Project:
Drupal core
Version:
main
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Mar 2026 at 20:26 UTC
Updated:
22 May 2026 at 21:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
mondrakeComment #4
mondrakeComment #5
mondrakeComment #6
smustgrave commentedPretty straight forward, no objections to the changes.
Comment #7
xjmThis issue has many of the changes I'd expect -- simply adding
voidtypehints to test method signatures -- but then there are other changes like this:Or this:
...And then there are things like switching
assertEquals()toassertSame(), which is a different scope of typing in tests. Or:...Note actually a typehint at all, but a docblock.
This is one of those merge requests that is much easier to generate from static analysis than it is to review, because each of these different cases needs separate evaluation. TLDR, this issue has scope-crept a lot from the original scope described in the IS and should be split up accordingly. :)
Comment #8
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #9
mondrakerebased and added types to base class properties and some of the traits
Comment #10
mondrakeanyone willing tackle #7 and split this up, feel free.
Comment #11
mstrelan commentedI'm not so sure about that, the proposed resolution says:
Comment #12
smustgrave commentedThe change to testGetComponentNames does seem weird but is it a blocker for this ticket?
Comment #13
mondrake#12 yes, that solves this baseline entry:
That happens because
\Drupalhas thiswhile
Drupal\locale\LocaleDefaultConfigStorageexpectsin fact I think \Drupal is wrong (otherwise we would get a TypeError, as the parameter is strictly typed in the constructor), but I did not want to change \Drupal, here it's only about test code. Splitting the code in a variable assignment and asserting the inheritance on the variable makes PHPStan be confident we are not passing a wrongly typed parameter.
Please, add comments inline on the MR if possible, it's easier to see the context.
Comment #14
smustgrave commentedYour explanation makes sense to me.
Comment #15
mondrakeActually - checked a bit.
\Drupalis right.Drupal\Core\Language\LanguageManagerInterfaceis an ancestor of theDrupal\language\ConfigurableLanguageManager, that implements the additionalDrupal\language\ConfigurableLanguageManagerInterfaceinterface.So it's right that
\Drupal::languageManager()returns the topmost interface. The language module then overrides the standard manager with its own class, so the concrete class returned will be the replaced one that implements both interfaces.But since
Drupal\locale\LocaleDefaultConfigStoragerequiresConfigurableLanguageManagerInterfacethe assertInstanceOf is IMHO the proper 'type narrowing' action to take.Comment #16
longwaveCan we change the type in the
LocaleDefaultConfigStorageconstructor? The only usage isand that method is on the parent
LanguageManagerInterfaceinterface - it doesn't seem to needConfigurableLanguageManagerInterface?Comment #17
mondrake#16 if it's OK to change runtime code in this MR, sure we can, done in latest commit.
Comment #18
smustgrave commentedFeedback from @longwave appears to be addressed.
Comment #20
longwaveCommitted and pushed 65586432e25 to main. Thanks!