Closed (fixed)
Project:
Drupal core
Version:
9.4.x-dev
Component:
system.module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Jan 2022 at 10:11 UTC
Updated:
9 Mar 2022 at 00:54 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
bserem commentedComment #3
bserem commentedComment #4
bserem commentedComment #5
bserem commentedComment #6
larowlanNice cleanup - looks good to me
Are there any other calls like this in core (outside umami)
If so we should fix them all
Comment #7
cilefen commentedI sure don't mind commonsense fixes like this, but, won't the PHPStan project find these and more?
Comment #8
quietone commentedI'm with @cilefen.
I strongly suspect that Migration tests do this for various properties.
Comment #9
bserem commented@larowlan PhpStorm doesn't highlight anything else for me, only standard and umami
Comment #10
longwaveI think PhpStorm is actually wrong here. I get the same warning, but then if I press Ctrl+B on the highlighted
$user->rolesproperty, it takes me to\Drupal\filter\Entity\FilterFormat::$roleswhich is irrelevant.$user->rolesis a dynamically defined magic entity property, and PhpStorm doesn't understand these. I assume it's somehow figuring out from docblocks thatUser::load()returns an EntityInterface, and FilterFormat is the only EntityInterface in core that has a$rolesproperty, so it wrongly assumes it must be that one.If PhpStorm was right, I don't think
standard_install()would work - the administrator role would never be assigned to user 1 - but tests show this is working as intended.Comment #11
tstoeckler@longwave you are right! Wow, I never would have thought of that. But when I temporarily change the name of the
$rolesproperty ofFilterFormatthe "error" disappears.Yes, the current code is not broken, but the patch makes it more readable/self-documenting and it also removes a common (at least for me!) annoyance for people using PhpStorm. So even if PhpStorm is being a bit weird in this situation for me it's still a win-win to commit this patch. Not marking RTBC as I don't want to undermine any further discussion or reservations, but ++.
Comment #12
longwaveAgree we should use the API where possible to set a good example, and conveniently this also fixes the PhpStorm issue, so I'm going to mark this RTBC anyway.
Comment #13
kartagisI get the same "error" on
$form_state->inputand Cmd+B takes me tocore/lib/Drupal/Core/Form/FormState.php, which saysprotected $input;. I must add that this is the standard profile.Comment #14
bserem commented@kartagis I can't find any occurences of
$form_state->inputin the standard profile. May I suggest to create a followup issue and provide more information about it there?Comment #15
kartagis@bserem yeah, sorry. I should've mentioned that
$form_state->inputis in a custom module.Comment #17
bserem commentedAt some point automated tests failed for D9 for reasons not related to this issue. I asked for tests to run again and they are green again.
Putting this back to RTBC
Comment #18
alexpottCommitted and pushed 056040934b to 10.0.x and 123f259d82 to 9.4.x. Thanks!