Skip to content

Commit e19d0da

Browse files
committed
Fixes yiisoft#823: consistent interface naming
1 parent e1061f1 commit e19d0da

17 files changed

+49
-49
lines changed

apps/advanced/common/models/User.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use yii\db\ActiveRecord;
55
use yii\helpers\Security;
6-
use yii\web\Identity;
6+
use yii\web\IdentityInterface;
77

88
/**
99
* Class User
@@ -20,7 +20,7 @@
2020
* @property integer $create_time
2121
* @property integer $update_time
2222
*/
23-
class User extends ActiveRecord implements Identity
23+
class User extends ActiveRecord implements IdentityInterface
2424
{
2525
/**
2626
* @var string the raw password. Used to collect password input and isn't saved in database
@@ -49,7 +49,7 @@ public function behaviors()
4949
* Finds an identity by the given ID.
5050
*
5151
* @param string|integer $id the ID to be looked for
52-
* @return Identity|null the identity object that matches the given ID.
52+
* @return IdentityInterface|null the identity object that matches the given ID.
5353
*/
5454
public static function findIdentity($id)
5555
{

apps/basic/models/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace app\models;
44

5-
class User extends \yii\base\Object implements \yii\web\Identity
5+
class User extends \yii\base\Object implements \yii\web\IdentityInterface
66
{
77
public $id;
88
public $username;

docs/guide/upgrade-from-v1.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,11 @@ This feature is especially useful if you are developing an application that supp
450450
different DBMS.
451451

452452

453-
User and Identity
454-
-----------------
453+
User and IdentityInterface
454+
--------------------------
455455

456456
The `CWebUser` class in 1.1 is now replaced by `\yii\Web\User`, and there is no more
457-
`CUserIdentity` class. Instead, you should implement the `Identity` interface which
457+
`CUserIdentity` class. Instead, you should implement the `IdentityInterface` which
458458
is much more straightforward to implement. The bootstrap application provides such an example.
459459

460460

framework/yii/classes.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
'yii\data\ActiveDataProvider' => YII_PATH . '/data/ActiveDataProvider.php',
8787
'yii\data\ArrayDataProvider' => YII_PATH . '/data/ArrayDataProvider.php',
8888
'yii\data\DataProvider' => YII_PATH . '/data/DataProvider.php',
89-
'yii\data\IDataProvider' => YII_PATH . '/data/IDataProvider.php',
89+
'yii\data\DataProviderInterface' => YII_PATH . '/data/DataProviderInterface.php',
9090
'yii\data\Pagination' => YII_PATH . '/data/Pagination.php',
9191
'yii\data\Sort' => YII_PATH . '/data/Sort.php',
9292
'yii\db\ActiveQuery' => YII_PATH . '/db/ActiveQuery.php',
@@ -204,15 +204,15 @@
204204
'yii\web\HeaderCollection' => YII_PATH . '/web/HeaderCollection.php',
205205
'yii\web\HttpCache' => YII_PATH . '/web/HttpCache.php',
206206
'yii\web\HttpException' => YII_PATH . '/web/HttpException.php',
207-
'yii\web\IAssetConverter' => YII_PATH . '/web/IAssetConverter.php',
208-
'yii\web\Identity' => YII_PATH . '/web/Identity.php',
207+
'yii\web\AssetConverterInterface' => YII_PATH . '/web/AssetConverterInterface.php',
208+
'yii\web\IdentityInterface' => YII_PATH . '/web/IdentityInterface.php',
209209
'yii\web\JqueryAsset' => YII_PATH . '/web/JqueryAsset.php',
210210
'yii\web\JsExpression' => YII_PATH . '/web/JsExpression.php',
211211
'yii\web\PageCache' => YII_PATH . '/web/PageCache.php',
212212
'yii\web\Request' => YII_PATH . '/web/Request.php',
213213
'yii\web\Response' => YII_PATH . '/web/Response.php',
214214
'yii\web\ResponseEvent' => YII_PATH . '/web/ResponseEvent.php',
215-
'yii\web\ResponseFormatter' => YII_PATH . '/web/ResponseFormatter.php',
215+
'yii\web\ResponseFormatterInterface' => YII_PATH . '/web/ResponseFormatterInterface.php',
216216
'yii\web\Session' => YII_PATH . '/web/Session.php',
217217
'yii\web\SessionIterator' => YII_PATH . '/web/SessionIterator.php',
218218
'yii\web\UploadedFile' => YII_PATH . '/web/UploadedFile.php',

framework/yii/data/DataProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* DataProvider is the base class of data provider classes.
1616
*
17-
* It implements the [[getPagination()]] and [[getSort()]] methods as specified by the [[IDataProvider]] interface.
17+
* It implements the [[getPagination()]] and [[getSort()]] methods as specified by the [[DataProviderInterface]].
1818
*
1919
* @property integer $count The number of data models in the current page. This property is read-only.
2020
* @property Pagination|boolean $pagination The pagination object. If this is false, it means the pagination
@@ -26,7 +26,7 @@
2626
* @author Qiang Xue <qiang.xue@gmail.com>
2727
* @since 2.0
2828
*/
29-
abstract class DataProvider extends Component implements IDataProvider
29+
abstract class DataProvider extends Component implements DataProviderInterface
3030
{
3131
/**
3232
* @var string an ID that uniquely identifies the data provider among all data providers.

framework/yii/data/IDataProvider.php framework/yii/data/DataProviderInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
namespace yii\data;
99

1010
/**
11-
* IDataProvider is the interface that must be implemented by data provider classes.
11+
* DataProviderInterface is the interface that must be implemented by data provider classes.
1212
*
1313
* Data providers are components that sort and paginate data, and provide them to widgets
1414
* such as [[GridView]], [[ListView]].
1515
*
1616
* @author Qiang Xue <qiang.xue@gmail.com>
1717
* @since 2.0
1818
*/
19-
interface IDataProvider
19+
interface DataProviderInterface
2020
{
2121
/**
2222
* Returns the number of data models in the current page.

framework/yii/web/AssetConverter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @author Qiang Xue <qiang.xue@gmail.com>
1717
* @since 2.0
1818
*/
19-
class AssetConverter extends Component implements IAssetConverter
19+
class AssetConverter extends Component implements AssetConverterInterface
2020
{
2121
/**
2222
* @var array the commands that are used to perform the asset conversion.

framework/yii/web/IAssetConverter.php framework/yii/web/AssetConverterInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace yii\web;
99

1010
/**
11-
* The IAssetConverter interface must be implemented by asset converter classes.
11+
* The AssetConverterInterface must be implemented by asset converter classes.
1212
*
1313
* @author Qiang Xue <qiang.xue@gmail.com>
1414
* @since 2.0
1515
*/
16-
interface IAssetConverter
16+
interface AssetConverterInterface
1717
{
1818
/**
1919
* Converts a given asset file into a CSS or JS file.

framework/yii/web/AssetManager.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* AssetManager manages asset bundles and asset publishing.
1818
*
19-
* @property IAssetConverter $converter The asset converter. Note that the type of this property differs in
19+
* @property AssetConverterInterface $converter The asset converter. Note that the type of this property differs in
2020
* getter and setter. See [[getConverter()]] and [[setConverter()]] for details.
2121
*
2222
* @author Qiang Xue <qiang.xue@gmail.com>
@@ -116,7 +116,7 @@ public function getBundle($name)
116116

117117
/**
118118
* Returns the asset converter.
119-
* @return IAssetConverter the asset converter.
119+
* @return AssetConverterInterface the asset converter.
120120
*/
121121
public function getConverter()
122122
{
@@ -130,8 +130,8 @@ public function getConverter()
130130

131131
/**
132132
* Sets the asset converter.
133-
* @param array|IAssetConverter $value the asset converter. This can be either
134-
* an object implementing the [[IAssetConverter]] interface, or a configuration
133+
* @param array|AssetConverterInterface $value the asset converter. This can be either
134+
* an object implementing the [[AssetConverterInterface]], or a configuration
135135
* array that can be used to create the asset converter object.
136136
*/
137137
public function setConverter($value)

framework/yii/web/Identity.php framework/yii/web/IdentityInterface.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
namespace yii\web;
99

1010
/**
11-
* Identity is the interface that should be implemented by a class providing identity information.
11+
* IdentityInterface is the interface that should be implemented by a class providing identity information.
1212
*
1313
* This interface can typically be implemented by a user model class. For example, the following
1414
* code shows how to implement this interface by a User ActiveRecord class:
1515
*
1616
* ~~~
17-
* class User extends ActiveRecord implements Identity
17+
* class User extends ActiveRecord implements IdentityInterface
1818
* {
1919
* public static function findIdentity($id)
2020
* {
@@ -41,12 +41,12 @@
4141
* @author Qiang Xue <qiang.xue@gmail.com>
4242
* @since 2.0
4343
*/
44-
interface Identity
44+
interface IdentityInterface
4545
{
4646
/**
4747
* Finds an identity by the given ID.
4848
* @param string|integer $id the ID to be looked for
49-
* @return Identity the identity object that matches the given ID.
49+
* @return IdentityInterface the identity object that matches the given ID.
5050
* Null should be returned if such an identity cannot be found
5151
* or the identity is not in an active state (disabled, deleted, etc.)
5252
*/

framework/yii/web/Response.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,10 @@ protected function prepare()
766766
if (!is_object($formatter)) {
767767
$formatter = Yii::createObject($formatter);
768768
}
769-
if ($formatter instanceof ResponseFormatter) {
769+
if ($formatter instanceof ResponseFormatterInterface) {
770770
$formatter->format($this);
771771
} else {
772-
throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatter interface.");
772+
throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatterInterface.");
773773
}
774774
} else {
775775
switch ($this->format) {

framework/yii/web/ResponseFormatter.php framework/yii/web/ResponseFormatterInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace yii\web;
99

1010
/**
11-
* ResponseFormatter specifies the interface needed to format a response before it is sent out.
11+
* ResponseFormatterInterface specifies the interface needed to format a response before it is sent out.
1212
*
1313
* @author Qiang Xue <qiang.xue@gmail.com>
1414
* @since 2.0
1515
*/
16-
interface ResponseFormatter
16+
interface ResponseFormatterInterface
1717
{
1818
/**
1919
* Formats the specified response.

framework/yii/web/User.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
* In particular, [[User::isGuest]] returns a value indicating whether the current user is a guest or not.
1919
* Through methods [[login()]] and [[logout()]], you can change the user authentication status.
2020
*
21-
* User works with a class implementing the [[Identity]] interface. This class implements
21+
* User works with a class implementing the [[IdentityInterface]]. This class implements
2222
* the actual user authentication logic and is often backed by a user database table.
2323
*
2424
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
2525
* This property is read-only.
26-
* @property Identity $identity The identity object associated with the currently logged user. Null is
26+
* @property IdentityInterface $identity The identity object associated with the currently logged user. Null is
2727
* returned if the user is not logged in (not authenticated).
2828
* @property boolean $isGuest Whether the current user is a guest. This property is read-only.
2929
* @property string $returnUrl The URL that the user should be redirected to after login. Note that the type
@@ -128,7 +128,7 @@ public function init()
128128

129129
/**
130130
* Returns the identity object associated with the currently logged user.
131-
* @return Identity the identity object associated with the currently logged user.
131+
* @return IdentityInterface the identity object associated with the currently logged user.
132132
* Null is returned if the user is not logged in (not authenticated).
133133
* @see login
134134
* @see logout
@@ -140,7 +140,7 @@ public function getIdentity()
140140
if ($id === null) {
141141
$this->_identity = null;
142142
} else {
143-
/** @var $class Identity */
143+
/** @var $class IdentityInterface */
144144
$class = $this->identityClass;
145145
$this->_identity = $class::findIdentity($id);
146146
}
@@ -156,7 +156,7 @@ public function getIdentity()
156156
* You should normally update the user identity via methods [[login()]], [[logout()]]
157157
* or [[switchIdentity()]].
158158
*
159-
* @param Identity $identity the identity object associated with the currently logged user.
159+
* @param IdentityInterface $identity the identity object associated with the currently logged user.
160160
*/
161161
public function setIdentity($identity)
162162
{
@@ -171,7 +171,7 @@ public function setIdentity($identity)
171171
* and [[enableAutoLogin]] is true, it will also send out an identity
172172
* cookie to support cookie-based login.
173173
*
174-
* @param Identity $identity the user identity (which should already be authenticated)
174+
* @param IdentityInterface $identity the user identity (which should already be authenticated)
175175
* @param integer $duration number of seconds that the user can remain in logged-in status.
176176
* Defaults to 0, meaning login till the user closes the browser or the session is manually destroyed.
177177
* If greater than 0 and [[enableAutoLogin]] is true, cookie-based login will be supported.
@@ -200,7 +200,7 @@ protected function loginByCookie()
200200
$data = json_decode($value, true);
201201
if (count($data) === 3 && isset($data[0], $data[1], $data[2])) {
202202
list ($id, $authKey, $duration) = $data;
203-
/** @var $class Identity */
203+
/** @var $class IdentityInterface */
204204
$class = $this->identityClass;
205205
$identity = $class::findIdentity($id);
206206
if ($identity !== null && $identity->validateAuthKey($authKey)) {
@@ -318,7 +318,7 @@ public function loginRequired()
318318
* The default implementation will trigger the [[EVENT_BEFORE_LOGIN]] event.
319319
* If you override this method, make sure you call the parent implementation
320320
* so that the event is triggered.
321-
* @param Identity $identity the user identity information
321+
* @param IdentityInterface $identity the user identity information
322322
* @param boolean $cookieBased whether the login is cookie-based
323323
* @return boolean whether the user should continue to be logged in
324324
*/
@@ -337,7 +337,7 @@ protected function beforeLogin($identity, $cookieBased)
337337
* The default implementation will trigger the [[EVENT_AFTER_LOGIN]] event.
338338
* If you override this method, make sure you call the parent implementation
339339
* so that the event is triggered.
340-
* @param Identity $identity the user identity information
340+
* @param IdentityInterface $identity the user identity information
341341
* @param boolean $cookieBased whether the login is cookie-based
342342
*/
343343
protected function afterLogin($identity, $cookieBased)
@@ -353,7 +353,7 @@ protected function afterLogin($identity, $cookieBased)
353353
* The default implementation will trigger the [[EVENT_BEFORE_LOGOUT]] event.
354354
* If you override this method, make sure you call the parent implementation
355355
* so that the event is triggered.
356-
* @param Identity $identity the user identity information
356+
* @param IdentityInterface $identity the user identity information
357357
* @return boolean whether the user should continue to be logged out
358358
*/
359359
protected function beforeLogout($identity)
@@ -370,7 +370,7 @@ protected function beforeLogout($identity)
370370
* The default implementation will trigger the [[EVENT_AFTER_LOGOUT]] event.
371371
* If you override this method, make sure you call the parent implementation
372372
* so that the event is triggered.
373-
* @param Identity $identity the user identity information
373+
* @param IdentityInterface $identity the user identity information
374374
*/
375375
protected function afterLogout($identity)
376376
{
@@ -402,9 +402,9 @@ protected function renewIdentityCookie()
402402
/**
403403
* Sends an identity cookie.
404404
* This method is used when [[enableAutoLogin]] is true.
405-
* It saves [[id]], [[Identity::getAuthKey()|auth key]], and the duration of cookie-based login
405+
* It saves [[id]], [[IdentityInterface::getAuthKey()|auth key]], and the duration of cookie-based login
406406
* information in the cookie.
407-
* @param Identity $identity
407+
* @param IdentityInterface $identity
408408
* @param integer $duration number of seconds that the user can remain in logged-in status.
409409
* @see loginByCookie
410410
*/
@@ -430,7 +430,7 @@ protected function sendIdentityCookie($identity, $duration)
430430
* This method is mainly called by [[login()]], [[logout()]] and [[loginByCookie()]]
431431
* when the current user needs to be associated with the corresponding identity information.
432432
*
433-
* @param Identity $identity the identity information to be associated with the current user.
433+
* @param IdentityInterface $identity the identity information to be associated with the current user.
434434
* If null, it means switching to be a guest.
435435
* @param integer $duration number of seconds that the user can remain in logged-in status.
436436
* This parameter is used only when `$identity` is not null.
@@ -444,7 +444,7 @@ public function switchIdentity($identity, $duration = 0)
444444
$this->setIdentity($identity);
445445
$session->remove($this->idVar);
446446
$session->remove($this->authTimeoutVar);
447-
if ($identity instanceof Identity) {
447+
if ($identity instanceof IdentityInterface) {
448448
$session->set($this->idVar, $identity->getId());
449449
if ($this->authTimeout !== null) {
450450
$session->set($this->authTimeoutVar, time() + $this->authTimeout);

framework/yii/web/UserEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class UserEvent extends Event
1919
{
2020
/**
21-
* @var Identity the identity object associated with this event
21+
* @var IdentityInterface the identity object associated with this event
2222
*/
2323
public $identity;
2424
/**

framework/yii/web/XmlResponseFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @author Qiang Xue <qiang.xue@gmail.com>
2121
* @since 2.0
2222
*/
23-
class XmlResponseFormatter extends Component implements ResponseFormatter
23+
class XmlResponseFormatter extends Component implements ResponseFormatterInterface
2424
{
2525
/**
2626
* @var string the Content-Type header for the response

framework/yii/widgets/ListViewBase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ abstract class ListViewBase extends Widget
2525
*/
2626
public $options = array();
2727
/**
28-
* @var \yii\data\IDataProvider the data provider for the view. This property is required.
28+
* @var \yii\data\DataProviderInterface the data provider for the view. This property is required.
2929
*/
3030
public $dataProvider;
3131
/**

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<file>framework/yii/helpers/ArrayHelper.php</file>
2222
<file>framework/yii/helpers/Console.php</file>
2323
<file>framework/yii/i18n/GettextFile.php</file>
24-
<file>framework/yii/web/ResponseFormatter.php</file>
24+
<file>framework/yii/web/ResponseFormatterInterface.php</file>
2525
<directory suffix="Exception.php">framework/yii/base</directory>
2626
<directory suffix=".php">framework/yii/db/mssql</directory>
2727
<directory suffix=".php">framework/yii/bootstrap</directory>

0 commit comments

Comments
 (0)