Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
user.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Oct 2012 at 16:56 UTC
Updated:
16 May 2015 at 23:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
lars toomre commentedThe first patch in this sub-issue addresses type hinting for approximately a dozen functions in the user.module file.
As this is a module that dates from Drupal's earliest days, this one file will require several iterations before it fully contains accurate and complete docblocks that include type hinting on all appropriate @param and @return directives. At present, there are more than a half-dozen functions in this one file that have no docblock whatsoever.
Comment #2
lars toomre commentedZero bytes... Grr!! Let try that attachment again!
Comment #2.0
lars toomre commentedAdded reference to relevent API docs issue.
Comment #2.1
lars toomre commentedAdded reference to Code Review sprint issue.
Comment #2.2
lars toomre commentedReformatted related issues as a table.
Comment #2.3
lars toomre commentedAdded links to Meta issues.
Comment #3
lars toomre commentedHere is a patch that adds missing type hinting to all @param and @return directives in hook declarations in user.api.php file.
Where appropriate, I also added missing array hinting to parameters in the function declarations as well.
Comment #3.0
lars toomre commentedCorrected table labels.
Comment #4
Jalandhar commentedPatch no longer applies. It needs reroll.
Comment #5
Jalandhar commentedHere is the updated patch
Comment #6
mile23Comment #7
idebr commented$account is now typehinted by its interface, for example see http://cgit.drupalcode.org/drupal/tree/core/modules/user/src/Permissions...
Comment #8
mile23More work. I think I got most.
Ended up filing this issue, because there was a big @todo about refactoring with no associated issue: #2403729: Convert user_cancel_confirm() to a new-style Form object
Comment #9
dawehnerIs this really a menu callback? Isn't that a controller?
Its Drupal\user\Entity\User now.
Why can't we typehint for \Drupal\user\UserInterface here?
Comment #10
idebr commentedYes, $account should be type hinted by its interface, I commented on it earlier in #7.
Comment #11
mile23Thanks for the review.
#9.1: I just copied the docblock over from user_cancel_confirm(), and I guess I should remove that change from this patch.
#9.2: Well spotted, but I'll go you one better. The first thing this function does is this:
Which means it has to be
AccountInterface, although there is that weirdness withelseif (!empty($account->homepage)) {.#9.3:
user_delete_multiple()just callsentity_delete_multiple(), anduser_view()just callsentity_view(). Both take anEntityInterface. There's really no difference between theuser_andentity_methods in this regard, since entities are so well encapsulated.In fact, there should be a
static EntityInterface::deleteMultiple($entities[]);but that's a whole other scope.Regardless.. I'll change it all.
I added actual type hinting in user.module. if that explodes, then a) there's a new issue to file, and b), I'll take it out and restrict my changes to only docblocks.
Comment #12
dawehnerThank you for taking the review into account.
Comment #13
alexpottNeeds reroll
Comment #14
mile23Reroll.
Comment #15
yesct commentedactual tag has no dash.
Comment #16
mile23Doesn't need a reroll, needs review. :-)
Comment #17
idebr commentedActually it did need a reroll :)
Changes look good! Let's get this in.
Comment #18
idebr commentedTestbot came back green, settings to RTBC.
Comment #19
yesct commentedtook out some unrelated changes that were out of scope of the issue.
added the leading \ to namespaces https://www.drupal.org/node/1353118
added some types to function definition to match the types added to the @param's
lowercase null should be used for types in @param and @return
https://www.drupal.org/node/1354#types
why this change?
It is false that it is an associative array with the role id as the key?
why the change in the description? looks like it is returning an array of objects, not strings.
Can we do
\Drupal\user\EntityOwnerInterface[]
?
relevant...
$roles = Role::loadMultiple();
maybe it should be
\Drupal\user\RoleInterface[]
Comment #20
mile23Needed a reroll.
#19.1: You got the nulls...
#19.2 and #19.3: Setting the
@returncomments to be the same as api.drupal.org.Also in #19.3: Let's just say
RoleInterface[]. The entity system doesn't enforce it, but it just so happens thatRoleimplementsRoleInterface, and the interface is where we want people to go for documentation.Comment #21
mile23Here it is again without changing the function signatures. This way it can be evaluated as a documentation change.
Comment #22
idebr commentedThe patch in #21 removes the type hinting from the function signatures, so the feedback has been addressed or no longer applies since the patch updates the documentation only.
Comment #23
jhodgdonUm, really?
User object is a stdObject object, not a particular class? (occurs multiple times in this patch). Shouldn't it be:
like in other spots in the patch?
Also, if you're fixing a function first line, like here:
Might as well also change Retrieve to Retrieves?
Also this is missing the \ in user.module:
I stopped reading the patch here but it's not really ready.
Comment #24
jhodgdonAlso, PLEASE do not set this or any of the other related issues to RTBC until the patch has been ***carefully*** reviewed and verified to be correct.
Comment #25
idebr commentedMy bad, I'll leave this for the documentation team :)My bad, I'll try to get the documentation right next time instead of checking if the patch applies.
Comment #26
jhodgdonThere is no "documentation team".
What we have is hopefully a community of Drupal developers who try to get the code documentation right. All I'm asking is that before marking a patch that is supposed to be fixing the documentation as "reviewed and tested", that the documentation actually be reviewed for accuracy, not just that the patch applies.
Comment #27
mile23@idebr: Thanks for working on it, at least.
@jhodgdon: Thanks for the mini-review. This patch addresses everything you mention, and also some stale docs in
user_user_logout().Comment #28
mile23Still applies, still addresses all missing hinting in docblocks.
Comment #29
mile23Comment #30
rishikant05 commentedComment #31
rishikant05 commentedRerolling the patch as its not applied.
Comment #32
rishikant05 commentedComment #33
yogen.prasad commentedLooking Fine
Comment #34
webchickLooks like all previous feedback has been addressed.
Committed and pushed to 8.0.x. Thanks!