diff --git a/core/includes/password.inc b/core/includes/password.inc
index b052a4a..f89156d 100644
--- a/core/includes/password.inc
+++ b/core/includes/password.inc
@@ -13,6 +13,8 @@
* user_needs_new_hash() functions.
*/
+use Drupal\user\User;
+
/**
* The standard log2 number of iterations for password stretching. This should
* increase by 1 every Drupal version in order to counteract increases in the
@@ -221,13 +223,13 @@ function user_hash_password($password, $count_log2 = 0) {
*
* @param $password
* A plain-text password
- * @param $account
+ * @param Drupal\user\User $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
-function user_check_password($password, $account) {
+function user_check_password($password, User $account) {
if (substr($account->pass, 0, 2) == 'U$') {
// This may be an updated password from user_update_7000(). Such hashes
// have 'U' added as the first character and need an extra md5() (see the
@@ -270,13 +272,13 @@ function user_check_password($password, $account) {
* Alternative implementations of this function might use other criteria based
* on the fields in $account.
*
- * @param $account
+ * @param Drupal\user\User $account
* A user object with at least the fields from the {users} table.
*
* @return
* TRUE or FALSE.
*/
-function user_needs_new_hash($account) {
+function user_needs_new_hash(User $account) {
// Check whether this was an updated password.
if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != DRUPAL_HASH_LENGTH)) {
return TRUE;
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index 4a3d6b9..4c84617 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -5,6 +5,8 @@
* Controls the visual building blocks a page is constructed with.
*/
+use Drupal\user\User;
+
/**
* Denotes that a block is not enabled in any region and should not be shown.
*/
@@ -641,7 +643,7 @@ function block_field_extra_fields() {
/**
* Implements hook_user_presave().
*/
-function block_user_presave($account) {
+function block_user_presave(User $account) {
if (isset($account->block)) {
$account->data['block'] = $account->block;
}
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 39faf90..7ab828e 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -10,6 +10,7 @@
*/
use Drupal\node\Node;
+use Drupal\user\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -1421,7 +1422,7 @@ function comment_node_search_result(Node $node) {
/**
* Implements hook_user_cancel().
*/
-function comment_user_cancel($edit, $account, $method) {
+function comment_user_cancel($edit, User $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
$comments = comment_load_multiple(array(), array('uid' => $account->uid));
@@ -1444,7 +1445,7 @@ function comment_user_cancel($edit, $account, $method) {
/**
* Implements hook_user_predelete().
*/
-function comment_user_predelete($account) {
+function comment_user_predelete(User $account) {
$cids = db_query('SELECT c.cid FROM {comment} c WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol();
comment_delete_multiple($cids);
}
diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module
index 245c125..971d507 100644
--- a/core/modules/contact/contact.module
+++ b/core/modules/contact/contact.module
@@ -5,6 +5,8 @@
* Enables the use of personal and site-wide contact forms.
*/
+use Drupal\user\User;
+
/**
* Implements hook_help().
*/
@@ -109,12 +111,12 @@ function contact_menu() {
/**
* Access callback: Checks access for a user's personal contact form.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user object of the user whose contact form is being requested.
*
* @see contact_menu()
*/
-function _contact_personal_tab_access($account) {
+function _contact_personal_tab_access(User $account) {
global $user;
// Anonymous users cannot have contact forms.
@@ -233,7 +235,7 @@ function contact_form_user_profile_form_alter(&$form, &$form_state) {
/**
* Implements hook_user_presave().
*/
-function contact_user_presave($account) {
+function contact_user_presave(User $account) {
$account->data['contact'] = isset($account->contact) ? $account->contact : config('contact.settings')->get('user_default_enabled');
}
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
index 16d26b0..539634d 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
@@ -7,6 +7,7 @@
namespace Drupal\contact\Tests;
+use Drupal\user\User;
use Drupal\simpletest\WebTestBase;
/**
@@ -159,12 +160,12 @@ class ContactPersonalTest extends WebTestBase {
/**
* Fills out a user's personal contact form and submits it.
*
- * @param $account
+ * @param Drupal\user\User $account
* A user object of the user being contacted.
* @param $message
* An optional array with the form fields being used.
*/
- protected function submitPersonalContact($account, array $message = array()) {
+ protected function submitPersonalContact(User $account, array $message = array()) {
$message += array(
'subject' => $this->randomName(16),
'message' => $this->randomName(64),
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index f770e06..d10f99c 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -2658,13 +2658,13 @@ function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
* The type of $entity; for example, 'node' or 'user'.
* @param $entity
* (optional) The entity for the operation.
- * @param $account
+ * @param Drupal\user\User $account
* (optional) The account to check; if not given use currently logged in user.
*
* @return
* TRUE if the operation is allowed, and FALSE if the operation is denied.
*/
-function hook_field_access($op, $field, $entity_type, $entity, $account) {
+function hook_field_access($op, $field, $entity_type, $entity, Drupal\user\User $account) {
if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
return user_access('edit field of interest', $account);
}
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 8157971..7654b04 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -4,6 +4,7 @@
* Attach custom data fields to Drupal entities.
*/
+use Drupal\user\User;
use Drupal\entity\EntityFieldQuery;
/*
@@ -995,14 +996,14 @@ function field_has_data($field) {
* The type of $entity; e.g., 'node' or 'user'.
* @param $entity
* (optional) The entity for the operation.
- * @param $account
+ * @param Drupal\user\User $account
* (optional) The account to check, if not given use currently logged in user.
*
* @return
* TRUE if the operation is allowed;
* FALSE if the operation is denied.
*/
-function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) {
+function field_access($op, $field, $entity_type, $entity = NULL, User $account = NULL) {
global $user;
if (!isset($account)) {
diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc
index 8933d8b..1d5f1b2 100644
--- a/core/modules/field/tests/modules/field_test/field_test.field.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.field.inc
@@ -6,6 +6,7 @@
*/
use Drupal\field\FieldException;
+use Drupal\user\User;
/**
* Implements hook_field_info().
@@ -405,7 +406,7 @@ function field_test_default_value($entity_type, $entity, $field, $instance) {
/**
* Implements hook_field_access().
*/
-function field_test_field_access($op, $field, $entity_type, $entity, $account) {
+function field_test_field_access($op, $field, $entity_type, $entity, User $account) {
if ($field['field_name'] == "field_no_{$op}_access") {
return FALSE;
}
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index f4fb5f5..0166f9d 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -181,7 +181,7 @@ use Drupal\entity\EntityInterface;
* sure to restore your {node_access} record after node_access_rebuild() is
* called.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user object whose grants are requested.
* @param $op
* The node operation to be performed, such as "view", "update", or "delete".
@@ -196,7 +196,7 @@ use Drupal\entity\EntityInterface;
* @see node_access_rebuild()
* @ingroup node_access
*/
-function hook_node_grants($account, $op) {
+function hook_node_grants(Drupal\user\User $account, $op) {
if (user_access('access private content', $account)) {
$grants['example'] = array(1);
}
@@ -363,7 +363,7 @@ function hook_node_access_records_alter(&$grants, Drupal\node\Node $node) {
*
* @param $grants
* The $grants array returned by hook_node_grants().
- * @param $account
+ * @param Drupal\user\User $account
* The user account requesting access to content.
* @param $op
* The operation being performed, 'view', 'update' or 'delete'.
@@ -373,7 +373,7 @@ function hook_node_access_records_alter(&$grants, Drupal\node\Node $node) {
* @see hook_node_access_records_alter()
* @ingroup node_access
*/
-function hook_node_grants_alter(&$grants, $account, $op) {
+function hook_node_grants_alter(&$grants, Drupal\user\User $account, $op) {
// Our sample module never allows certain roles to edit or delete
// content. Since some other node access modules might allow this
// permission, we expressly remove it by returning an empty $grants
@@ -594,7 +594,7 @@ function hook_node_load($nodes, $types) {
* - "delete"
* - "update"
* - "view"
- * @param object $account
+ * @param Drupal\user\User $account
* The user object to perform the access check operation on.
* @param object $langcode
* The language code to perform the access check operation on.
@@ -606,7 +606,7 @@ function hook_node_load($nodes, $types) {
*
* @ingroup node_access
*/
-function hook_node_access($node, $op, $account, $langcode) {
+function hook_node_access($node, $op, Drupal\user\User $account, $langcode) {
$type = is_string($node) ? $node : $node->type;
$configured_types = node_permissions_get_configured_types();
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index be15dee..d154567 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -14,6 +14,7 @@ use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\node\Node;
+use Drupal\user\User;
/**
* Denotes that the node is not published.
@@ -1690,7 +1691,7 @@ function node_ranking() {
/**
* Implements hook_user_cancel().
*/
-function node_user_cancel($edit, $account, $method) {
+function node_user_cancel($edit, User $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
// Unpublish nodes (current revisions).
@@ -1728,7 +1729,7 @@ function node_user_cancel($edit, $account, $method) {
/**
* Implements hook_user_predelete().
*/
-function node_user_predelete($account) {
+function node_user_predelete(User $account) {
// Delete nodes (current revisions).
// @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
$nodes = db_select('node', 'n')
@@ -1784,8 +1785,8 @@ function theme_node_search_admin($variables) {
* The node to check.
* @param $op
* (optional) The specific operation being checked. Defaults to 'view.'
- * @param object $account
- * (optional) A user object representing the user for whom the operation is
+ * @param Drupal\user\User $account
+ * (optional) A user entity representing the user for whom the operation is
* to be performed. Determines access for a user other than the current user.
* @param $langcode
* (optional) Language code for the variant of the node. Different language
@@ -2918,7 +2919,7 @@ function node_form_system_themes_admin_form_submit($form, &$form_state) {
* @param Drupal\node\Node|string|stdClass $node
* The node entity on which the operation is to be performed, or the node type
* object, or node type string (e.g., 'forum') for the 'create' operation.
- * @param $account
+ * @param Drupal\user\User $account
* (optional) A user object representing the user for whom the operation is to
* be performed. Determines access for a user other than the current user.
* @param $langcode
@@ -2935,7 +2936,7 @@ function node_form_system_themes_admin_form_submit($form, &$form_state) {
* Add langcode support to node_access schema / queries.
* http://drupal.org/node/1658846
*/
-function node_access($op, $node, $account = NULL, $langcode = NULL) {
+function node_access($op, $node, User $account = NULL, $langcode = NULL) {
$rights = &drupal_static(__FUNCTION__, array());
if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) {
@@ -3041,7 +3042,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
/**
* Implements hook_node_access().
*/
-function node_node_access($node, $op, $account) {
+function node_node_access($node, $op, User $account) {
$type = is_string($node) ? $node : $node->type;
$configured_types = node_permissions_get_configured_types();
@@ -3134,15 +3135,15 @@ function node_permissions_get_configured_types() {
*
* @param $op
* The operation that the user is trying to perform.
- * @param $account
- * (optional) The user object for the user performing the operation. If
+ * @param Drupal\user\User $account
+ * (optional) The user entity for the user performing the operation. If
* omitted, the current user is used.
*
* @return
* An associative array in which the keys are realms, and the values are
* arrays of grants for those realms.
*/
-function node_access_grants($op, $account = NULL) {
+function node_access_grants($op, User $account = NULL) {
if (!isset($account)) {
$account = $GLOBALS['user'];
@@ -3168,7 +3169,7 @@ function node_access_grants($op, $account = NULL) {
* 'node_access'; when this function returns TRUE, no node access joins are
* added to the query.
*
- * @param $account
+ * @param Drupal\user\User $account
* (optional) The user object for the user whose access is being checked. If
* omitted, the current user is used.
*
@@ -3178,7 +3179,7 @@ function node_access_grants($op, $account = NULL) {
* @see hook_node_grants()
* @see _node_query_node_access_alter()
*/
-function node_access_view_all_nodes($account = NULL) {
+function node_access_view_all_nodes(User $account = NULL) {
global $user;
if (!$account) {
$account = $user;
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index 5d557cc..1a9d8bd 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -8,12 +8,13 @@
*/
use Drupal\node\Node;
+use Drupal\user\User;
use Drupal\entity\EntityFieldQuery;
/**
* Implements hook_node_grants().
*/
-function node_access_test_node_grants($account, $op) {
+function node_access_test_node_grants(User $account, $op) {
$grants = array();
// First grant a grant to the author for own content.
$grants['node_access_test_author'] = array($account->uid);
diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module
index f541d10..6c5e504 100644
--- a/core/modules/node/tests/modules/node_test/node_test.module
+++ b/core/modules/node/tests/modules/node_test/node_test.module
@@ -7,6 +7,7 @@
*/
use Drupal\node\Node;
+use Drupal\user\User;
/**
* Implements hook_node_load().
@@ -54,7 +55,7 @@ function node_test_node_view(Node $node, $view_mode) {
/**
* Implements hook_node_grants().
*/
-function node_test_node_grants($account, $op) {
+function node_test_node_grants(User $account, $op) {
// Give everyone full grants so we don't break other node tests.
// Our node access tests asserts three realms of access.
// See testGrantAlter().
@@ -117,7 +118,7 @@ function node_test_node_access_records_alter(&$grants, Node $node) {
/**
* Implements hook_node_grants_alter().
*/
-function node_test_node_grants_alter(&$grants, $account, $op) {
+function node_test_node_grants_alter(&$grants, User $account, $op) {
// Return an empty array of grants to prove that we can alter by reference.
$grants = array();
}
diff --git a/core/modules/openid/openid.api.php b/core/modules/openid/openid.api.php
index bd286ff..899c296 100644
--- a/core/modules/openid/openid.api.php
+++ b/core/modules/openid/openid.api.php
@@ -15,10 +15,10 @@
*
* @param $request
* An associative array of request parameters.
- * @param $service
+ * @param Drupal\user\User $service
* A service array as returned by openid_discovery().
*/
-function hook_openid_request_alter(&$request, $service) {
+function hook_openid_request_alter(&$request, Drupal\user\User $service) {
if ($request['openid.mode'] == 'checkid_setup') {
$request['openid.identity'] = 'http://myname.myopenid.com/';
}
diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module
index 034c7c2..af68ac0 100644
--- a/core/modules/openid/openid.module
+++ b/core/modules/openid/openid.module
@@ -5,6 +5,8 @@
* Implement OpenID Relying Party support for Drupal
*/
+use Drupal\user\User;
+
/**
* Implements hook_menu().
*/
@@ -83,7 +85,7 @@ function openid_help($path, $arg) {
/**
* Implements hook_user_insert().
*/
-function openid_user_insert($account) {
+function openid_user_insert(User $account) {
if (!empty($account->openid_claimed_id)) {
// The user has registered after trying to log in via OpenID.
if (variable_get('user_email_verification', TRUE)) {
@@ -100,7 +102,7 @@ function openid_user_insert($account) {
*
* Save openid_identifier to visitor cookie.
*/
-function openid_user_login(&$edit, $account) {
+function openid_user_login(&$edit, User $account) {
if (isset($_SESSION['openid'])) {
// The user has logged in via OpenID.
user_cookie_save(array_intersect_key($_SESSION['openid']['user_login_values'], array_flip(array('openid_identifier'))));
@@ -113,7 +115,7 @@ function openid_user_login(&$edit, $account) {
*
* Delete any openid_identifier in visitor cookie.
*/
-function openid_user_logout($account) {
+function openid_user_logout(User $account) {
if (isset($_COOKIE['Drupal_visitor_openid_identifier'])) {
user_cookie_delete('openid_identifier');
}
diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module
index 89f3ddf..17009a3 100644
--- a/core/modules/openid/tests/openid_test.module
+++ b/core/modules/openid/tests/openid_test.module
@@ -20,6 +20,7 @@
* key is used for verifying the signed messages from the provider.
*/
+use Drupal\user\User;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -362,7 +363,7 @@ function openid_test_openid_request_alter(&$request, $service) {
/**
* Implements hook_openid_response().
*/
-function openid_test_openid_response($response, $account) {
+function openid_test_openid_response($response, User $account) {
variable_set('openid_test_hook_openid_response_response', $response);
variable_set('openid_test_hook_openid_response_account', $account ? $account : FALSE);
}
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index acfcc2c..f93ae20 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -5,6 +5,7 @@
* Displays the Drupal administration interface in an overlay.
*/
+use Drupal\user\User;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -105,7 +106,7 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) {
/**
* Implements hook_user_presave().
*/
-function overlay_user_presave($account) {
+function overlay_user_presave(User $account) {
if (isset($account->overlay)) {
$account->data['overlay'] = $account->overlay;
}
diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module
index 259ff14..a478e23 100644
--- a/core/modules/poll/poll.module
+++ b/core/modules/poll/poll.module
@@ -7,6 +7,7 @@
*/
use Drupal\node\Node;
+use Drupal\user\User;
/**
* Implements hook_help().
@@ -961,7 +962,7 @@ function poll_cancel($form, &$form_state) {
/**
* Implements hook_user_cancel().
*/
-function poll_user_cancel($edit, $account, $method) {
+function poll_user_cancel($edit, User $account, $method) {
switch ($method) {
case 'user_cancel_reassign':
db_update('poll_vote')
@@ -975,7 +976,7 @@ function poll_user_cancel($edit, $account, $method) {
/**
* Implements hook_user_predelete().
*/
-function poll_user_predelete($account) {
+function poll_user_predelete(User $account) {
db_delete('poll_vote')
->condition('uid', $account->uid)
->execute();
diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc
index 3345c59..4fe6ab4 100644
--- a/core/modules/shortcut/shortcut.admin.inc
+++ b/core/modules/shortcut/shortcut.admin.inc
@@ -5,6 +5,7 @@
* Administrative page callbacks for the shortcut module.
*/
+use Drupal\user\User;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
@@ -14,7 +15,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
* An associative array containing the structure of the form.
* @param $form_state
* An associative array containing the current state of the form.
- * @param $account
+ * @param Drupal\user\User $account
* (optional) The user account whose shortcuts will be switched. Defaults to
* the current logged-in user.
*
@@ -25,7 +26,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
* @see shortcut_set_switch_validate()
* @see shortcut_set_switch_submit()
*/
-function shortcut_set_switch($form, &$form_state, $account = NULL) {
+function shortcut_set_switch($form, &$form_state, User $account = NULL) {
global $user;
if (!isset($account)) {
$account = $user;
diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php
index 717a7c9..2a185e1 100644
--- a/core/modules/shortcut/shortcut.api.php
+++ b/core/modules/shortcut/shortcut.api.php
@@ -24,13 +24,13 @@
* modules implement this hook, the last (i.e., highest weighted) module which
* returns a valid shortcut set name will prevail.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user account whose default shortcut set is being requested.
* @return
* The name of the shortcut set that this module recommends for that user, if
* there is one.
*/
-function hook_shortcut_default_set($account) {
+function hook_shortcut_default_set(Drupal\user\User $account) {
// Use a special set of default shortcuts for administrators only.
if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
return variable_get('mymodule_shortcut_admin_default_set');
diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module
index 27eb8c2..89b68bd 100644
--- a/core/modules/shortcut/shortcut.module
+++ b/core/modules/shortcut/shortcut.module
@@ -5,6 +5,8 @@
* Allows users to manage customizable lists of shortcut links.
*/
+use Drupal\user\User;
+
/**
* The name of the default shortcut set.
*
@@ -256,7 +258,7 @@ function shortcut_set_delete_access($shortcut_set) {
/**
* Access callback for switching the shortcut set assigned to a user account.
*
- * @param object $account
+ * @param Drupal\user\User $account
* (optional) The user account whose shortcuts will be switched. If not set,
* permissions will be checked for switching the logged-in user's own
* shortcut set.
@@ -265,7 +267,7 @@ function shortcut_set_delete_access($shortcut_set) {
* TRUE if the current user has access to switch the shortcut set of the
* provided account, FALSE otherwise.
*/
-function shortcut_set_switch_access($account = NULL) {
+function shortcut_set_switch_access(User $account = NULL) {
global $user;
if (user_access('administer shortcuts')) {
@@ -435,10 +437,10 @@ function shortcut_set_reset_link_weights(&$shortcut_set) {
*
* @param $shortcut_set
* An object representing the shortcut set.
- * @param $account
+ * @param Drupal\user\User $account
* A user account that will be assigned to use the set.
*/
-function shortcut_set_assign_user($shortcut_set, $account) {
+function shortcut_set_assign_user($shortcut_set, User $account) {
db_merge('shortcut_set_users')
->key(array('uid' => $account->uid))
->fields(array('set_name' => $shortcut_set->set_name))
@@ -451,7 +453,7 @@ function shortcut_set_assign_user($shortcut_set, $account) {
*
* The user will go back to using whatever default set applies.
*
- * @param $account
+ * @param Drupal\user\User $account
* A user account that will be removed from the shortcut set assignment.
*
* @return
@@ -459,7 +461,7 @@ function shortcut_set_assign_user($shortcut_set, $account) {
* successfully removed from it. FALSE if the user was already not assigned
* to any set.
*/
-function shortcut_set_unassign_user($account) {
+function shortcut_set_unassign_user(User $account) {
$deleted = db_delete('shortcut_set_users')
->condition('uid', $account->uid)
->execute();
@@ -469,7 +471,7 @@ function shortcut_set_unassign_user($account) {
/**
* Returns the current displayed shortcut set for the provided user account.
*
- * @param $account
+ * @param Drupal\user\User $account
* (optional) The user account whose shortcuts will be returned. Defaults to
* the currently logged-in user.
*
@@ -478,7 +480,7 @@ function shortcut_set_unassign_user($account) {
* current user. If the user does not have an explicit shortcut set defined,
* the default set is returned.
*/
-function shortcut_current_displayed_set($account = NULL) {
+function shortcut_current_displayed_set(Drupal\user\User $account = NULL) {
$shortcut_sets = &drupal_static(__FUNCTION__, array());
global $user;
if (!isset($account)) {
@@ -510,7 +512,7 @@ function shortcut_current_displayed_set($account = NULL) {
/**
* Returns the default shortcut set for a given user account.
*
- * @param object $account
+ * @param $account
* (optional) The user account whose default shortcut set will be returned.
* If not provided, the function will return the currently logged-in user's
* default shortcut set.
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 35f625a..b9cd00c 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -6,6 +6,7 @@
*/
use Drupal\node\Node;
+use Drupal\user\User;
/**
* Implements hook_help().
@@ -206,7 +207,7 @@ function statistics_menu() {
/**
* Implements hook_user_cancel().
*/
-function statistics_user_cancel($edit, $account, $method) {
+function statistics_user_cancel($edit, User $account, $method) {
switch ($method) {
case 'user_cancel_reassign':
db_update('accesslog')
@@ -220,7 +221,7 @@ function statistics_user_cancel($edit, $account, $method) {
/**
* Implements hook_user_predelete().
*/
-function statistics_user_predelete($account) {
+function statistics_user_predelete(User $account) {
db_delete('accesslog')
->condition('uid', $account->uid)
->execute();
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 4cf5780..1e2c547 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -5,6 +5,7 @@
* Configuration system that lets administrators modify the workings of the site.
*/
+use Drupal\user\User;
use Drupal\Core\Utility\ModuleInfo;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
@@ -2232,7 +2233,7 @@ function system_form_user_register_form_alter(&$form, &$form_state) {
/**
* Implements hook_user_presave().
*/
-function system_user_presave($account) {
+function system_user_presave(User $account) {
if (variable_get('configurable_timezones', 1) && empty($account->timezone) && !variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT)) {
$account->timezone = variable_get('date_default_timezone', '');
}
@@ -2241,7 +2242,7 @@ function system_user_presave($account) {
/**
* Implements hook_user_login().
*/
-function system_user_login(&$edit, $account) {
+function system_user_login(&$edit, User $account) {
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
diff --git a/core/modules/system/tests/modules/session_test/session_test.module b/core/modules/system/tests/modules/session_test/session_test.module
index 689ff09..c1fe030 100644
--- a/core/modules/system/tests/modules/session_test/session_test.module
+++ b/core/modules/system/tests/modules/session_test/session_test.module
@@ -1,5 +1,7 @@
name == 'session_test_user') {
// Exit so we can verify that the session was regenerated
// before hook_user() was called.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
index b5e8882..12212dc 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\user\User;
use Drupal\simpletest\WebTestBase;
/**
@@ -124,13 +125,13 @@ class UserLoginTest extends WebTestBase {
/**
* Make an unsuccessful login attempt.
*
- * @param $account
- * A user object with name and pass_raw attributes for the login attempt.
+ * @param Drupal\user\User $account
+ * A user entity with name and pass_raw attributes for the login attempt.
* @param $flood_trigger
* Whether or not to expect that the flood control mechanism will be
* triggered.
*/
- function assertFailedLogin($account, $flood_trigger = NULL) {
+ function assertFailedLogin(User $account, $flood_trigger = NULL) {
$edit = array(
'name' => $account->name,
'pass' => $account->pass_raw,
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
index eaabdd2..504a4e6 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
@@ -83,7 +83,7 @@ class UserRolesAssignmentTest extends WebTestBase {
/**
* Check role on user object.
*
- * @param object $account
+ * @param Drupal\user\User $account
* The user account to check.
* @param string $rid
* The role ID to search for.
@@ -91,7 +91,7 @@ class UserRolesAssignmentTest extends WebTestBase {
* (optional) Whether to assert that $rid exists (TRUE) or not (FALSE).
* Defaults to TRUE.
*/
- private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
+ private function userLoadAndCheckRoleAssigned(User $account, $rid, $is_assigned = TRUE) {
$account = user_load($account->uid, TRUE);
if ($is_assigned) {
$this->assertTrue(array_key_exists($rid, $account->roles), t('The role is present in the user object.'));
diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php
index 98b9887..1cf9bd6 100644
--- a/core/modules/user/user.api.php
+++ b/core/modules/user/user.api.php
@@ -42,13 +42,13 @@ function hook_user_load($users) {
* Modules should additionally implement hook_user_cancel() to process stored
* user data for other account cancellation methods.
*
- * @param $account
+ * @param Drupal\user\User $account
* The account that is about to be deleted.
*
* @see hook_user_delete()
* @see user_delete_multiple()
*/
-function hook_user_predelete($account) {
+function hook_user_predelete(Drupal\user\User $account) {
db_delete('mytable')
->condition('uid', $account->uid)
->execute();
@@ -63,13 +63,13 @@ function hook_user_predelete($account) {
* Modules should additionally implement hook_user_cancel() to process stored
* user data for other account cancellation methods.
*
- * @param $account
+ * @param Drupal\user\User $account
* The account that has been deleted.
*
* @see hook_user_predelete()
* @see user_delete_multiple()
*/
-function hook_user_delete($account) {
+function hook_user_delete(Drupal\user\User $account) {
drupal_set_message(t('User: @name has been deleted.', array('@name' => $account->name)));
}
@@ -91,7 +91,7 @@ function hook_user_delete($account) {
*
* @param $edit
* The array of form values submitted by the user.
- * @param $account
+ * @param Drupal\user\User $account
* The user object on which the operation is being performed.
* @param $method
* The account cancellation method.
@@ -99,7 +99,7 @@ function hook_user_delete($account) {
* @see user_cancel_methods()
* @see hook_user_cancel_methods_alter()
*/
-function hook_user_cancel($edit, $account, $method) {
+function hook_user_cancel($edit, Drupal\user\User $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
// Unpublish nodes (current revisions).
@@ -182,12 +182,12 @@ function hook_user_cancel_methods_alter(&$methods) {
* @param $name
* The string that user_format_name() will return.
*
- * @param $account
+ * @param Drupal\user\User $account
* The account object passed to user_format_name().
*
* @see user_format_name()
*/
-function hook_user_format_name_alter(&$name, $account) {
+function hook_user_format_name_alter(&$name, Drupal\user\User $account) {
// Display the user's uid instead of name.
if (isset($account->uid)) {
$name = t('User !uid', array('!uid' => $account->uid));
@@ -238,13 +238,13 @@ function hook_user_operations() {
* add their properties to $account->data in order to have their data serialized
* on save.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user account object.
*
* @see hook_user_insert()
* @see hook_user_update()
*/
-function hook_user_presave($account) {
+function hook_user_presave(Drupal\user\User $account) {
// Make sure that our form value 'mymodule_foo' is stored as
// 'mymodule_bar' in the 'data' (serialized) column.
if (isset($account->mymodule_foo)) {
@@ -255,13 +255,13 @@ function hook_user_presave($account) {
/**
* Respond to creation of a new user account.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user account object.
*
* @see hook_user_presave()
* @see hook_user_update()
*/
-function hook_user_insert($account) {
+function hook_user_insert(Drupal\user\User $account) {
db_insert('user_changes')
->fields(array(
'uid' => $account->uid,
@@ -273,13 +273,13 @@ function hook_user_insert($account) {
/**
* Respond to updates to a user account.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user account object.
*
* @see hook_user_presave()
* @see hook_user_insert()
*/
-function hook_user_update($account) {
+function hook_user_update(Drupal\user\User $account) {
db_insert('user_changes')
->fields(array(
'uid' => $account->uid,
@@ -293,10 +293,10 @@ function hook_user_update($account) {
*
* @param $edit
* The array of form values submitted by the user.
- * @param $account
+ * @param Drupal\user\User $account
* The user object on which the operation was just performed.
*/
-function hook_user_login(&$edit, $account) {
+function hook_user_login(&$edit, Drupal\user\User $account) {
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
drupal_set_message(t('Configure your account time zone setting.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone')))));
@@ -306,10 +306,10 @@ function hook_user_login(&$edit, $account) {
/**
* The user just logged out.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user object on which the operation was just performed.
*/
-function hook_user_logout($account) {
+function hook_user_logout(Drupal\user\User $account) {
db_insert('logouts')
->fields(array(
'uid' => $account->uid,
@@ -324,7 +324,7 @@ function hook_user_logout($account) {
* The module should format its custom additions for display and add them to the
* $account->content array.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user object on which the operation is being performed.
* @param $view_mode
* View mode, e.g. 'full'.
@@ -334,7 +334,7 @@ function hook_user_logout($account) {
* @see hook_user_view_alter()
* @see hook_entity_view()
*/
-function hook_user_view($account, $view_mode, $langcode) {
+function hook_user_view(Drupal\user\User $account, $view_mode, $langcode) {
$account->content['user_picture'] = array(
'#markup' => theme('user_picture', array('account' => $account)),
'#weight' => -10,
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 1f72aa6..167521b 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -1,6 +1,7 @@
content['user_picture'] = array(
'#markup' => theme('user_picture', array('account' => $account)),
'#weight' => -10,
@@ -1213,7 +1214,7 @@ function user_preprocess_block(&$variables) {
*
* @see hook_user_format_name_alter()
*
- * @param $account
+ * @param Drupal\user\User $account
* The account object for the user whose name is to be formatted.
*
* @return
@@ -1426,10 +1427,10 @@ function user_register_access() {
/**
* User view access callback.
*
- * @param $account
+ * @param Drupal\user\User $account
* Can either be a full user object or a $uid.
*/
-function user_view_access($account) {
+function user_view_access(User $account) {
$uid = is_object($account) ? $account->uid : (int) $account;
// Never allow access to view the anonymous user account.
@@ -1452,7 +1453,7 @@ function user_view_access($account) {
/**
* Access callback for user account editing.
*/
-function user_edit_access($account) {
+function user_edit_access(User $account) {
return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0;
}
@@ -1462,7 +1463,7 @@ function user_edit_access($account) {
* Limit access to users with the 'cancel account' permission or administrative
* users, and prevent the anonymous user from cancelling the account.
*/
-function user_cancel_access($account) {
+function user_cancel_access(User $account) {
return ((($GLOBALS['user']->uid == $account->uid) && user_access('cancel account')) || user_access('administer users')) && $account->uid > 0;
}
@@ -1833,15 +1834,15 @@ function user_get_authmaps($authname = NULL) {
* Save mappings of which external authentication module(s) authenticated
* a user. Maps external usernames to user ids in the users table.
*
- * @param $account
- * A user object.
+ * @param Drupal\user\User $account
+ * A user entity.
* @param $authmaps
* An associative array with a compound key and the username as the value.
* The key is made up of 'authname_' plus the name of the external authentication
* module.
* @see user_external_login_register()
*/
-function user_set_authmaps($account, $authmaps) {
+function user_set_authmaps(User $account, $authmaps) {
foreach ($authmaps as $key => $value) {
$module = explode('_', $key, 2);
if ($value) {
@@ -2116,14 +2117,14 @@ function user_external_login_register($name, $module) {
/**
* Generates a unique URL for a user to login and reset their password.
*
- * @param object $account
- * An object containing the user account.
+ * @param Drupal\user\User $account
+ * An entity containing the user account.
*
* @return
* A unique URL that provides a one-time log in for the user, from which
* they can change their password.
*/
-function user_pass_reset_url($account) {
+function user_pass_reset_url(User $account) {
$timestamp = REQUEST_TIME;
return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
}
@@ -2131,8 +2132,8 @@ function user_pass_reset_url($account) {
/**
* Generates a URL to confirm an account cancellation request.
*
- * @param object $account
- * The user account object, which must contain at least the following
+ * @param Drupal\user\User $account
+ * The user account entity, which must contain at least the following
* properties:
* - uid: The user uid number.
* - pass: The hashed user password string.
@@ -2145,7 +2146,7 @@ function user_pass_reset_url($account) {
* @see user_mail_tokens()
* @see user_cancel_confirm()
*/
-function user_cancel_url($account) {
+function user_cancel_url(User $account) {
$timestamp = REQUEST_TIME;
return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
}
@@ -2238,7 +2239,7 @@ function user_cancel($edit, $uid, $method) {
*
* @see user_cancel()
*/
-function _user_cancel($edit, $account, $method) {
+function _user_cancel($edit, User $account, $method) {
global $user;
switch ($method) {
@@ -2361,8 +2362,8 @@ function user_view_page($account) {
* To theme user profiles, copy modules/user/user-profile.tpl.php
* to your theme directory, and edit it as instructed in that file's comments.
*
- * @param $account
- * A user object.
+ * @param Drupal\user\User $account
+ * A user entity.
* @param $view_mode
* View mode, e.g. 'full'.
* @param $langcode
@@ -2372,7 +2373,7 @@ function user_view_page($account) {
* @return
* An array as expected by drupal_render().
*/
-function user_view($account, $view_mode = 'full', $langcode = NULL) {
+function user_view(User $account, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
}
@@ -2400,15 +2401,15 @@ function user_view($account, $view_mode = 'full', $langcode = NULL) {
/**
* Builds a structured array representing the profile content.
*
- * @param $account
- * A user object.
+ * @param Drupal\user\User $account
+ * A user entity.
* @param $view_mode
* View mode, e.g. 'full'.
* @param $langcode
* (optional) A language code to use for rendering. Defaults to the global
* content language of the current request.
*/
-function user_build_content($account, $view_mode = 'full', $langcode = NULL) {
+function user_build_content(User $account, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
}
@@ -3257,13 +3258,13 @@ function theme_user_signature($variables) {
* choose a preferred language, or is the anonymous user, the $default
* value, or if it is not set, the site default language will be returned.
*
- * @param $account
+ * @param Drupal\user\User $account
* User account to look up language for.
* @param $default
* Optional default language object to return if the account
* has no valid language.
*/
-function user_preferred_language($account, $default = NULL) {
+function user_preferred_language(User $account, $default = NULL) {
$language_list = language_list();
if (!empty($account->preferred_langcode) && isset($language_list[$account->preferred_langcode])) {
return $language_list[$account->preferred_langcode];
@@ -3293,7 +3294,7 @@ function user_preferred_language($account, $default = NULL) {
* - 'cancel_confirm': Account cancellation request.
* - 'status_canceled': Account canceled.
*
- * @param $account
+ * @param Drupal\user\User $account
* The user object of the account being notified. Must contain at
* least the fields 'uid', 'name', and 'mail'.
* @param $language
@@ -3303,7 +3304,7 @@ function user_preferred_language($account, $default = NULL) {
* The return value from drupal_mail_system()->mail(), if ends up being
* called.
*/
-function _user_mail_notify($op, $account, $language = NULL) {
+function _user_mail_notify($op, User $account, $language = NULL) {
// By default, we always notify except for canceled and blocked.
$default_notify = ($op != 'status_canceled' && $op != 'status_blocked');
$notify = variable_get('user_mail_' . $op . '_notify', $default_notify);