Issue #1800174 by Mile23, Lars Toomre, rishikant05, YesCT, idebr, Jalandhar, jhodgdon, dawehner: Add missing type hinting to User module docblocks

8.0.x
webchick 2015-05-02 16:08:41 -07:00
parent 6889e50f17
commit b3cd848705
4 changed files with 93 additions and 81 deletions

View File

@ -46,7 +46,7 @@ abstract class AccountForm extends ContentEntityForm {
* The entity manager. * The entity manager.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager. * The language manager.
* @param \Drupal\Core\Entity\Query\QueryFactory * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
* The entity query factory. * The entity query factory.
*/ */
public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, QueryFactory $entity_query) { public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, QueryFactory $entity_query) {

View File

@ -149,11 +149,15 @@ class UserLoginTest extends WebTestBase {
/** /**
* Make an unsuccessful login attempt. * Make an unsuccessful login attempt.
* *
* @param $account * @param \Drupal\user\Entity\User $account
* A user object with name and pass_raw attributes for the login attempt. * A user object with name and pass_raw attributes for the login attempt.
* @param $flood_trigger * @param mixed $flood_trigger
* Whether or not to expect that the flood control mechanism will be * (optional) Whether or not to expect that the flood control mechanism
* triggered. * will be triggered. Defaults to NULL.
* - Set to 'user' to expect a 'too many failed logins error.
* - Set to any value to expect an error for too many failed logins per IP
* .
* - Set to NULL to expect a failed login.
*/ */
function assertFailedLogin($account, $flood_trigger = NULL) { function assertFailedLogin($account, $flood_trigger = NULL) {
$edit = array( $edit = array(

View File

@ -28,11 +28,11 @@ use Drupal\Core\Entity\EntityInterface;
* Expensive operations should be added to the global account cancellation batch * Expensive operations should be added to the global account cancellation batch
* by using batch_set(). * by using batch_set().
* *
* @param $edit * @param array $edit
* The array of form values submitted by the user. * The array of form values submitted by the user.
* @param $account * @param \Drupal\Core\Session\AccountInterface $account
* The user object on which the operation is being performed. * The user object on which the operation is being performed.
* @param $method * @param string $method
* The account cancellation method. * The account cancellation method.
* *
* @see user_cancel_methods() * @see user_cancel_methods()
@ -81,7 +81,7 @@ function hook_user_cancel($edit, $account, $method) {
* a method. If 'access' is defined, the method cannot be configured as * a method. If 'access' is defined, the method cannot be configured as
* default method. * default method.
* *
* @param $methods * @param array $methods
* An array containing user account cancellation methods, keyed by method id. * An array containing user account cancellation methods, keyed by method id.
* *
* @see user_cancel_methods() * @see user_cancel_methods()
@ -111,10 +111,10 @@ function hook_user_cancel_methods_alter(&$methods) {
* displayed. Can be used to ensure user privacy in situations where * displayed. Can be used to ensure user privacy in situations where
* $account->name is too revealing. * $account->name is too revealing.
* *
* @param $name * @param string $name
* The string that user_format_name() will return. * The string that user_format_name() will return.
* *
* @param $account * @param object $account
* The account object passed to user_format_name(). * The account object passed to user_format_name().
* *
* @see user_format_name() * @see user_format_name()
@ -129,7 +129,7 @@ function hook_user_format_name_alter(&$name, $account) {
/** /**
* The user just logged in. * The user just logged in.
* *
* @param $account * @param object $account
* The user object on which the operation was just performed. * The user object on which the operation was just performed.
*/ */
function hook_user_login($account) { function hook_user_login($account) {

View File

@ -349,7 +349,7 @@ function _user_role_permissions_update($roles) {
/** /**
* Checks for usernames blocked by user administration. * Checks for usernames blocked by user administration.
* *
* @param $name * @param string $name
* A string containing a name of the user. * A string containing a name of the user.
* *
* @return bool * @return bool
@ -390,10 +390,10 @@ function user_preprocess_block(&$variables) {
/** /**
* Format a username. * Format a username.
* *
* @param \Drupal\Core\Session\Interface $account * @param \Drupal\Core\Session\AccountInterface $account
* The account object for the user whose name is to be formatted. * The account object for the user whose name is to be formatted.
* *
* @return * @return string
* An unsanitized string with the username to display. The code receiving * An unsanitized string with the username to display. The code receiving
* this result must ensure that \Drupal\Component\Utility\SafeMarkup::checkPlain() * this result must ensure that \Drupal\Component\Utility\SafeMarkup::checkPlain()
* is called on it before it is printed to the page. * is called on it before it is printed to the page.
@ -435,7 +435,7 @@ function user_template_preprocess_default_variables_alter(&$variables) {
* *
* @param array $variables * @param array $variables
* An associative array containing: * An associative array containing:
* - account: The user account (Drupal\user\Plugin\Core\Entity\User). * - account: The user account (\Drupal\Core\Session\AccountInterface).
* *
* Modules that make any changes to variables like 'name' or 'extra' must ensure * Modules that make any changes to variables like 'name' or 'extra' must ensure
* that the final string is safe to include directly in the output by using * that the final string is safe to include directly in the output by using
@ -553,17 +553,14 @@ function user_user_logout($account) {
/** /**
* Generates a unique URL for a user to login and reset their password. * Generates a unique URL for a user to login and reset their password.
* *
* @param object $account * @param \Drupal\user\UserInterface $account
* An object containing the user account, which must contain at least the * An object containing the user account.
* following properties:
* - uid: The user ID number.
* - login: The UNIX timestamp of the user's last login.
* @param array $options * @param array $options
* (optional) A keyed array of settings. Supported options are: * (optional) A keyed array of settings. Supported options are:
* - langcode: A language code to be used when generating locale-sensitive * - langcode: A language code to be used when generating locale-sensitive
* URLs. If langcode is NULL the users preferred language is used. * URLs. If langcode is NULL the users preferred language is used.
* *
* @return * @return string
* A unique URL that provides a one-time log in for the user, from which * A unique URL that provides a one-time log in for the user, from which
* they can change their password. * they can change their password.
*/ */
@ -586,7 +583,7 @@ function user_pass_reset_url($account, $options = array()) {
/** /**
* Generates a URL to confirm an account cancellation request. * Generates a URL to confirm an account cancellation request.
* *
* @param object $account * @param \Drupal\user\UserInterface $account
* The user account object, which must contain at least the following * The user account object, which must contain at least the following
* properties: * properties:
* - uid: The user ID number. * - uid: The user ID number.
@ -597,7 +594,7 @@ function user_pass_reset_url($account, $options = array()) {
* - langcode: A language code to be used when generating locale-sensitive * - langcode: A language code to be used when generating locale-sensitive
* URLs. If langcode is NULL the users preferred language is used. * URLs. If langcode is NULL the users preferred language is used.
* *
* @return * @return string
* A unique URL that may be used to confirm the cancellation of the user * A unique URL that may be used to confirm the cancellation of the user
* account. * account.
* *
@ -650,11 +647,11 @@ function user_pass_rehash($password, $timestamp, $login, $uid) {
* Form API will invoke it, or batch_process() needs to be invoked after calling * Form API will invoke it, or batch_process() needs to be invoked after calling
* this function and should define the path to redirect to. * this function and should define the path to redirect to.
* *
* @param $edit * @param array $edit
* An array of submitted form values. * An array of submitted form values.
* @param $uid * @param int $uid
* The user ID of the user account to cancel. * The user ID of the user account to cancel.
* @param $method * @param string $method
* The account cancellation method to use. * The account cancellation method to use.
* *
* @see _user_cancel() * @see _user_cancel()
@ -712,6 +709,12 @@ function user_cancel($edit, $uid, $method) {
* *
* Since batch and session API require a valid user account, the actual * Since batch and session API require a valid user account, the actual
* cancellation of a user account needs to happen last. * cancellation of a user account needs to happen last.
* @param array $edit
* An array of submitted form values.
* @param \Drupal\user\UserInterface $account
* The user ID of the user account to cancel.
* @param string $method
* The account cancellation method to use.
* *
* @see user_cancel() * @see user_cancel()
*/ */
@ -825,7 +828,7 @@ function user_cancel_methods() {
/** /**
* Delete a user. * Delete a user.
* *
* @param $uid * @param int $uid
* A user ID. * A user ID.
*/ */
function user_delete($uid) { function user_delete($uid) {
@ -835,7 +838,7 @@ function user_delete($uid) {
/** /**
* Delete multiple user accounts. * Delete multiple user accounts.
* *
* @param $uids * @param int[] $uids
* An array of user IDs. * An array of user IDs.
* *
* @see hook_ENTITY_TYPE_predelete() * @see hook_ENTITY_TYPE_predelete()
@ -858,15 +861,15 @@ function user_delete_multiple(array $uids) {
* To theme user profiles, copy core/modules/user/templates/user.html.twig * To theme user profiles, copy core/modules/user/templates/user.html.twig
* to your theme directory, and edit it as instructed in that file's comments. * to your theme directory, and edit it as instructed in that file's comments.
* *
* @param $account * @param \Drupal\user\UserInterface $account
* A user object. * A user object.
* @param $view_mode * @param string $view_mode
* View mode, e.g. 'full'. * View mode, e.g. 'full'.
* @param $langcode * @param string|null $langcode
* (optional) A language code to use for rendering. Defaults to the global * (optional) A language code to use for rendering. Defaults to the global
* content language of the current request. * content language of the current request.
* *
* @return * @return array
* An array as expected by drupal_render(). * An array as expected by drupal_render().
*/ */
function user_view($account, $view_mode = 'full', $langcode = NULL) { function user_view($account, $view_mode = 'full', $langcode = NULL) {
@ -876,15 +879,15 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) {
/** /**
* Constructs a drupal_render() style array from an array of loaded users. * Constructs a drupal_render() style array from an array of loaded users.
* *
* @param $accounts * @param \Drupal\user\UserInterface[] $account
* An array of user accounts as returned by User::loadMultiple(). * An array of user accounts as returned by User::loadMultiple().
* @param $view_mode * @param string $view_mode
* (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser.' * (optional) View mode, e.g., 'full', 'teaser'... Defaults to 'teaser'.
* @param $langcode * @param string|null $langcode
* (optional) A language code to use for rendering. Defaults to the global * (optional) A language code to use for rendering. Defaults to the global
* content language of the current request. * content language of the current request.
* *
* @return * @return array
* An array in the format expected by drupal_render(). * An array in the format expected by drupal_render().
*/ */
function user_view_multiple($accounts, $view_mode = 'full', $langcode = NULL) { function user_view_multiple($accounts, $view_mode = 'full', $langcode = NULL) {
@ -922,17 +925,18 @@ function user_mail($key, &$message, $params) {
* some additional tokens that can be used in email messages generated by * some additional tokens that can be used in email messages generated by
* user_mail(). * user_mail().
* *
* @param $replacements * @param array $replacements
* An associative array variable containing mappings from token names to * An associative array variable containing mappings from token names to
* values (for use with strtr()). * values (for use with strtr()).
* @param $data * @param array $data
* An associative array of token replacement values. If the 'user' element * An associative array of token replacement values. If the 'user' element
* exists, it must contain a user account object with the following * exists, it must contain a user account object with the following
* properties: * properties:
* - login: The UNIX timestamp of the user's last login. * - login: The UNIX timestamp of the user's last login.
* - pass: The hashed account login password. * - pass: The hashed account login password.
* @param $options * @param array $options
* Unused parameter required by \Drupal\Core\Utility\Token::replace(). * A keyed array of settings and flags to control the token replacement
* process. See \Drupal\Core\Utility\Token::replace().
*/ */
function user_mail_tokens(&$replacements, $data, $options) { function user_mail_tokens(&$replacements, $data, $options) {
if (isset($data['user'])) { if (isset($data['user'])) {
@ -944,15 +948,17 @@ function user_mail_tokens(&$replacements, $data, $options) {
/*** Administrative features ***********************************************/ /*** Administrative features ***********************************************/
/** /**
* Retrieve an array of roles matching specified conditions. * Retrieves the names of roles matching specified conditions.
* *
* @param $membersonly * @param bool $membersonly
* Set this to TRUE to exclude the 'anonymous' role. * (optional) Set this to TRUE to exclude the 'anonymous' role. Defaults to
* @param $permission * FALSE.
* A string containing a permission. If set, only roles containing that * @param string|null $permission
* permission are returned. * (optional) A string containing a permission. If set, only roles
* containing that permission are returned. Defaults to NULL, which
* returns all roles.
* *
* @return * @return array
* An associative array with the role id as the key and the role name as * An associative array with the role id as the key and the role name as
* value. * value.
*/ */
@ -1024,13 +1030,15 @@ function user_user_role_delete(RoleInterface $role) {
/** /**
* Retrieve an array of roles matching specified conditions. * Retrieve an array of roles matching specified conditions.
* *
* @param $membersonly * @param bool $membersonly
* Set this to TRUE to exclude the 'anonymous' role. * (optional) Set this to TRUE to exclude the 'anonymous' role. Defaults to
* @param $permission * FALSE.
* A string containing a permission. If set, only roles containing that * @param string|null $permission
* permission are returned. * (optional) A string containing a permission. If set, only roles
* containing that permission are returned. Defaults to NULL, which
* returns all roles.
* *
* @return * @return \Drupal\user\RoleInterface[]
* An associative array with the role id as the key and the role object as * An associative array with the role id as the key and the role object as
* value. * value.
*/ */
@ -1067,10 +1075,10 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
/** /**
* Fetches a user role by role ID. * Fetches a user role by role ID.
* *
* @param $rid * @param string $rid
* A string representing the role ID. * A string representing the role ID.
* *
* @return * @return \Drupal\user\RoleInterface|null
* A fully-loaded role object if a role with the given ID exists, or NULL * A fully-loaded role object if a role with the given ID exists, or NULL
* otherwise. * otherwise.
* *
@ -1089,13 +1097,14 @@ function user_role_load($rid) {
* role, the form submit handler may directly pass the submitted values for the * role, the form submit handler may directly pass the submitted values for the
* checkboxes form element to this function. * checkboxes form element to this function.
* *
* @param $rid * @param mixed $rid
* The ID of a user role to alter. * The ID of a user role to alter.
* @param $permissions * @param array $permissions
* An associative array, where the key holds the permission name and the value * (optional) An associative array, where the key holds the permission name
* determines whether to grant or revoke that permission. Any value that * and the value determines whether to grant or revoke that permission. Any
* evaluates to TRUE will cause the permission to be granted. Any value that * value that evaluates to TRUE will cause the permission to be granted.
* evaluates to FALSE will cause the permission to be revoked. * Any value that evaluates to FALSE will cause the permission to be
* revoked.
* @code * @code
* array( * array(
* 'administer nodes' => 0, // Revoke 'administer nodes' * 'administer nodes' => 0, // Revoke 'administer nodes'
@ -1126,10 +1135,10 @@ function user_role_change_permissions($rid, array $permissions = array()) {
/** /**
* Grant permissions to a user role. * Grant permissions to a user role.
* *
* @param $rid * @param mixed $rid
* The ID of a user role to alter. * The ID of a user role to alter.
* @param $permissions * @param array $permissions
* A list of permission names to grant. * (optional) A list of permission names to grant.
* *
* @see user_role_change_permissions() * @see user_role_change_permissions()
* @see user_role_revoke_permissions() * @see user_role_revoke_permissions()
@ -1147,10 +1156,10 @@ function user_role_grant_permissions($rid, array $permissions = array()) {
/** /**
* Revoke permissions from a user role. * Revoke permissions from a user role.
* *
* @param $rid * @param mixed $rid
* The ID of a user role to alter. * The ID of a user role to alter.
* @param $permissions * @param array $permissions
* A list of permission names to revoke. * (optional) A list of permission names to revoke.
* *
* @see user_role_change_permissions() * @see user_role_change_permissions()
* @see user_role_grant_permissions() * @see user_role_grant_permissions()
@ -1168,10 +1177,7 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
* Conditionally create and send a notification email when a certain * Conditionally create and send a notification email when a certain
* operation happens on the given user account. * operation happens on the given user account.
* *
* @see user_mail_tokens() * @param string $op
* @see \Drupal\Core\Mail\MailManagerInterface::mail()
*
* @param $op
* The operation being performed on the account. Possible values: * The operation being performed on the account. Possible values:
* - 'register_admin_created': Welcome message for user created by the admin. * - 'register_admin_created': Welcome message for user created by the admin.
* - 'register_no_approval_required': Welcome message when user * - 'register_no_approval_required': Welcome message when user
@ -1184,16 +1190,18 @@ function user_role_revoke_permissions($rid, array $permissions = array()) {
* - 'cancel_confirm': Account cancellation request. * - 'cancel_confirm': Account cancellation request.
* - 'status_canceled': Account canceled. * - 'status_canceled': Account canceled.
* *
* @param $account * @param \Drupal\Core\Session\AccountInterface $account
* The user object of the account being notified. Must contain at * The user object of the account being notified. Must contain at
* least the fields 'uid', 'name', and 'mail'. * least the fields 'uid', 'name', and 'mail'.
* @param $langcode * @param string $langcode
* Optional language code to use for the notification, overriding account * (optional) Language code to use for the notification, overriding account
* language. * language.
* *
* @return * @return array
* The return value from \Drupal::service('plugin.manager.mail')->mail(), if * An array containint various information about the message.
* ends up being called. * See \Drupal\Core\Mail\MailManagerInterface::mail() for details.
*
* @see user_mail_tokens()
*/ */
function _user_mail_notify($op, $account, $langcode = NULL) { function _user_mail_notify($op, $account, $langcode = NULL) {
// By default, we always notify except for canceled and blocked. // By default, we always notify except for canceled and blocked.
@ -1282,7 +1290,7 @@ function user_modules_uninstalled($modules) {
/** /**
* Saves visitor information as a cookie so it can be reused. * Saves visitor information as a cookie so it can be reused.
* *
* @param $values * @param array $values
* An array of key/value pairs to be saved into a cookie. * An array of key/value pairs to be saved into a cookie.
*/ */
function user_cookie_save(array $values) { function user_cookie_save(array $values) {
@ -1295,7 +1303,7 @@ function user_cookie_save(array $values) {
/** /**
* Delete a visitor information cookie. * Delete a visitor information cookie.
* *
* @param $cookie_name * @param string $cookie_name
* A cookie name such as 'homepage'. * A cookie name such as 'homepage'.
*/ */
function user_cookie_delete($cookie_name) { function user_cookie_delete($cookie_name) {