diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e8350cf..d2126e3 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2848,7 +2848,7 @@ function drupal_classloader_register($name, $path) { * * Example: * @code - * function user_access($string, $account = NULL) { + * function user_access($string, User $account = NULL) { * // Use the advanced drupal_static() pattern, since this is called very often. * static $drupal_static_fast; * if (!isset($drupal_static_fast)) { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 45af84a..e35917e 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1240,7 +1240,7 @@ function comment_node_search_result(EntityInterface $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 = entity_load_multiple_by_properties('comment', array('uid' => $account->id())); @@ -1263,8 +1263,65 @@ 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->id()))->fetchCol(); + comment_delete_multiple($cids); +} + +/** + * Determines whether the current user has access to a particular comment. + * + * Authenticated users can edit their comments as long they have not been + * replied to. This prevents people from changing or revising their statements + * based on the replies to their posts. + * + * @param $op + * The operation that is to be performed on the comment. Only 'edit' is + * recognized now. + * @param Drupal\comment\Comment $comment + * The comment object. + * + * @return + * TRUE if the current user has acces to the comment, FALSE otherwise. + */ +function comment_access($op, Comment $comment) { + global $user; + + if ($op == 'edit') { + return ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && user_access('edit own comments')) || user_access('administer comments'); + } +} + +/** + * Accepts a submission of new or changed comment content. + * + * @param Drupal\comment\Comment $comment + * A comment object. + */ +function comment_save(Comment $comment) { + $comment->save(); +} + +/** + * Deletes a comment and all its replies. + * + * @param $cid + * The ID of the comment to delete. + */ +function comment_delete($cid) { + comment_delete_multiple(array($cid)); +} + +/** + * Deletes comments and all their replies. + * + * @param $cids + * The IDs of the comments to delete. + * + * @see hook_comment_predelete() + * @see hook_comment_delete() + */ +function comment_delete_multiple($cids) { entity_delete_multiple('comment', $cids); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 673a500..9ec069e 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -118,7 +118,7 @@ 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() diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php index e974ec6..59c11c0 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; /** @@ -209,13 +210,13 @@ function testPersonalContactFlood() { /** * 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 * (optional) An array with the form fields being used. Defaults to an empty * array. */ - 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 7f5dec5..1c5c8b0 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -587,13 +587,13 @@ function hook_field_purge_instance($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, \Drupal\field\FieldInterface $field, $entity_type, $entity, $account) { +function hook_field_access($op, \Drupal\field\FieldInterface $field, $entity_type, $entity, Drupal\user\User $account) { if ($field['field_name'] == 'field_of_interest' && $op == 'edit') { return $account->hasPermission('edit field of interest'); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index cc7ad90..26e7a20 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -736,13 +736,13 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options * 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; FALSE if the operation is denied. */ -function field_access($op, FieldInterface $field, $entity_type, $entity = NULL, $account = NULL) { +function field_access($op, FieldInterface $field, $entity_type, $entity = NULL, Drupal\user\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 3ac75fa..75b3d01 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 @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\field\FieldException; use Drupal\field\FieldInterface; +use Drupal\user\User; /** * Implements hook_field_info(). @@ -201,7 +202,7 @@ function field_test_default_value(EntityInterface $entity, $field, $instance) { /** * Implements hook_field_access(). */ -function field_test_field_access($op, FieldInterface $field, $entity_type, $entity, $account) { +function field_test_field_access($op, FieldInterface $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 59d27b5..ad3ef71 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -163,7 +163,7 @@ * 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'. @@ -178,7 +178,7 @@ * @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); } @@ -353,7 +353,7 @@ function hook_node_access_records_alter(&$grants, Drupal\Core\Entity\EntityInter * * @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'. @@ -363,7 +363,7 @@ function hook_node_access_records_alter(&$grants, Drupal\Core\Entity\EntityInter * @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 @@ -548,7 +548,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. @@ -560,7 +560,7 @@ function hook_node_load($nodes, $types) { * * @ingroup node_access */ -function hook_node_access(\Drupal\node\NodeInterface $node, $op, $account, $langcode) { +function hook_node_access(\Drupal\node\NodeInterface $node, $op, Drupal\user\User $account, $langcode) { $type = is_string($node) ? $node : $node->getType(); $configured_types = node_permissions_get_configured_types(); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 8c6eddb..09e948b 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -858,7 +858,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_field_data', 'n') @@ -916,7 +916,7 @@ function theme_node_search_admin($variables) { * The node to check. * @param $op * (optional) The specific operation being checked. Defaults to 'view.' - * @param object $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. * Defaults to NULL. @@ -930,7 +930,7 @@ function theme_node_search_admin($variables) { * * @see node_menu() */ -function _node_revision_access(EntityInterface $node, $op = 'view', $account = NULL, $langcode = NULL) { +function _node_revision_access(EntityInterface $node, $op = 'view', User $account = NULL, $langcode = NULL) { return Drupal::service('access_check.node.revision')->checkAccess($node, $op, $account, $langcode); } @@ -1681,7 +1681,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 = $node->bundle(); $configured_types = node_permissions_get_configured_types(); @@ -1786,7 +1786,7 @@ function node_permissions_get_configured_types() { * * @param $op * The operation that the user is trying to perform. - * @param $account + * @param Drupal\user\User $account * (optional) The user object for the user performing the operation. If * omitted, the current user is used. Defaults to NULL. * @@ -1794,7 +1794,7 @@ function node_permissions_get_configured_types() { * 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']; @@ -1820,7 +1820,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. Defaults to NULL. * @@ -1830,7 +1830,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 abc18c6..5fd7ab0 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 @@ -15,7 +15,7 @@ /** * 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->id()); 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 835f82c..5bb1f66 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -58,7 +58,7 @@ function node_test_node_view(EntityInterface $node, EntityDisplay $display, $vie /** * 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(). @@ -121,7 +121,7 @@ function node_test_node_access_records_alter(&$grants, NodeInterface $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/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php index 44e147c..92169fa 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -226,7 +226,7 @@ public function testCommentReplyOfRdfaMarkup() { * * @param $comment * Comment object. - * @param $account + * @param Drupal\user\User $account * An array containing information about an anonymous user. */ function _testBasicCommentRdfaMarkup($graph, $comment, $account = array()) { diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index c230fb5..8d0477d 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -6,6 +6,7 @@ */ use Symfony\Component\HttpFoundation\RedirectResponse; +use Drupal\user\User; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; /** @@ -15,7 +16,7 @@ * 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. * @@ -26,7 +27,7 @@ * @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) { $user = Drupal::currentUser(); if (!isset($account)) { diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php index 27eecf3..14d944b 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(Drupal::config('user.settings')->get('admin_role'), $account->getRoles())) { return 'admin-shortcuts'; diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 27f11d7..882d5d4 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -186,7 +186,7 @@ function shortcut_set_edit_access($shortcut_set = NULL) { /** * 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. @@ -195,7 +195,7 @@ function shortcut_set_edit_access($shortcut_set = NULL) { * 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(Drupal\user\User $account = NULL) { $user = Drupal::currentUser(); if ($user->hasPermission('administer shortcuts')) { @@ -282,10 +282,10 @@ function shortcut_set_reset_link_weights(&$shortcut_set) { * * @param $shortcut_set Drupal\shortcut\Entity\Shortcut * 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, Drupal\user\User $account) { Drupal::entityManager() ->getStorageController('shortcut_set') ->assignUser($shortcut_set, $account); @@ -296,7 +296,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 @@ -304,7 +304,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(Drupal\user\User $account) { return (bool) Drupal::entityManager() ->getStorageController('shortcut_set') ->unassignUser($account); @@ -313,7 +313,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. * @@ -322,7 +322,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)) { @@ -352,7 +352,7 @@ function shortcut_current_displayed_set($account = NULL) { /** * Returns the default shortcut set for a given user account. * - * @param object $account + * @param Drupal\user\User $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. @@ -360,7 +360,7 @@ function shortcut_current_displayed_set($account = NULL) { * @return * An object representing the default shortcut set. */ -function shortcut_default_set($account = NULL) { +function shortcut_default_set(User $account = NULL) { global $user; if (!isset($account)) { $account = $user; diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php index e8abd34..cafa168 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php @@ -24,7 +24,7 @@ class StatisticsAdminTest extends WebTestBase { /** * A user that has permission to administer statistics. * - * @var object|FALSE + * @var \Drupal\user\User|false * * A fully loaded user object, or FALSE if user creation failed. */ diff --git a/core/modules/system/system.module b/core/modules/system/system.module index d31cd3c2..86dcd38 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -8,6 +8,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\Language; +use Drupal\user\User; use Drupal\Core\Utility\ModuleInfo; use Drupal\user\UserInterface; use Symfony\Component\HttpFoundation\JsonResponse; @@ -2241,7 +2242,7 @@ function system_user_presave(UserInterface $account) { /** * Implements hook_user_login(). */ -function system_user_login($account) { +function system_user_login(User $account) { $config = Drupal::config('system.date'); // If the user has a NULL time zone, notify them to set a time zone. if (!$account->getTimezone() && $config->get('timezone.user.configurable') && $config->get('timezone.user.warn')) { 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 c618bab..2be7b70 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 @@ extend('Drupal\Core\Database\Query\PagerSelectExtender') diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLoginTest.php index 1b75930..e76cf7f 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; use Drupal\Core\Password\PhpassHashedPassword; @@ -134,13 +135,13 @@ function testPasswordRehashOnLogin() { /** * 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->getUsername(), '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 b9cd7f8..79399d7 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 @@ function testCreateUserWithRole() { /** * 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 @@ function testCreateUserWithRole() { * (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(Drupal\user\User $account, $rid, $is_assigned = TRUE) { $account = user_load($account->id(), TRUE); if ($is_assigned) { $this->assertTrue(array_search($rid, $account->getRoles()), '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 b7f8b8c..94214a1 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -56,13 +56,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->id()) ->execute(); @@ -77,13 +77,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->getUsername()))); } @@ -105,7 +105,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. @@ -113,7 +113,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). @@ -192,12 +192,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 ($account->id()) { $name = t('User !uid', array('!uid' => $account->id())); @@ -215,7 +215,7 @@ function hook_user_format_name_alter(&$name, $account) { * @see hook_user_insert() * @see hook_user_update() */ -function hook_user_presave($account) { +function hook_user_presave(Drupal\user\User $account) { // Ensure that our value is an array. if (isset($account->mymodule_foo)) { $account->mymodule_foo = (array) $account->mymodule_foo; @@ -240,7 +240,7 @@ function hook_user_presave($account) { * @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->id(), @@ -267,7 +267,7 @@ function hook_user_insert($account) { * @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->id(), @@ -293,10 +293,10 @@ function hook_user_login($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->id(), diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 7037793..b626169 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -290,8 +290,6 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) { * @return object * A fully-loaded user object upon successful user load, or NULL if the user * cannot be loaded. - * - * @see user_load_multiple() */ function user_load($uid, $reset = FALSE) { return entity_load('user', $uid, $reset); @@ -302,7 +300,7 @@ function user_load($uid, $reset = FALSE) { * * @param string $mail * String with the account's e-mail address. - * @return object|bool + * @return Drupal\user\User|false * A fully-loaded $user object upon successful user load or FALSE if user * cannot be loaded. * @@ -318,7 +316,7 @@ function user_load_by_mail($mail) { * * @param string $name * String with the account's user name. - * @return object|bool + * @return Drupal\user\User|false * A fully-loaded $user object upon successful user load or FALSE if user * cannot be loaded. * @@ -1108,7 +1106,7 @@ function user_user_logout($account) { * 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, $options = array()) { +function user_pass_reset_url(User $account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); $url_options = array('absolute' => TRUE, 'language' => language_load($langcode)); @@ -1118,7 +1116,7 @@ function user_pass_reset_url($account, $options = array()) { /** * Generates a URL to confirm an account cancellation request. * - * @param object $account + * @param Drupal\user\User $account * The user account object, which must contain at least the following * properties: * - uid: The user ID number. @@ -1136,7 +1134,7 @@ function user_pass_reset_url($account, $options = array()) { * @see user_mail_tokens() * @see user_cancel_confirm() */ -function user_cancel_url($account, $options = array()) { +function user_cancel_url(User $account, $options = array()) { $timestamp = REQUEST_TIME; $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); $url_options = array('absolute' => TRUE, 'language' => language_load($langcode)); @@ -1239,7 +1237,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) { @@ -1395,7 +1393,7 @@ function user_view_page($account) { * To theme user profiles, copy modules/user/user.tpl.php * to your theme directory, and edit it as instructed in that file's comments. * - * @param $account + * @param Drupal\user\User $account * A user object. * @param $view_mode * View mode, e.g. 'full'. @@ -1406,7 +1404,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(Drupal\user\User $account, $view_mode = 'full', $langcode = NULL) { return entity_view($account, $view_mode, $langcode); } @@ -1749,7 +1747,7 @@ function theme_user_signature($variables) { * - '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 $langcode @@ -1760,7 +1758,7 @@ function theme_user_signature($variables) { * The return value from drupal_mail_system()->mail(), if ends up being * called. */ -function _user_mail_notify($op, $account, $langcode = NULL) { +function _user_mail_notify($op, Drupal\user\User $account, $langcode = NULL) { // By default, we always notify except for canceled and blocked. $notify = Drupal::config('user.settings')->get('notify.' . $op); if ($notify || ($op != 'status_canceled' && $op != 'status_blocked')) {