Closed (fixed)
Project:
Drupal core
Version:
10.6.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Nov 2025 at 09:40 UTC
Updated:
18 Dec 2025 at 15:04 UTC
Jump to comment: Most recent
Comments
Comment #2
srushti_k commentedHi — I’m Srushti Kondhalkar (new to Drupal contributions).
I looked at this issue; the PHPDoc says @var \Drupal\user\UserInterface, but the property is initialized as FALSE.
I plan to reproduce and prepare a patch that changes the initial value to NULL so that the type matches.
Could someone please confirm if this approach is acceptable, or point me to the exact file path to update?
Thanks — I’ll follow up with a branch/merge request once I have the code.
— Srushti (srushti_k)
Comment #3
chi commentedThe fix should just extend the declared type in PHPDoc block
I think adding the native typehint here is out of scope for this issue.
Comment #4
longwaveWould it be better to use null instead of false? There might be some BC concerns doing that though.
Comment #5
chi commentedRe: #4. It certainly would. And yes, there might be BC break if someone checks the property with strict comparison operator.
Comment #8
aryan singh commentedComment #9
longwaveDiscussed briefly with @mondrake, I think it would be much better if we used typed properties:
or even better if we could use
Comment #10
chi commentedThen, why not add typehints to other trait properties and methods?
Comment #11
longwaveWell, exactly - that's probably worth doing in bulk in a followup.
Comment #12
smustgrave commentedFor #9
Comment #13
longwaveAs discussed in #10/11 not sure we should do that here, maybe let's just fix up the docs and then bulk-fix the properties later.
Comment #14
mondrakeNot sure it's worth changing this isolated case here.
My suggestion would be to do, for core/tests:
Comment #15
chi commentedAgree with #13. Here we just fix the bug in Docblock.
Changing native typehints is out of scope for this issue.
The MR looks right to me. Test failure seems unrelated.
Comment #16
mstrelan commentedNULL would indeed be better. For example, in
\Drupal\Tests\system\FunctionalJavascript\OffCanvasTestBase::assertPageLoadComplete, we could update$this->loggedInUser && $this->loggedInUser->hasPermission()to just$this->loggedInUser?->hasPermission().Core doesn't seem to have any cases where we are checking if the property is FALSE, only the loose empty check, but of course contrib would be the issue. I guess the same way would be to deprecate the
$loggedInUserproperty and make a new$authenticatedUserproperty.Comment #17
quietone commentedThis search reports 22 pages for
this->loggedInUser. Some of those are on 7.x branches and I don't see a way to exclude those from the search. So, not really all that helpful.Comment #18
longwaveBackported down to 10.6.x as a documentation fix.
Committed and pushed 422ac9c2aa6 to 11.x and ac5feee6fc6 to 11.3.x and 74bda5e0635 to 10.6.x. Thanks!