Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21namespace MediaWiki\User;
22
23use MediaWiki\DAO\WikiAwareEntity;
24
25/**
26 * Interface for objects representing user identity.
27 *
28 * This represents the identity of a user in the context of page revisions and log entries.
29 *
30 * @note Starting MediaWiki 1.37, UserIdentity objects should no longer expose an actor ID.
31 * The actor ID is considered a storage layer optimization and should not be exposed to
32 * and used by application logic. Storage layer code should use ActorNormalization to
33 * get an actor ID for a UserIdentity.
34 *
35 * @since 1.31
36 * @ingroup User
37 */
38interface UserIdentity extends WikiAwareEntity {
39
40    /**
41     * @since 1.31
42     *
43     * @param string|false $wikiId The wiki ID expected by the caller
44     * @return int The user ID. May be 0 for anonymous users or for users with no local account.
45     *
46     */
47    public function getId( $wikiId = self::LOCAL ): int;
48
49    /**
50     * @since 1.31
51     *
52     * @return string The user's logical name. May be an IPv4 or IPv6 address for anonymous users.
53     */
54    public function getName(): string;
55
56    /**
57     * @since 1.32
58     *
59     * @param UserIdentity|null $user
60     * @return bool
61     */
62    public function equals( ?UserIdentity $user ): bool;
63
64    /**
65     * This must be equivalent to getId() != 0 and is provided for code readability. There is no
66     * equivalent utility for checking whether a user is temporary, since that would introduce a
67     * service dependency. Use UserIdentityUtils::isTemp (or UserNameUtils::isTemp) instead.
68     *
69     * @since 1.34
70     *
71     * @return bool True if user is registered on this wiki, i.e., has a user ID. False if user is
72     *   anonymous or has no local account (which can happen when importing).
73     */
74    public function isRegistered(): bool;
75}