Browse Source

Merge branch 'master' of github.com:yiisoft/yii2

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
2d86618644
  1. 6
      apps/advanced/backend/config/main.php
  2. 2
      apps/advanced/backend/controllers/SiteController.php
  3. 8
      apps/advanced/backend/views/layouts/main.php
  4. 2
      apps/advanced/frontend/controllers/SiteController.php
  5. 4
      apps/advanced/frontend/views/emails/passwordResetToken.php
  6. 12
      apps/advanced/frontend/views/layouts/main.php
  7. 2
      apps/advanced/frontend/views/site/login.php
  8. 13
      apps/basic/views/layouts/main.php
  9. 7
      extensions/bootstrap/composer.json
  10. 1
      extensions/composer/composer.json
  11. 7
      extensions/debug/composer.json
  12. 7
      extensions/gii/composer.json
  13. 8
      extensions/gii/views/default/index.php
  14. 4
      extensions/gii/views/default/view/files.php
  15. 8
      extensions/gii/views/layouts/generator.php
  16. 4
      extensions/gii/views/layouts/main.php
  17. 7
      extensions/jui/composer.json
  18. 3
      extensions/smarty/composer.json
  19. 2
      extensions/swiftmailer/Message.php
  20. 3
      extensions/swiftmailer/composer.json
  21. 3
      extensions/twig/composer.json
  22. 4
      framework/composer.json
  23. 19
      framework/yii/BaseYii.php
  24. 5
      framework/yii/base/ActionFilter.php
  25. 2
      framework/yii/base/Application.php
  26. 18
      framework/yii/base/Component.php
  27. 5
      framework/yii/base/Controller.php
  28. 3
      framework/yii/base/ErrorHandler.php
  29. 3
      framework/yii/base/Formatter.php
  30. 26
      framework/yii/base/Model.php
  31. 2
      framework/yii/base/Module.php
  32. 15
      framework/yii/base/Object.php
  33. 1
      framework/yii/base/Request.php
  34. 2
      framework/yii/base/Response.php
  35. 4
      framework/yii/base/View.php
  36. 2
      framework/yii/base/ViewEvent.php
  37. 2
      framework/yii/captcha/CaptchaAsset.php
  38. 4
      framework/yii/console/Request.php
  39. 2
      framework/yii/console/Response.php
  40. 2
      framework/yii/console/controllers/CacheController.php
  41. 6
      framework/yii/db/ActiveQuery.php
  42. 22
      framework/yii/db/ActiveRecord.php
  43. 12
      framework/yii/db/ActiveRelation.php
  44. 2
      framework/yii/db/Command.php
  45. 4
      framework/yii/db/Query.php
  46. 8
      framework/yii/db/Schema.php
  47. 2
      framework/yii/grid/ActionColumn.php
  48. 4
      framework/yii/grid/DataColumn.php
  49. 4
      framework/yii/grid/GridView.php
  50. 1
      framework/yii/grid/GridViewAsset.php
  51. 26
      framework/yii/helpers/BaseHtml.php
  52. 2
      framework/yii/helpers/BaseInflector.php
  53. 9
      framework/yii/i18n/Formatter.php
  54. 3
      framework/yii/i18n/I18N.php
  55. 2
      framework/yii/log/Target.php
  56. 2
      framework/yii/mail/BaseMailer.php
  57. 28
      framework/yii/rbac/PhpManager.php
  58. 2
      framework/yii/requirements/requirements.php
  59. 6
      framework/yii/requirements/views/console/index.php
  60. 6
      framework/yii/requirements/views/web/index.php
  61. 4
      framework/yii/validators/ExistValidator.php
  62. 2
      framework/yii/validators/PunycodeAsset.php
  63. 2
      framework/yii/validators/UniqueValidator.php
  64. 2
      framework/yii/validators/ValidationAsset.php
  65. 2
      framework/yii/web/AccessControl.php
  66. 4
      framework/yii/web/AssetConverter.php
  67. 16
      framework/yii/web/AssetManager.php
  68. 12
      framework/yii/web/CacheSession.php
  69. 31
      framework/yii/web/Controller.php
  70. 1
      framework/yii/web/DbSession.php
  71. 27
      framework/yii/web/HttpCache.php
  72. 8
      framework/yii/web/HttpException.php
  73. 30
      framework/yii/web/PageCache.php
  74. 21
      framework/yii/web/Request.php
  75. 14
      framework/yii/web/Response.php
  76. 3
      framework/yii/web/Session.php
  77. 2
      framework/yii/web/UploadedFile.php
  78. 22
      framework/yii/web/UrlManager.php
  79. 12
      framework/yii/web/UrlRule.php
  80. 27
      framework/yii/web/User.php
  81. 30
      framework/yii/web/View.php
  82. 2
      framework/yii/web/XmlResponseFormatter.php
  83. 2
      framework/yii/web/YiiAsset.php
  84. 2
      framework/yii/widgets/ActiveForm.php
  85. 6
      framework/yii/widgets/Menu.php
  86. 6
      tests/unit/data/views/layout.php
  87. 4
      tests/unit/data/views/rawlayout.php
  88. 2
      tests/unit/extensions/swiftmailer/MessageTest.php
  89. 6
      tests/unit/framework/db/ActiveRecordTest.php
  90. 4
      tests/unit/framework/validators/ValidatorTest.php

6
apps/advanced/backend/config/main.php

@ -1,5 +1,5 @@
<?php <?php
$rootDir = __DIR__ . '/../..'; $rootDir = dirname(dirname(__DIR__));
$params = array_merge( $params = array_merge(
require($rootDir . '/common/config/params.php'), require($rootDir . '/common/config/params.php'),
@ -11,11 +11,11 @@ $params = array_merge(
return [ return [
'id' => 'app-backend', 'id' => 'app-backend',
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'vendorPath' => $rootDir . '/vendor',
'preload' => ['log'], 'preload' => ['log'],
'controllerNamespace' => 'backend\controllers', 'controllerNamespace' => 'backend\controllers',
'modules' => [], 'modules' => [],
'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'), 'extensions' => require($rootDir . '/vendor/yiisoft/extensions.php'),
'components' => [ 'components' => [
'request' => [ 'request' => [
'enableCsrfValidation' => true, 'enableCsrfValidation' => true,

2
apps/advanced/backend/controllers/SiteController.php

@ -50,7 +50,7 @@ class SiteController extends Controller
$model = new LoginForm(); $model = new LoginForm();
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goBack();
} else { } else {
return $this->render('login', [ return $this->render('login', [
'model' => $model, 'model' => $model,

8
apps/advanced/backend/views/layouts/main.php

@ -6,8 +6,8 @@ use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
AppAsset::register($this); AppAsset::register($this);
?> ?>
@ -45,9 +45,9 @@ AppAsset::register($this);
?> ?>
<div class="container"> <div class="container">
<?=Breadcrumbs::widget([ <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]); ?> ]) ?>
<?= $content ?> <?= $content ?>
</div> </div>

2
apps/advanced/frontend/controllers/SiteController.php

@ -60,7 +60,7 @@ class SiteController extends Controller
$model = new LoginForm(); $model = new LoginForm();
if ($model->load($_POST) && $model->login()) { if ($model->load($_POST) && $model->login()) {
return $this->goHome(); return $this->goBack();
} else { } else {
return $this->render('login', [ return $this->render('login', [
'model' => $model, 'model' => $model,

4
apps/advanced/frontend/views/emails/passwordResetToken.php

@ -9,8 +9,8 @@ use yii\helpers\Html;
$resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', ['token' => $user->password_reset_token]); $resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', ['token' => $user->password_reset_token]);
?> ?>
Hello <?=Html::encode($user->username)?>, Hello <?= Html::encode($user->username) ?>,
Follow the link below to reset your password: Follow the link below to reset your password:
<?=Html::a(Html::encode($resetLink), $resetLink)?> <?= Html::a(Html::encode($resetLink), $resetLink) ?>

12
apps/advanced/frontend/views/layouts/main.php

@ -1,14 +1,14 @@
<?php <?php
use frontend\config\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar; use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use frontend\config\AppAsset;
use frontend\widgets\Alert; use frontend\widgets\Alert;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
AppAsset::register($this); AppAsset::register($this);
?> ?>
@ -49,10 +49,10 @@ AppAsset::register($this);
?> ?>
<div class="container"> <div class="container">
<?=Breadcrumbs::widget([ <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]); ?> ]) ?>
<?=Alert::widget()?> <?= Alert::widget() ?>
<?= $content ?> <?= $content ?>
</div> </div>

2
apps/advanced/frontend/views/site/login.php

@ -22,7 +22,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $form->field($model, 'password')->passwordInput() ?> <?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?> <?= $form->field($model, 'rememberMe')->checkbox() ?>
<div style="color:#999;margin:1em 0"> <div style="color:#999;margin:1em 0">
If you forgot your password you can <?=Html::a('reset it', ['site/request-password-reset'])?>. If you forgot your password you can <?= Html::a('reset it', ['site/request-password-reset']) ?>.
</div> </div>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?> <?= Html::submitButton('Login', ['class' => 'btn btn-primary']) ?>

13
apps/basic/views/layouts/main.php

@ -3,12 +3,13 @@ use yii\helpers\Html;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar; use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use app\config\AppAsset;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
app\config\AppAsset::register($this); AppAsset::register($this);
?> ?>
<?php $this->beginPage(); ?> <?php $this->beginPage(); ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -36,7 +37,7 @@ app\config\AppAsset::register($this);
['label' => 'Contact', 'url' => ['/site/contact']], ['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] : ['label' => 'Login', 'url' => ['/site/login']] :
['label' => 'Logout (' . Yii::$app->user->identity->username .')' , ['label' => 'Logout (' . Yii::$app->user->identity->username . ')' ,
'url' => ['/site/logout'], 'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']], 'linkOptions' => ['data-method' => 'post']],
], ],
@ -45,9 +46,9 @@ app\config\AppAsset::register($this);
?> ?>
<div class="container"> <div class="container">
<?=Breadcrumbs::widget([ <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]); ?> ]) ?>
<?= $content ?> <?= $content ?>
</div> </div>

7
extensions/bootstrap/composer.json

@ -11,7 +11,12 @@
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"minimum-stability": "dev", "authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"twbs/bootstrap": "3.0.*" "twbs/bootstrap": "3.0.*"

1
extensions/composer/composer.json

@ -17,7 +17,6 @@
"email": "qiang.xue@gmail.com" "email": "qiang.xue@gmail.com"
} }
], ],
"minimum-stability": "dev",
"autoload": { "autoload": {
"psr-0": { "yii\\composer\\": "" } "psr-0": { "yii\\composer\\": "" }
}, },

7
extensions/debug/composer.json

@ -11,7 +11,12 @@
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"minimum-stability": "dev", "authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*" "yiisoft/yii2-bootstrap": "*"

7
extensions/gii/composer.json

@ -11,7 +11,12 @@
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"minimum-stability": "dev", "authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*" "yiisoft/yii2-bootstrap": "*"

8
extensions/gii/views/default/index.php

@ -2,10 +2,10 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var \yii\gii\Generator[] $generators
* @var yii\gii\Generator[] $generators * @var \yii\gii\Generator $activeGenerator
* @var yii\gii\Generator $activeGenerator * @var string $content
*/ */
$generators = Yii::$app->controller->module->generators; $generators = Yii::$app->controller->module->generators;
$activeGenerator = Yii::$app->controller->generator; $activeGenerator = Yii::$app->controller->generator;

4
extensions/gii/views/default/view/files.php

@ -4,8 +4,8 @@ use yii\helpers\Html;
use yii\gii\CodeFile; use yii\gii\CodeFile;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $generator \yii\gii\Generator * @var \yii\gii\Generator $generator
* @var CodeFile[] $files * @var CodeFile[] $files
* @var array $answers * @var array $answers
*/ */

8
extensions/gii/views/layouts/generator.php

@ -2,10 +2,10 @@
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var \yii\gii\Generator[] $generators
* @var yii\gii\Generator[] $generators * @var \yii\gii\Generator $activeGenerator
* @var yii\gii\Generator $activeGenerator * @var string $content
*/ */
$generators = Yii::$app->controller->module->generators; $generators = Yii::$app->controller->module->generators;
$activeGenerator = Yii::$app->controller->generator; $activeGenerator = Yii::$app->controller->generator;

4
extensions/gii/views/layouts/main.php

@ -4,8 +4,8 @@ use yii\bootstrap\Nav;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
$asset = yii\gii\GiiAsset::register($this); $asset = yii\gii\GiiAsset::register($this);
?> ?>

7
extensions/jui/composer.json

@ -11,7 +11,12 @@
"irc": "irc://irc.freenode.net/yii", "irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2" "source": "https://github.com/yiisoft/yii2"
}, },
"minimum-stability": "dev", "authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": { "require": {
"yiisoft/yii2": "*" "yiisoft/yii2": "*"
}, },

3
extensions/smarty/composer.json

@ -17,10 +17,9 @@
"email": "sam@rmcreative.ru" "email": "sam@rmcreative.ru"
} }
], ],
"minimum-stability": "dev",
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"smarty/smarty": ">=v3.1.13" "smarty/smarty": "*"
}, },
"autoload": { "autoload": {
"psr-0": { "yii\\smarty\\": "" } "psr-0": { "yii\\smarty\\": "" }

2
extensions/swiftmailer/Message.php

@ -192,7 +192,7 @@ class Message extends BaseMessage
$partFound = false; $partFound = false;
foreach ($parts as $key => $part) { foreach ($parts as $key => $part) {
if (!($part instanceof \Swift_Mime_Attachment)) { if (!($part instanceof \Swift_Mime_Attachment)) {
/* @var $part \Swift_Mime_MimePart */ /* @var \Swift_Mime_MimePart $part */
if ($part->getContentType() == $contentType) { if ($part->getContentType() == $contentType) {
unset($parts[$key]); unset($parts[$key]);
$partFound = true; $partFound = true;

3
extensions/swiftmailer/composer.json

@ -17,10 +17,9 @@
"email": "klimov.paul@gmail.com" "email": "klimov.paul@gmail.com"
} }
], ],
"minimum-stability": "dev",
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"swiftmailer/swiftmailer": "@stable" "swiftmailer/swiftmailer": "*"
}, },
"autoload": { "autoload": {
"psr-0": { "yii\\swiftmailer\\": "" } "psr-0": { "yii\\swiftmailer\\": "" }

3
extensions/twig/composer.json

@ -17,10 +17,9 @@
"email": "sam@rmcreative.ru" "email": "sam@rmcreative.ru"
} }
], ],
"minimum-stability": "dev",
"require": { "require": {
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
"twig/twig": "1.13.*" "twig/twig": "*"
}, },
"autoload": { "autoload": {
"psr-0": { "yii\\twig\\": "" } "psr-0": { "yii\\twig\\": "" }

4
framework/composer.json

@ -65,10 +65,10 @@
}, },
"require": { "require": {
"php": ">=5.4.0", "php": ">=5.4.0",
"yiisoft/yii2-composer": "*",
"yiisoft/jquery": "1.10.*",
"ext-mbstring": "*", "ext-mbstring": "*",
"lib-pcre": "*", "lib-pcre": "*",
"yiisoft/yii2-composer": "*",
"yiisoft/jquery": "1.10.*",
"phpspec/php-diff": ">=1.0.2", "phpspec/php-diff": ">=1.0.2",
"ezyang/htmlpurifier": "4.5.*", "ezyang/htmlpurifier": "4.5.*",
"michelf/php-markdown": "1.3.*" "michelf/php-markdown": "1.3.*"

19
framework/yii/BaseYii.php

@ -63,8 +63,7 @@ class BaseYii
* The array keys are the class names (without leading backslashes), and the array values * The array keys are the class names (without leading backslashes), and the array values
* are the corresponding class file paths (or path aliases). This property mainly affects * are the corresponding class file paths (or path aliases). This property mainly affects
* how [[autoload()]] works. * how [[autoload()]] works.
* @see import * @see autoload()
* @see autoload
*/ */
public static $classMap = []; public static $classMap = [];
/** /**
@ -73,8 +72,8 @@ class BaseYii
public static $app; public static $app;
/** /**
* @var array registered path aliases * @var array registered path aliases
* @see getAlias * @see getAlias()
* @see setAlias * @see setAlias()
*/ */
public static $aliases = ['@yii' => __DIR__]; public static $aliases = ['@yii' => __DIR__];
/** /**
@ -95,7 +94,7 @@ class BaseYii
* ] * ]
* ~~~ * ~~~
* *
* @see createObject * @see createObject()
*/ */
public static $objectConfig = []; public static $objectConfig = [];
@ -136,7 +135,7 @@ class BaseYii
* If this is false and an invalid alias is given, false will be returned by this method. * If this is false and an invalid alias is given, false will be returned by this method.
* @return string|boolean the path corresponding to the alias, false if the root alias is not previously registered. * @return string|boolean the path corresponding to the alias, false if the root alias is not previously registered.
* @throws InvalidParamException if the alias is invalid while $throwException is true. * @throws InvalidParamException if the alias is invalid while $throwException is true.
* @see setAlias * @see setAlias()
*/ */
public static function getAlias($alias, $throwException = true) public static function getAlias($alias, $throwException = true)
{ {
@ -219,7 +218,7 @@ class BaseYii
* actual path first by calling [[getAlias()]]. * actual path first by calling [[getAlias()]].
* *
* @throws InvalidParamException if $path is an invalid alias. * @throws InvalidParamException if $path is an invalid alias.
* @see getAlias * @see getAlias()
*/ */
public static function setAlias($alias, $path) public static function setAlias($alias, $path)
{ {
@ -368,7 +367,7 @@ class BaseYii
} }
if (($n = func_num_args()) > 1) { if (($n = func_num_args()) > 1) {
/** @var $reflection \ReflectionClass */ /** @var \ReflectionClass $reflection */
if (isset($reflections[$class])) { if (isset($reflections[$class])) {
$reflection = $reflections[$class]; $reflection = $reflections[$class];
} else { } else {
@ -450,7 +449,7 @@ class BaseYii
* ~~~ * ~~~
* @param string $token token for the code block * @param string $token token for the code block
* @param string $category the category of this log message * @param string $category the category of this log message
* @see endProfile * @see endProfile()
*/ */
public static function beginProfile($token, $category = 'application') public static function beginProfile($token, $category = 'application')
{ {
@ -462,7 +461,7 @@ class BaseYii
* This has to be matched with a previous call to [[beginProfile]] with the same category name. * This has to be matched with a previous call to [[beginProfile]] with the same category name.
* @param string $token token for the code block * @param string $token token for the code block
* @param string $category the category of this log message * @param string $category the category of this log message
* @see beginProfile * @see beginProfile()
*/ */
public static function endProfile($token, $category = 'application') public static function endProfile($token, $category = 'application')
{ {

5
framework/yii/base/ActionFilter.php

@ -8,6 +8,11 @@
namespace yii\base; namespace yii\base;
/** /**
* ActionFilter provides a base implementation for action filters that can be added to a controller
* to handle the `beforeAction` event.
*
* Check implementation of [[AccessControl]], [[PageCache]] and [[HttpCache]] as examples on how to use it.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/base/Application.php

@ -616,10 +616,8 @@ abstract class Application extends Module
{ {
$category = get_class($exception); $category = get_class($exception);
if ($exception instanceof HttpException) { if ($exception instanceof HttpException) {
/** @var $exception HttpException */
$category .= '\\' . $exception->statusCode; $category .= '\\' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) { } elseif ($exception instanceof \ErrorException) {
/** @var $exception \ErrorException */
$category .= '\\' . $exception->getSeverity(); $category .= '\\' . $exception->getSeverity();
} }
Yii::error((string)$exception, $category); Yii::error((string)$exception, $category);

18
framework/yii/base/Component.php

@ -10,6 +10,8 @@ namespace yii\base;
use Yii; use Yii;
/** /**
* Component is the base class that implements the *property*, *event* and *behavior* features.
*
* @include @yii/base/Component.md * @include @yii/base/Component.md
* *
* @property Behavior[] $behaviors List of behaviors attached to this component. This property is read-only. * @property Behavior[] $behaviors List of behaviors attached to this component. This property is read-only.
@ -41,7 +43,7 @@ class Component extends Object
* @return mixed the property value or the value of a behavior's property * @return mixed the property value or the value of a behavior's property
* @throws UnknownPropertyException if the property is not defined * @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is write-only. * @throws InvalidCallException if the property is write-only.
* @see __set * @see __set()
*/ */
public function __get($name) public function __get($name)
{ {
@ -80,7 +82,7 @@ class Component extends Object
* @param mixed $value the property value * @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined * @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only. * @throws InvalidCallException if the property is read-only.
* @see __get * @see __get()
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
@ -225,8 +227,8 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property is defined * @return boolean whether the property is defined
* @see canGetProperty * @see canGetProperty()
* @see canSetProperty * @see canSetProperty()
*/ */
public function hasProperty($name, $checkVars = true, $checkBehaviors = true) public function hasProperty($name, $checkVars = true, $checkBehaviors = true)
{ {
@ -246,7 +248,7 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property can be read * @return boolean whether the property can be read
* @see canSetProperty * @see canSetProperty()
*/ */
public function canGetProperty($name, $checkVars = true, $checkBehaviors = true) public function canGetProperty($name, $checkVars = true, $checkBehaviors = true)
{ {
@ -276,7 +278,7 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component * @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property can be written * @return boolean whether the property can be written
* @see canGetProperty * @see canGetProperty()
*/ */
public function canSetProperty($name, $checkVars = true, $checkBehaviors = true) public function canSetProperty($name, $checkVars = true, $checkBehaviors = true)
{ {
@ -492,7 +494,7 @@ class Component extends Object
* - an object configuration array that will be passed to [[Yii::createObject()]] to create the behavior object. * - an object configuration array that will be passed to [[Yii::createObject()]] to create the behavior object.
* *
* @return Behavior the behavior object * @return Behavior the behavior object
* @see detachBehavior * @see detachBehavior()
*/ */
public function attachBehavior($name, $behavior) public function attachBehavior($name, $behavior)
{ {
@ -505,7 +507,7 @@ class Component extends Object
* Each behavior is indexed by its name and should be a [[Behavior]] object, * Each behavior is indexed by its name and should be a [[Behavior]] object,
* a string specifying the behavior class, or an configuration array for creating the behavior. * a string specifying the behavior class, or an configuration array for creating the behavior.
* @param array $behaviors list of behaviors to be attached to the component * @param array $behaviors list of behaviors to be attached to the component
* @see attachBehavior * @see attachBehavior()
*/ */
public function attachBehaviors($behaviors) public function attachBehaviors($behaviors)
{ {

5
framework/yii/base/Controller.php

@ -111,7 +111,7 @@ class Controller extends Component implements ViewContextInterface
* @param array $params the parameters (name-value pairs) to be passed to the action. * @param array $params the parameters (name-value pairs) to be passed to the action.
* @return mixed the result of the action * @return mixed the result of the action
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully. * @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @see createAction * @see createAction()
*/ */
public function runAction($id, $params = []) public function runAction($id, $params = [])
{ {
@ -149,8 +149,7 @@ class Controller extends Component implements ViewContextInterface
* @param string $route the route to be handled, e.g., 'view', 'comment/view', '/admin/comment/view'. * @param string $route the route to be handled, e.g., 'view', 'comment/view', '/admin/comment/view'.
* @param array $params the parameters to be passed to the action. * @param array $params the parameters to be passed to the action.
* @return mixed the result of the action * @return mixed the result of the action
* @see runAction * @see runAction()
* @see forward
*/ */
public function run($route, $params = []) public function run($route, $params = [])
{ {

3
framework/yii/base/ErrorHandler.php

@ -16,6 +16,9 @@ use yii\web\HttpException;
* ErrorHandler displays these errors using appropriate views based on the * ErrorHandler displays these errors using appropriate views based on the
* nature of the errors and the mode the application runs at. * nature of the errors and the mode the application runs at.
* *
* ErrorHandler is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->errorHandler`.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @author Timur Ruziev <resurtm@gmail.com> * @author Timur Ruziev <resurtm@gmail.com>
* @since 2.0 * @since 2.0

3
framework/yii/base/Formatter.php

@ -19,6 +19,9 @@ use yii\helpers\Html;
* The behavior of some of them may be configured via the properties of Formatter. For example, * The behavior of some of them may be configured via the properties of Formatter. For example,
* by configuring [[dateFormat]], one may control how [[asDate()]] formats the value into a date string. * by configuring [[dateFormat]], one may control how [[asDate()]] formats the value into a date string.
* *
* Formatter is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->formatter`.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

26
framework/yii/base/Model.php

@ -46,7 +46,8 @@ use yii\validators\Validator;
* @property ArrayIterator $iterator An iterator for traversing the items in the list. This property is * @property ArrayIterator $iterator An iterator for traversing the items in the list. This property is
* read-only. * read-only.
* @property string $scenario The scenario that this model is in. Defaults to [[DEFAULT_SCENARIO]]. * @property string $scenario The scenario that this model is in. Defaults to [[DEFAULT_SCENARIO]].
* @property ArrayObject $validators All the validators declared in the model. This property is read-only. * @property ArrayObject|\yii\validators\Validator[] $validators All the validators declared in the model.
* This property is read-only.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
@ -144,7 +145,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* merge the parent rules with child rules using functions such as `array_merge()`. * merge the parent rules with child rules using functions such as `array_merge()`.
* *
* @return array validation rules * @return array validation rules
* @see scenarios * @see scenarios()
*/ */
public function rules() public function rules()
{ {
@ -255,7 +256,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* merge the parent labels with child labels using functions such as `array_merge()`. * merge the parent labels with child labels using functions such as `array_merge()`.
* *
* @return array attribute labels (name => label) * @return array attribute labels (name => label)
* @see generateAttributeLabel * @see generateAttributeLabel()
*/ */
public function attributeLabels() public function attributeLabels()
{ {
@ -349,7 +350,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* $model->validators[] = $newValidator; * $model->validators[] = $newValidator;
* ~~~ * ~~~
* *
* @return ArrayObject all the validators declared in the model. * @return ArrayObject|\yii\validators\Validator[] all the validators declared in the model.
*/ */
public function getValidators() public function getValidators()
{ {
@ -369,7 +370,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
{ {
$validators = []; $validators = [];
$scenario = $this->getScenario(); $scenario = $this->getScenario();
/** @var $validator Validator */
foreach ($this->getValidators() as $validator) { foreach ($this->getValidators() as $validator) {
if ($validator->isActive($scenario) && ($attribute === null || in_array($attribute, $validator->attributes, true))) { if ($validator->isActive($scenario) && ($attribute === null || in_array($attribute, $validator->attributes, true))) {
$validators[] = $validator; $validators[] = $validator;
@ -444,8 +444,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* Returns the text label for the specified attribute. * Returns the text label for the specified attribute.
* @param string $attribute the attribute name * @param string $attribute the attribute name
* @return string the attribute label * @return string the attribute label
* @see generateAttributeLabel * @see generateAttributeLabel()
* @see attributeLabels * @see attributeLabels()
*/ */
public function getAttributeLabel($attribute) public function getAttributeLabel($attribute)
{ {
@ -483,8 +483,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* ] * ]
* ~~~ * ~~~
* *
* @see getFirstErrors * @see getFirstErrors()
* @see getFirstError * @see getFirstError()
*/ */
public function getErrors($attribute = null) public function getErrors($attribute = null)
{ {
@ -498,8 +498,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
/** /**
* Returns the first error of every attribute in the model. * Returns the first error of every attribute in the model.
* @return array the first errors. An empty array will be returned if there is no error. * @return array the first errors. An empty array will be returned if there is no error.
* @see getErrors * @see getErrors()
* @see getFirstError * @see getFirstError()
*/ */
public function getFirstErrors() public function getFirstErrors()
{ {
@ -520,8 +520,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* Returns the first error of the specified attribute. * Returns the first error of the specified attribute.
* @param string $attribute attribute name. * @param string $attribute attribute name.
* @return string the error message. Null is returned if no error. * @return string the error message. Null is returned if no error.
* @see getErrors * @see getErrors()
* @see getFirstErrors * @see getFirstErrors()
*/ */
public function getFirstError($attribute) public function getFirstError($attribute)
{ {

2
framework/yii/base/Module.php

@ -578,7 +578,7 @@ abstract class Module extends Component
{ {
$parts = $this->createController($route); $parts = $this->createController($route);
if (is_array($parts)) { if (is_array($parts)) {
/** @var $controller Controller */ /** @var Controller $controller */
list($controller, $actionID) = $parts; list($controller, $actionID) = $parts;
$oldController = Yii::$app->controller; $oldController = Yii::$app->controller;
Yii::$app->controller = $controller; Yii::$app->controller = $controller;

15
framework/yii/base/Object.php

@ -10,7 +10,10 @@ namespace yii\base;
use Yii; use Yii;
/** /**
* Object is the base class that implements the *property* feature.
*
* @include @yii/base/Object.md * @include @yii/base/Object.md
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
@ -64,7 +67,7 @@ class Object implements Arrayable
* @return mixed the property value * @return mixed the property value
* @throws UnknownPropertyException if the property is not defined * @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is write-only * @throws InvalidCallException if the property is write-only
* @see __set * @see __set()
*/ */
public function __get($name) public function __get($name)
{ {
@ -87,7 +90,7 @@ class Object implements Arrayable
* @param mixed $value the property value * @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined * @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only * @throws InvalidCallException if the property is read-only
* @see __get * @see __get()
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
@ -168,8 +171,8 @@ class Object implements Arrayable
* @param string $name the property name * @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property is defined * @return boolean whether the property is defined
* @see canGetProperty * @see canGetProperty()
* @see canSetProperty * @see canSetProperty()
*/ */
public function hasProperty($name, $checkVars = true) public function hasProperty($name, $checkVars = true)
{ {
@ -187,7 +190,7 @@ class Object implements Arrayable
* @param string $name the property name * @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property can be read * @return boolean whether the property can be read
* @see canSetProperty * @see canSetProperty()
*/ */
public function canGetProperty($name, $checkVars = true) public function canGetProperty($name, $checkVars = true)
{ {
@ -205,7 +208,7 @@ class Object implements Arrayable
* @param string $name the property name * @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties * @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property can be written * @return boolean whether the property can be written
* @see canGetProperty * @see canGetProperty()
*/ */
public function canSetProperty($name, $checkVars = true) public function canSetProperty($name, $checkVars = true)
{ {

1
framework/yii/base/Request.php

@ -8,6 +8,7 @@
namespace yii\base; namespace yii\base;
/** /**
* Request represents a request that is handled by an [[Application]].
* *
* @property boolean $isConsoleRequest The value indicating whether the current request is made via console. * @property boolean $isConsoleRequest The value indicating whether the current request is made via console.
* @property string $scriptFile Entry script file path (processed w/ realpath()). * @property string $scriptFile Entry script file path (processed w/ realpath()).

2
framework/yii/base/Response.php

@ -8,6 +8,8 @@
namespace yii\base; namespace yii\base;
/** /**
* Response represents the response of an [[Application]] to a [[Request]].
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

4
framework/yii/base/View.php

@ -123,7 +123,7 @@ class View extends Component
* existing [[context]] will be used. * existing [[context]] will be used.
* @return string the rendering result * @return string the rendering result
* @throws InvalidParamException if the view cannot be resolved or the view file does not exist. * @throws InvalidParamException if the view cannot be resolved or the view file does not exist.
* @see renderFile * @see renderFile()
*/ */
public function render($view, $params = [], $context = null) public function render($view, $params = [], $context = null)
{ {
@ -410,7 +410,7 @@ class View extends Component
{ {
$properties['id'] = $id; $properties['id'] = $id;
$properties['view'] = $this; $properties['view'] = $this;
/** @var $cache FragmentCache */ /** @var FragmentCache $cache */
$cache = FragmentCache::begin($properties); $cache = FragmentCache::begin($properties);
if ($cache->getCachedContent() !== false) { if ($cache->getCachedContent() !== false) {
$this->endCache(); $this->endCache();

2
framework/yii/base/ViewEvent.php

@ -8,6 +8,8 @@
namespace yii\base; namespace yii\base;
/** /**
* ViewEvent represents events triggered by the [[View]] component.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/captcha/CaptchaAsset.php

@ -10,6 +10,8 @@ namespace yii\captcha;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
* This asset bundle provides the javascript files needed for the [[Captcha]] widget.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

4
framework/yii/console/Request.php

@ -8,6 +8,10 @@
namespace yii\console; namespace yii\console;
/** /**
* The console Request represents the environment information for a console application.
*
* It is a wrapper for the PHP `$_SERVER` variable which holds information about the
* currently running PHP script and the command line arguments given to it.
* *
* @property array $params The command line arguments. It does not include the entry script name. * @property array $params The command line arguments. It does not include the entry script name.
* *

2
framework/yii/console/Response.php

@ -8,6 +8,8 @@
namespace yii\console; namespace yii\console;
/** /**
* The console Response represents the result of a console application by holding the [[exitCode]].
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/console/controllers/CacheController.php

@ -52,7 +52,7 @@ class CacheController extends Controller
*/ */
public function actionFlush($component = 'cache') public function actionFlush($component = 'cache')
{ {
/** @var $cache Cache */ /** @var Cache $cache */
$cache = Yii::$app->getComponent($component); $cache = Yii::$app->getComponent($component);
if (!$cache || !$cache instanceof Cache) { if (!$cache || !$cache instanceof Cache) {
throw new Exception('Application component "'.$component.'" is not defined or not a cache.'); throw new Exception('Application component "'.$component.'" is not defined or not a cache.');

6
framework/yii/db/ActiveQuery.php

@ -122,7 +122,7 @@ class ActiveQuery extends Query
if ($this->asArray) { if ($this->asArray) {
$model = $row; $model = $row;
} else { } else {
/** @var $class ActiveRecord */ /** @var ActiveRecord $class */
$class = $this->modelClass; $class = $this->modelClass;
$model = $class::create($row); $model = $class::create($row);
} }
@ -145,7 +145,7 @@ class ActiveQuery extends Query
*/ */
public function createCommand($db = null) public function createCommand($db = null)
{ {
/** @var $modelClass ActiveRecord */ /** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass; $modelClass = $this->modelClass;
if ($db === null) { if ($db === null) {
$db = $modelClass::getDb(); $db = $modelClass::getDb();
@ -253,7 +253,7 @@ class ActiveQuery extends Query
$models[$key] = $row; $models[$key] = $row;
} }
} else { } else {
/** @var $class ActiveRecord */ /** @var ActiveRecord $class */
$class = $this->modelClass; $class = $this->modelClass;
if ($this->indexBy === null) { if ($this->indexBy === null) {
foreach ($rows as $row) { foreach ($rows as $row) {

22
framework/yii/db/ActiveRecord.php

@ -372,7 +372,7 @@ class ActiveRecord extends Model
* This method is overridden so that attributes and related objects can be accessed like properties. * This method is overridden so that attributes and related objects can be accessed like properties.
* @param string $name property name * @param string $name property name
* @return mixed property value * @return mixed property value
* @see getAttribute * @see getAttribute()
*/ */
public function __get($name) public function __get($name)
{ {
@ -576,7 +576,7 @@ class ActiveRecord extends Model
* null will be returned. * null will be returned.
* @param string $name the attribute name * @param string $name the attribute name
* @return mixed the attribute value. Null if the attribute is not set or does not exist. * @return mixed the attribute value. Null if the attribute is not set or does not exist.
* @see hasAttribute * @see hasAttribute()
*/ */
public function getAttribute($name) public function getAttribute($name)
{ {
@ -588,7 +588,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name * @param string $name the attribute name
* @param mixed $value the attribute value. * @param mixed $value the attribute value.
* @throws InvalidParamException if the named attribute does not exist. * @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute * @see hasAttribute()
*/ */
public function setAttribute($name, $value) public function setAttribute($name, $value)
{ {
@ -625,7 +625,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name * @param string $name the attribute name
* @return mixed the old attribute value. Null if the attribute is not loaded before * @return mixed the old attribute value. Null if the attribute is not loaded before
* or does not exist. * or does not exist.
* @see hasAttribute * @see hasAttribute()
*/ */
public function getOldAttribute($name) public function getOldAttribute($name)
{ {
@ -637,7 +637,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name * @param string $name the attribute name
* @param mixed $value the old attribute value. * @param mixed $value the old attribute value.
* @throws InvalidParamException if the named attribute does not exist. * @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute * @see hasAttribute()
*/ */
public function setOldAttribute($name, $value) public function setOldAttribute($name, $value)
{ {
@ -1030,7 +1030,7 @@ class ActiveRecord extends Model
/** /**
* Sets the value indicating whether the record is new. * Sets the value indicating whether the record is new.
* @param boolean $value whether the record is new and should be inserted when calling [[save()]]. * @param boolean $value whether the record is new and should be inserted when calling [[save()]].
* @see getIsNewRecord * @see getIsNewRecord()
*/ */
public function setIsNewRecord($value) public function setIsNewRecord($value)
{ {
@ -1321,9 +1321,9 @@ class ActiveRecord extends Model
throw new InvalidCallException('Unable to link models: both models must NOT be newly created.'); throw new InvalidCallException('Unable to link models: both models must NOT be newly created.');
} }
if (is_array($relation->via)) { if (is_array($relation->via)) {
/** @var $viaRelation ActiveRelation */ /** @var ActiveRelation $viaRelation */
list($viaName, $viaRelation) = $relation->via; list($viaName, $viaRelation) = $relation->via;
/** @var $viaClass ActiveRecord */ /** @var ActiveRecord $viaClass */
$viaClass = $viaRelation->modelClass; $viaClass = $viaRelation->modelClass;
$viaTable = $viaClass::tableName(); $viaTable = $viaClass::tableName();
// unset $viaName so that it can be reloaded to reflect the change // unset $viaName so that it can be reloaded to reflect the change
@ -1396,9 +1396,9 @@ class ActiveRecord extends Model
if ($relation->via !== null) { if ($relation->via !== null) {
if (is_array($relation->via)) { if (is_array($relation->via)) {
/** @var $viaRelation ActiveRelation */ /** @var ActiveRelation $viaRelation */
list($viaName, $viaRelation) = $relation->via; list($viaName, $viaRelation) = $relation->via;
/** @var $viaClass ActiveRecord */ /** @var ActiveRecord $viaClass */
$viaClass = $viaRelation->modelClass; $viaClass = $viaRelation->modelClass;
$viaTable = $viaClass::tableName(); $viaTable = $viaClass::tableName();
unset($this->_related[$viaName]); unset($this->_related[$viaName]);
@ -1444,7 +1444,7 @@ class ActiveRecord extends Model
if (!$relation->multiple) { if (!$relation->multiple) {
unset($this->_related[$name]); unset($this->_related[$name]);
} elseif (isset($this->_related[$name])) { } elseif (isset($this->_related[$name])) {
/** @var $b ActiveRecord */ /** @var ActiveRecord $b */
foreach ($this->_related[$name] as $a => $b) { foreach ($this->_related[$name] as $a => $b) {
if ($model->getPrimaryKey() == $b->getPrimaryKey()) { if ($model->getPrimaryKey() == $b->getPrimaryKey()) {
unset($this->_related[$name][$a]); unset($this->_related[$name][$a]);

12
framework/yii/db/ActiveRelation.php

@ -55,9 +55,11 @@ class ActiveRelation extends ActiveQuery
*/ */
public function __clone() public function __clone()
{ {
// make a clone of "via" object so that the same query object can be reused multiple times
if (is_object($this->via)) { if (is_object($this->via)) {
// make a clone of "via" object so that the same query object can be reused multiple times
$this->via = clone $this->via; $this->via = clone $this->via;
} elseif (is_array($this->via)) {
$this->via = [$this->via[0], clone $this->via[1]];
} }
} }
@ -120,7 +122,7 @@ class ActiveRelation extends ActiveQuery
$this->filterByModels($viaModels); $this->filterByModels($viaModels);
} elseif (is_array($this->via)) { } elseif (is_array($this->via)) {
// via relation // via relation
/** @var $viaQuery ActiveRelation */ /** @var ActiveRelation $viaQuery */
list($viaName, $viaQuery) = $this->via; list($viaName, $viaQuery) = $this->via;
if ($viaQuery->multiple) { if ($viaQuery->multiple) {
$viaModels = $viaQuery->all(); $viaModels = $viaQuery->all();
@ -154,13 +156,13 @@ class ActiveRelation extends ActiveQuery
if ($this->via instanceof self) { if ($this->via instanceof self) {
// via pivot table // via pivot table
/** @var $viaQuery ActiveRelation */ /** @var ActiveRelation $viaQuery */
$viaQuery = $this->via; $viaQuery = $this->via;
$viaModels = $viaQuery->findPivotRows($primaryModels); $viaModels = $viaQuery->findPivotRows($primaryModels);
$this->filterByModels($viaModels); $this->filterByModels($viaModels);
} elseif (is_array($this->via)) { } elseif (is_array($this->via)) {
// via relation // via relation
/** @var $viaQuery ActiveRelation */ /** @var ActiveRelation $viaQuery */
list($viaName, $viaQuery) = $this->via; list($viaName, $viaQuery) = $this->via;
$viaQuery->primaryModel = null; $viaQuery->primaryModel = null;
$viaModels = $viaQuery->findWith($viaName, $primaryModels); $viaModels = $viaQuery->findWith($viaName, $primaryModels);
@ -306,7 +308,7 @@ class ActiveRelation extends ActiveQuery
return []; return [];
} }
$this->filterByModels($primaryModels); $this->filterByModels($primaryModels);
/** @var $primaryModel ActiveRecord */ /** @var ActiveRecord $primaryModel */
$primaryModel = reset($primaryModels); $primaryModel = reset($primaryModels);
$db = $primaryModel->getDb(); $db = $primaryModel->getDb();
list ($sql, $params) = $db->getQueryBuilder()->build($this); list ($sql, $params) = $db->getQueryBuilder()->build($this);

2
framework/yii/db/Command.php

@ -366,7 +366,7 @@ class Command extends \yii\base\Component
Yii::info($rawSql, __METHOD__); Yii::info($rawSql, __METHOD__);
/** @var $cache \yii\caching\Cache */ /** @var \yii\caching\Cache $cache */
if ($db->enableQueryCache && $method !== '') { if ($db->enableQueryCache && $method !== '') {
$cache = is_string($db->queryCache) ? Yii::$app->getComponent($db->queryCache) : $db->queryCache; $cache = is_string($db->queryCache) ? Yii::$app->getComponent($db->queryCache) : $db->queryCache;
} }

4
framework/yii/db/Query.php

@ -39,12 +39,12 @@ class Query extends Component
{ {
/** /**
* Sort ascending * Sort ascending
* @see orderBy * @see orderBy()
*/ */
const SORT_ASC = false; const SORT_ASC = false;
/** /**
* Sort descending * Sort descending
* @see orderBy * @see orderBy()
*/ */
const SORT_DESC = true; const SORT_DESC = true;

8
framework/yii/db/Schema.php

@ -92,7 +92,7 @@ abstract class Schema extends Object
$realName = $this->getRawTableName($name); $realName = $this->getRawTableName($name);
if ($db->enableSchemaCache && !in_array($name, $db->schemaCacheExclude, true)) { if ($db->enableSchemaCache && !in_array($name, $db->schemaCacheExclude, true)) {
/** @var $cache Cache */ /** @var Cache $cache */
$cache = is_string($db->schemaCache) ? Yii::$app->getComponent($db->schemaCache) : $db->schemaCache; $cache = is_string($db->schemaCache) ? Yii::$app->getComponent($db->schemaCache) : $db->schemaCache;
if ($cache instanceof Cache) { if ($cache instanceof Cache) {
$key = $this->getCacheKey($name); $key = $this->getCacheKey($name);
@ -215,7 +215,7 @@ abstract class Schema extends Object
*/ */
public function refresh() public function refresh()
{ {
/** @var $cache Cache */ /** @var Cache $cache */
$cache = is_string($this->db->schemaCache) ? Yii::$app->getComponent($this->db->schemaCache) : $this->db->schemaCache; $cache = is_string($this->db->schemaCache) ? Yii::$app->getComponent($this->db->schemaCache) : $this->db->schemaCache;
if ($this->db->enableSchemaCache && $cache instanceof Cache) { if ($this->db->enableSchemaCache && $cache instanceof Cache) {
GroupDependency::invalidate($cache, $this->getCacheGroup()); GroupDependency::invalidate($cache, $this->getCacheGroup());
@ -291,7 +291,7 @@ abstract class Schema extends Object
* then this method will do nothing. * then this method will do nothing.
* @param string $name table name * @param string $name table name
* @return string the properly quoted table name * @return string the properly quoted table name
* @see quoteSimpleTableName * @see quoteSimpleTableName()
*/ */
public function quoteTableName($name) public function quoteTableName($name)
{ {
@ -316,7 +316,7 @@ abstract class Schema extends Object
* then this method will do nothing. * then this method will do nothing.
* @param string $name column name * @param string $name column name
* @return string the properly quoted column name * @return string the properly quoted column name
* @see quoteSimpleColumnName * @see quoteSimpleColumnName()
*/ */
public function quoteColumnName($name) public function quoteColumnName($name)
{ {

2
framework/yii/grid/ActionColumn.php

@ -12,6 +12,8 @@ use Closure;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* ActionColumn is a column for the [[GridView]] widget that displays buttons for viewing and manipulating the items.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

4
framework/yii/grid/DataColumn.php

@ -15,6 +15,10 @@ use yii\helpers\Html;
use yii\helpers\Inflector; use yii\helpers\Inflector;
/** /**
* DataColumn is the default column type for the [[GridView]] widget.
*
* It is used to show data columns and allows sorting them.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

4
framework/yii/grid/GridView.php

@ -16,6 +16,10 @@ use yii\helpers\Json;
use yii\widgets\BaseListView; use yii\widgets\BaseListView;
/** /**
* The GridView widget is used to display data in a grid.
*
* It provides features like sorting, paging and also filtering the data.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

1
framework/yii/grid/GridViewAsset.php

@ -10,6 +10,7 @@ namespace yii\grid;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
* This asset bundle provides the javascript files for the [[GridView]] widget.
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0

26
framework/yii/helpers/BaseHtml.php

@ -86,7 +86,7 @@ class BaseHtml
* @param boolean $doubleEncode whether to encode HTML entities in `$content`. If false, * @param boolean $doubleEncode whether to encode HTML entities in `$content`. If false,
* HTML entities in `$content` will not be further encoded. * HTML entities in `$content` will not be further encoded.
* @return string the encoded content * @return string the encoded content
* @see decode * @see decode()
* @see http://www.php.net/manual/en/function.htmlspecialchars.php * @see http://www.php.net/manual/en/function.htmlspecialchars.php
*/ */
public static function encode($content, $doubleEncode = true) public static function encode($content, $doubleEncode = true)
@ -99,7 +99,7 @@ class BaseHtml
* This is the opposite of [[encode()]]. * This is the opposite of [[encode()]].
* @param string $content the content to be decoded * @param string $content the content to be decoded
* @return string the decoded content * @return string the decoded content
* @see encode * @see encode()
* @see http://www.php.net/manual/en/function.htmlspecialchars-decode.php * @see http://www.php.net/manual/en/function.htmlspecialchars-decode.php
*/ */
public static function decode($content) public static function decode($content)
@ -116,8 +116,8 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated HTML tag * @return string the generated HTML tag
* @see beginTag * @see beginTag()
* @see endTag * @see endTag()
*/ */
public static function tag($name, $content = '', $options = []) public static function tag($name, $content = '', $options = [])
{ {
@ -132,8 +132,8 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated start tag * @return string the generated start tag
* @see endTag * @see endTag()
* @see tag * @see tag()
*/ */
public static function beginTag($name, $options = []) public static function beginTag($name, $options = [])
{ {
@ -144,8 +144,8 @@ class BaseHtml
* Generates an end tag. * Generates an end tag.
* @param string $name the tag name * @param string $name the tag name
* @return string the generated end tag * @return string the generated end tag
* @see beginTag * @see beginTag()
* @see tag * @see tag()
*/ */
public static function endTag($name) public static function endTag($name)
{ {
@ -187,7 +187,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated link tag * @return string the generated link tag
* @see url * @see url()
*/ */
public static function cssFile($url, $options = []) public static function cssFile($url, $options = [])
{ {
@ -203,7 +203,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated script tag * @return string the generated script tag
* @see url * @see url()
*/ */
public static function jsFile($url, $options = []) public static function jsFile($url, $options = [])
{ {
@ -222,7 +222,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated form start tag. * @return string the generated form start tag.
* @see endForm * @see endForm()
*/ */
public static function beginForm($action = '', $method = 'post', $options = []) public static function beginForm($action = '', $method = 'post', $options = [])
{ {
@ -271,7 +271,7 @@ class BaseHtml
/** /**
* Generates a form end tag. * Generates a form end tag.
* @return string the generated tag * @return string the generated tag
* @see beginForm * @see beginForm()
*/ */
public static function endForm() public static function endForm()
{ {
@ -290,7 +290,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered. * If a value is null, the corresponding attribute will not be rendered.
* @return string the generated hyperlink * @return string the generated hyperlink
* @see url * @see url()
*/ */
public static function a($text, $url = null, $options = []) public static function a($text, $url = null, $options = [])
{ {

2
framework/yii/helpers/BaseInflector.php

@ -328,7 +328,7 @@ class BaseInflector
* Converts a word like "send_email" to "SendEmail". It * Converts a word like "send_email" to "SendEmail". It
* will remove non alphanumeric character from the word, so * will remove non alphanumeric character from the word, so
* "who's online" will be converted to "WhoSOnline" * "who's online" will be converted to "WhoSOnline"
* @see variablize * @see variablize()
* @param string $word the word to CamelCase * @param string $word the word to CamelCase
* @return string * @return string
*/ */

9
framework/yii/i18n/Formatter.php

@ -19,6 +19,15 @@ use yii\base\InvalidConfigException;
* Formatter requires the PHP "intl" extension to be installed. Formatter supports localized * Formatter requires the PHP "intl" extension to be installed. Formatter supports localized
* formatting of date, time and numbers, based on the current [[locale]]. * formatting of date, time and numbers, based on the current [[locale]].
* *
* This Formatter can replace the `formatter` application component that is configured by default.
* To do so, add the following to your application config under `components`:
*
* ```php
* 'formatter' => [
* 'class' => 'yii\i18n\Formatter',
* ]
* ```
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

3
framework/yii/i18n/I18N.php

@ -14,6 +14,9 @@ use yii\base\InvalidConfigException;
/** /**
* I18N provides features related with internationalization (I18N) and localization (L10N). * I18N provides features related with internationalization (I18N) and localization (L10N).
* *
* I18N is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->i18n`.
*
* @property MessageFormatter $messageFormatter The message formatter to be used to format message via ICU * @property MessageFormatter $messageFormatter The message formatter to be used to format message via ICU
* message format. Note that the type of this property differs in getter and setter. See * message format. Note that the type of this property differs in getter and setter. See
* [[getMessageFormatter()]] and [[setMessageFormatter()]] for details. * [[getMessageFormatter()]] and [[setMessageFormatter()]] for details.

2
framework/yii/log/Target.php

@ -112,7 +112,7 @@ abstract class Target extends Component
{ {
$context = []; $context = [];
if ($this->logUser && ($user = Yii::$app->getComponent('user', false)) !== null) { if ($this->logUser && ($user = Yii::$app->getComponent('user', false)) !== null) {
/** @var $user \yii\web\User */ /** @var \yii\web\User $user */
$context[] = 'User: ' . $user->getId(); $context[] = 'User: ' . $user->getId();
} }

2
framework/yii/mail/BaseMailer.php

@ -281,7 +281,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
$file = $path . '/' . call_user_func($this->fileTransportCallback, $this, $message); $file = $path . '/' . call_user_func($this->fileTransportCallback, $this, $message);
} else { } else {
$time = microtime(true); $time = microtime(true);
$file = $path . '/' . date('Ymd-His-', $time) . sprintf('%04d', (int)(($time - (int)$time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.txt'; $file = $path . '/' . date('Ymd-His-', $time) . sprintf('%04d', (int)(($time - (int)$time) * 10000)) . '-' . sprintf('%04d', mt_rand(0, 10000)) . '.eml';
} }
file_put_contents($file, $message->toString()); file_put_contents($file, $message->toString());
return true; return true;

28
framework/yii/rbac/PhpManager.php

@ -36,8 +36,8 @@ class PhpManager extends Manager
* If not set, it will be using 'protected/data/rbac.php' as the data file. * If not set, it will be using 'protected/data/rbac.php' as the data file.
* Make sure this file is writable by the Web server process if the authorization * Make sure this file is writable by the Web server process if the authorization
* needs to be changed. * needs to be changed.
* @see loadFromFile * @see loadFromFile()
* @see saveToFile * @see saveToFile()
*/ */
public $authFile; public $authFile;
@ -74,7 +74,7 @@ class PhpManager extends Manager
if (!isset($this->_items[$itemName])) { if (!isset($this->_items[$itemName])) {
return false; return false;
} }
/** @var $item Item */ /** @var Item $item */
$item = $this->_items[$itemName]; $item = $this->_items[$itemName];
Yii::trace('Checking permission: ' . $item->getName(), __METHOD__); Yii::trace('Checking permission: ' . $item->getName(), __METHOD__);
if (!isset($params['userId'])) { if (!isset($params['userId'])) {
@ -85,7 +85,7 @@ class PhpManager extends Manager
return true; return true;
} }
if (isset($this->_assignments[$userId][$itemName])) { if (isset($this->_assignments[$userId][$itemName])) {
/** @var $assignment Assignment */ /** @var Assignment $assignment */
$assignment = $this->_assignments[$userId][$itemName]; $assignment = $this->_assignments[$userId][$itemName];
if ($this->executeBizRule($assignment->bizRule, $params, $assignment->data)) { if ($this->executeBizRule($assignment->bizRule, $params, $assignment->data)) {
return true; return true;
@ -113,9 +113,9 @@ class PhpManager extends Manager
if (!isset($this->_items[$childName], $this->_items[$itemName])) { if (!isset($this->_items[$childName], $this->_items[$itemName])) {
throw new Exception("Either '$itemName' or '$childName' does not exist."); throw new Exception("Either '$itemName' or '$childName' does not exist.");
} }
/** @var $child Item */ /** @var Item $child */
$child = $this->_items[$childName]; $child = $this->_items[$childName];
/** @var $item Item */ /** @var Item $item */
$item = $this->_items[$itemName]; $item = $this->_items[$itemName];
$this->checkItemChildType($item->type, $child->type); $this->checkItemChildType($item->type, $child->type);
if ($this->detectLoop($itemName, $childName)) { if ($this->detectLoop($itemName, $childName)) {
@ -270,14 +270,14 @@ class PhpManager extends Manager
$items = []; $items = [];
if ($userId === null) { if ($userId === null) {
foreach ($this->_items as $name => $item) { foreach ($this->_items as $name => $item) {
/** @var $item Item */ /** @var Item $item */
if ($item->type == $type) { if ($item->type == $type) {
$items[$name] = $item; $items[$name] = $item;
} }
} }
} elseif (isset($this->_assignments[$userId])) { } elseif (isset($this->_assignments[$userId])) {
foreach ($this->_assignments[$userId] as $assignment) { foreach ($this->_assignments[$userId] as $assignment) {
/** @var $assignment Assignment */ /** @var Assignment $assignment */
$name = $assignment->itemName; $name = $assignment->itemName;
if (isset($this->_items[$name]) && ($type === null || $this->_items[$name]->type == $type)) { if (isset($this->_items[$name]) && ($type === null || $this->_items[$name]->type == $type)) {
$items[$name] = $this->_items[$name]; $items[$name] = $this->_items[$name];
@ -400,7 +400,7 @@ class PhpManager extends Manager
{ {
$items = []; $items = [];
foreach ($this->_items as $name => $item) { foreach ($this->_items as $name => $item) {
/** @var $item Item */ /** @var Item $item */
$items[$name] = [ $items[$name] = [
'type' => $item->type, 'type' => $item->type,
'description' => $item->description, 'description' => $item->description,
@ -409,7 +409,7 @@ class PhpManager extends Manager
]; ];
if (isset($this->_children[$name])) { if (isset($this->_children[$name])) {
foreach ($this->_children[$name] as $child) { foreach ($this->_children[$name] as $child) {
/** @var $child Item */ /** @var Item $child */
$items[$name]['children'][] = $child->getName(); $items[$name]['children'][] = $child->getName();
} }
} }
@ -417,7 +417,7 @@ class PhpManager extends Manager
foreach ($this->_assignments as $userId => $assignments) { foreach ($this->_assignments as $userId => $assignments) {
foreach ($assignments as $name => $assignment) { foreach ($assignments as $name => $assignment) {
/** @var $assignment Assignment */ /** @var Assignment $assignment */
if (isset($items[$name])) { if (isset($items[$name])) {
$items[$name]['assignments'][$userId] = [ $items[$name]['assignments'][$userId] = [
'bizRule' => $assignment->bizRule, 'bizRule' => $assignment->bizRule,
@ -505,7 +505,7 @@ class PhpManager extends Manager
return false; return false;
} }
foreach ($this->_children[$childName] as $child) { foreach ($this->_children[$childName] as $child) {
/** @var $child Item */ /** @var Item $child */
if ($this->detectLoop($itemName, $child->getName())) { if ($this->detectLoop($itemName, $child->getName())) {
return true; return true;
} }
@ -517,7 +517,7 @@ class PhpManager extends Manager
* Loads the authorization data from a PHP script file. * Loads the authorization data from a PHP script file.
* @param string $file the file path. * @param string $file the file path.
* @return array the authorization data * @return array the authorization data
* @see saveToFile * @see saveToFile()
*/ */
protected function loadFromFile($file) protected function loadFromFile($file)
{ {
@ -532,7 +532,7 @@ class PhpManager extends Manager
* Saves the authorization data to a PHP script file. * Saves the authorization data to a PHP script file.
* @param array $data the authorization data * @param array $data the authorization data
* @param string $file the file path. * @param string $file the file path.
* @see loadFromFile * @see loadFromFile()
*/ */
protected function saveToFile($data, $file) protected function saveToFile($data, $file)
{ {

2
framework/yii/requirements/requirements.php

@ -3,7 +3,7 @@
* These are the Yii core requirements for the [[YiiRequirementChecker]] instance. * These are the Yii core requirements for the [[YiiRequirementChecker]] instance.
* These requirements are mandatory for any Yii application. * These requirements are mandatory for any Yii application.
* *
* @var $this YiiRequirementChecker * @var YiiRequirementChecker $this
*/ */
return array( return array(
array( array(

6
framework/yii/requirements/views/console/index.php

@ -1,7 +1,7 @@
<?php <?php
/* @var $this YiiRequirementChecker */ /* @var YiiRequirementChecker $this */
/* @var $summary array */ /* @var array $summary */
/* @var $requirements array[] */ /* @var array[] $requirements */
echo "\nYii Application Requirement Checker\n\n"; echo "\nYii Application Requirement Checker\n\n";

6
framework/yii/requirements/views/web/index.php

@ -1,7 +1,7 @@
<?php <?php
/* @var $this YiiRequirementChecker */ /* @var YiiRequirementChecker $this */
/* @var $summary array */ /* @var array $summary */
/* @var $requirements array[] */ /* @var array[] $requirements */
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

4
framework/yii/validators/ExistValidator.php

@ -65,7 +65,7 @@ class ExistValidator extends Validator
return; return;
} }
/** @var $className \yii\db\ActiveRecord */ /** @var \yii\db\ActiveRecord $className */
$className = $this->className === null ? get_class($object) : $this->className; $className = $this->className === null ? get_class($object) : $this->className;
$attributeName = $this->attributeName === null ? $attribute : $this->attributeName; $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;
$query = $className::find(); $query = $className::find();
@ -92,7 +92,7 @@ class ExistValidator extends Validator
if ($this->attributeName === null) { if ($this->attributeName === null) {
throw new InvalidConfigException('The "attributeName" property must be set.'); throw new InvalidConfigException('The "attributeName" property must be set.');
} }
/** @var $className \yii\db\ActiveRecord */ /** @var \yii\db\ActiveRecord $className */
$className = $this->className; $className = $this->className;
$query = $className::find(); $query = $className::find();
$query->where([$this->attributeName => $value]); $query->where([$this->attributeName => $value]);

2
framework/yii/validators/PunycodeAsset.php

@ -9,6 +9,8 @@ namespace yii\validators;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
* This asset bundle provides the javascript files needed for the [[EmailValidator]]s client validation.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/validators/UniqueValidator.php

@ -60,7 +60,7 @@ class UniqueValidator extends Validator
return; return;
} }
/** @var $className \yii\db\ActiveRecord */ /** @var \yii\db\ActiveRecord $className */
$className = $this->className === null ? get_class($object) : $this->className; $className = $this->className === null ? get_class($object) : $this->className;
$attributeName = $this->attributeName === null ? $attribute : $this->attributeName; $attributeName = $this->attributeName === null ? $attribute : $this->attributeName;

2
framework/yii/validators/ValidationAsset.php

@ -9,6 +9,8 @@ namespace yii\validators;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
* This asset bundle provides the javascript files for client validation.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/web/AccessControl.php

@ -102,7 +102,7 @@ class AccessControl extends ActionFilter
{ {
$user = Yii::$app->getUser(); $user = Yii::$app->getUser();
$request = Yii::$app->getRequest(); $request = Yii::$app->getRequest();
/** @var $rule AccessRule */ /** @var AccessRule $rule */
foreach ($this->rules as $rule) { foreach ($this->rules as $rule) {
if ($allow = $rule->allows($action, $user, $request)) { if ($allow = $rule->allows($action, $user, $request)) {
return true; return true;

4
framework/yii/web/AssetConverter.php

@ -14,6 +14,8 @@ use yii\base\Exception;
/** /**
* AssetConverter supports conversion of several popular script formats into JS or CSS scripts. * AssetConverter supports conversion of several popular script formats into JS or CSS scripts.
* *
* It is used by [[AssetManager]] to convert files after they have been published.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
@ -63,6 +65,8 @@ class AssetConverter extends Component implements AssetConverterInterface
* @param string $asset the name of the asset file * @param string $asset the name of the asset file
* @param string $result the name of the file to be generated by the converter command * @param string $result the name of the file to be generated by the converter command
* @return bool true on success, false on failure. Failures will be logged. * @return bool true on success, false on failure. Failures will be logged.
* @throws \yii\base\Exception when the command fails and YII_DEBUG is true.
* In production mode the error will be logged.
*/ */
protected function runCommand($command, $basePath, $asset, $result) protected function runCommand($command, $basePath, $asset, $result)
{ {

16
framework/yii/web/AssetManager.php

@ -16,6 +16,22 @@ use yii\helpers\FileHelper;
/** /**
* AssetManager manages asset bundles and asset publishing. * AssetManager manages asset bundles and asset publishing.
* *
* AssetManager is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->assetManager`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'assetManager' => [
* 'bundles' => [
* // you can override AssetBundle configs here
* ],
* //'linkAssets' => true,
* // ...
* ]
* ~~~
*
* @property AssetConverterInterface $converter The asset converter. Note that the type of this property * @property AssetConverterInterface $converter The asset converter. Note that the type of this property
* differs in getter and setter. See [[getConverter()]] and [[setConverter()]] for details. * differs in getter and setter. See [[getConverter()]] and [[setConverter()]] for details.
* *

12
framework/yii/web/CacheSession.php

@ -19,7 +19,17 @@ use yii\base\InvalidConfigException;
* *
* Beware, by definition cache storage are volatile, which means the data stored on them * Beware, by definition cache storage are volatile, which means the data stored on them
* may be swapped out and get lost. Therefore, you must make sure the cache used by this component * may be swapped out and get lost. Therefore, you must make sure the cache used by this component
* is NOT volatile. If you want to use database as storage medium, use [[DbSession]] is a better choice. * is NOT volatile. If you want to use database as storage medium, [[DbSession]] is a better choice.
*
* The following example shows how you can configure the application to use CacheSession:
* Add the following to your application config under `components`:
*
* ~~~
* 'session' => [
* 'class' => 'yii\web\CacheSession',
* // 'cache' => 'mycache',
* ]
* ~~~
* *
* @property boolean $useCustomStorage Whether to use custom storage. This property is read-only. * @property boolean $useCustomStorage Whether to use custom storage. This property is read-only.
* *

31
framework/yii/web/Controller.php

@ -150,6 +150,13 @@ class Controller extends \yii\base\Controller
* Redirects the browser to the specified URL. * Redirects the browser to the specified URL.
* This method is a shortcut to [[Response::redirect()]]. * This method is a shortcut to [[Response::redirect()]].
* *
* You can use it in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to login page
* return $this->redirect(['login']);
* ```
*
* @param string|array $url the URL to be redirected to. This can be in one of the following formats: * @param string|array $url the URL to be redirected to. This can be in one of the following formats:
* *
* - a string representing a URL (e.g. "http://example.com") * - a string representing a URL (e.g. "http://example.com")
@ -172,6 +179,14 @@ class Controller extends \yii\base\Controller
/** /**
* Redirects the browser to the home page. * Redirects the browser to the home page.
*
* You can use this method in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to home page
* return $this->goHome();
* ```
*
* @return Response the current response object * @return Response the current response object
*/ */
public function goHome() public function goHome()
@ -181,6 +196,14 @@ class Controller extends \yii\base\Controller
/** /**
* Redirects the browser to the last visited page. * Redirects the browser to the last visited page.
*
* You can use this method in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to last visited page
* return $this->goBack();
* ```
*
* @param string|array $defaultUrl the default return URL in case it was not set previously. * @param string|array $defaultUrl the default return URL in case it was not set previously.
* If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to. * If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to.
* Please refer to [[User::setReturnUrl()]] on accepted format of the URL. * Please refer to [[User::setReturnUrl()]] on accepted format of the URL.
@ -195,6 +218,14 @@ class Controller extends \yii\base\Controller
/** /**
* Refreshes the current page. * Refreshes the current page.
* This method is a shortcut to [[Response::refresh()]]. * This method is a shortcut to [[Response::refresh()]].
*
* You can use it in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and refresh the current page
* return $this->refresh();
* ```
*
* @param string $anchor the anchor that should be appended to the redirection URL. * @param string $anchor the anchor that should be appended to the redirection URL.
* Defaults to empty. Make sure the anchor starts with '#' if you want to specify it. * Defaults to empty. Make sure the anchor starts with '#' if you want to specify it.
* @return Response the response object itself * @return Response the response object itself

1
framework/yii/web/DbSession.php

@ -19,6 +19,7 @@ use yii\base\InvalidConfigException;
* must be pre-created. The table name can be changed by setting [[sessionTable]]. * must be pre-created. The table name can be changed by setting [[sessionTable]].
* *
* The following example shows how you can configure the application to use DbSession: * The following example shows how you can configure the application to use DbSession:
* Add the following to your application config under `components`:
* *
* ~~~ * ~~~
* 'session' => [ * 'session' => [

27
framework/yii/web/HttpCache.php

@ -12,7 +12,32 @@ use yii\base\ActionFilter;
use yii\base\Action; use yii\base\Action;
/** /**
* The HttpCache provides functionality for caching via HTTP Last-Modified and Etag headers * The HttpCache provides functionality for caching via HTTP Last-Modified and Etag headers.
*
* It is an action filter that can be added to a controller and handles the `beforeAction` event.
*
* To use AccessControl, declare it in the `behaviors()` method of your controller class.
* In the following example the filter will be applied to the `list`-action and
* the Last-Modified header will contain the date of the last update to the user table in the database.
*
* ~~~
* public function behaviors()
* {
* return [
* 'httpCache' => [
* 'class' => \yii\web\HttpCache::className(),
* 'only' => ['list'],
* 'lastModified' => function ($action, $params) {
* $q = new Query();
* return strtotime($q->from('users')->max('updated_timestamp'));
* },
* // 'etagSeed' => function ($action, $params) {
* // return // generate etag seed here
* // }
* ],
* ];
* }
* ~~~
* *
* @author Da:Sourcerer <webmaster@dasourcerer.net> * @author Da:Sourcerer <webmaster@dasourcerer.net>
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>

8
framework/yii/web/HttpException.php

@ -16,6 +16,14 @@ use yii\base\UserException;
* keeps a standard HTTP status code (e.g. 404, 500). Error handlers may use this status code * keeps a standard HTTP status code (e.g. 404, 500). Error handlers may use this status code
* to decide how to format the error page. * to decide how to format the error page.
* *
* Throwing an HttpException like in the following example will result in the 404 page to be displayed.
*
* ```php
* if ($item === null) { // item does not exist
* throw new \yii\web\HttpException(404, 'The requested Item could not be found.');
* }
* ```
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

30
framework/yii/web/PageCache.php

@ -15,6 +15,35 @@ use yii\caching\Dependency;
/** /**
* The PageCache provides functionality for whole page caching * The PageCache provides functionality for whole page caching
* *
* It is an action filter that can be added to a controller and handles the `beforeAction` event.
*
* To use PageCache, declare it in the `behaviors()` method of your controller class.
* In the following example the filter will be applied to the `list`-action and
* cache the whole page for maximum 60 seconds or until the count of entries in the post table changes.
* It also stores different versions of the page depended on the route ([[varyByRoute]] is true by default),
* the application language and user id.
*
* ~~~
* public function behaviors()
* {
* return [
* 'pageCache' => [
* 'class' => \yii\web\PageCache::className(),
* 'only' => ['list'],
* 'duration' => 60,
* 'dependecy' => [
* 'class' => 'yii\caching\DbDependency',
* 'sql' => 'SELECT COUNT(*) FROM post',
* ],
* 'variations' => [
* Yii::$app->language,
* Yii::$app->user->id
* ]
* ],
* ];
* }
* ~~~
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */
@ -60,6 +89,7 @@ class PageCache extends ActionFilter
* [ * [
* Yii::$app->language, * Yii::$app->language,
* ] * ]
* ~~~
*/ */
public $variations; public $variations;
/** /**

21
framework/yii/web/Request.php

@ -18,6 +18,9 @@ use yii\helpers\Security;
* Also it provides an interface to retrieve request parameters from $_POST, $_GET, $_COOKIES and REST * Also it provides an interface to retrieve request parameters from $_POST, $_GET, $_COOKIES and REST
* parameters sent via other HTTP methods like PUT or DELETE. * parameters sent via other HTTP methods like PUT or DELETE.
* *
* Request is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->request`.
*
* @property string $absoluteUrl The currently requested absolute URL. This property is read-only. * @property string $absoluteUrl The currently requested absolute URL. This property is read-only.
* @property string $acceptTypes User browser accept types, null if not present. This property is read-only. * @property string $acceptTypes User browser accept types, null if not present. This property is read-only.
* @property array $acceptedContentTypes The content types ordered by the preference level. The first element * @property array $acceptedContentTypes The content types ordered by the preference level. The first element
@ -116,8 +119,8 @@ class Request extends \yii\base\Request
/** /**
* @var string|boolean the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE * @var string|boolean the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE
* request tunneled through POST. Default to '_method'. * request tunneled through POST. Default to '_method'.
* @see getMethod * @see getMethod()
* @see getRestParams * @see getRestParams()
*/ */
public $restVar = '_method'; public $restVar = '_method';
@ -242,7 +245,7 @@ class Request extends \yii\base\Request
/** /**
* Returns the request parameters for the RESTful request. * Returns the request parameters for the RESTful request.
* @return array the RESTful request parameters * @return array the RESTful request parameters
* @see getMethod * @see getMethod()
*/ */
public function getRestParams() public function getRestParams()
{ {
@ -298,7 +301,7 @@ class Request extends \yii\base\Request
* @param string $name the GET parameter name. If not specified, whole $_GET is returned. * @param string $name the GET parameter name. If not specified, whole $_GET is returned.
* @param mixed $defaultValue the default parameter value if the GET parameter does not exist. * @param mixed $defaultValue the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value * @return mixed the GET parameter value
* @see getPost * @see getPost()
*/ */
public function get($name = null, $defaultValue = null) public function get($name = null, $defaultValue = null)
{ {
@ -324,7 +327,7 @@ class Request extends \yii\base\Request
* @param mixed $defaultValue the default parameter value if the POST parameter does not exist. * @param mixed $defaultValue the default parameter value if the POST parameter does not exist.
* @property array the POST request parameter values * @property array the POST request parameter values
* @return mixed the POST parameter value * @return mixed the POST parameter value
* @see get * @see get()
*/ */
public function getPost($name = null, $defaultValue = null) public function getPost($name = null, $defaultValue = null)
{ {
@ -387,7 +390,7 @@ class Request extends \yii\base\Request
* By default this is determined based on the user request information. * By default this is determined based on the user request information.
* You may explicitly specify it by setting the [[setHostInfo()|hostInfo]] property. * You may explicitly specify it by setting the [[setHostInfo()|hostInfo]] property.
* @return string schema and hostname part (with port number if needed) of the request URL (e.g. `http://www.yiiframework.com`) * @return string schema and hostname part (with port number if needed) of the request URL (e.g. `http://www.yiiframework.com`)
* @see setHostInfo * @see setHostInfo()
*/ */
public function getHostInfo() public function getHostInfo()
{ {
@ -426,7 +429,7 @@ class Request extends \yii\base\Request
* This is similar to [[scriptUrl]] except that it does not include the script file name, * This is similar to [[scriptUrl]] except that it does not include the script file name,
* and the ending slashes are removed. * and the ending slashes are removed.
* @return string the relative URL for the application * @return string the relative URL for the application
* @see setScriptUrl * @see setScriptUrl()
*/ */
public function getBaseUrl() public function getBaseUrl()
{ {
@ -743,7 +746,7 @@ class Request extends \yii\base\Request
* Defaults to 80, or the port specified by the server if the current * Defaults to 80, or the port specified by the server if the current
* request is insecure. * request is insecure.
* @return integer port number for insecure requests. * @return integer port number for insecure requests.
* @see setPort * @see setPort()
*/ */
public function getPort() public function getPort()
{ {
@ -774,7 +777,7 @@ class Request extends \yii\base\Request
* Defaults to 443, or the port specified by the server if the current * Defaults to 443, or the port specified by the server if the current
* request is secure. * request is secure.
* @return integer port number for secure requests. * @return integer port number for secure requests.
* @see setSecurePort * @see setSecurePort()
*/ */
public function getSecurePort() public function getSecurePort()
{ {

14
framework/yii/web/Response.php

@ -22,6 +22,20 @@ use yii\helpers\StringHelper;
* It holds the [[headers]], [[cookies]] and [[content]] that is to be sent to the client. * It holds the [[headers]], [[cookies]] and [[content]] that is to be sent to the client.
* It also controls the HTTP [[statusCode|status code]]. * It also controls the HTTP [[statusCode|status code]].
* *
* Response is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->response`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'response' => [
* 'format' => yii\web\Response::FORMAT_JSON,
* 'charset' => 'UTF-8',
* // ...
* ]
* ~~~
*
* @property CookieCollection $cookies The cookie collection. This property is read-only. * @property CookieCollection $cookies The cookie collection. This property is read-only.
* @property HeaderCollection $headers The header collection. This property is read-only. * @property HeaderCollection $headers The header collection. This property is read-only.
* @property boolean $isClientError Whether this response indicates a client error. This property is * @property boolean $isClientError Whether this response indicates a client error. This property is

3
framework/yii/web/Session.php

@ -15,7 +15,7 @@ use yii\base\InvalidParamException;
* Session provides session data management and the related configurations. * Session provides session data management and the related configurations.
* *
* Session is a Web application component that can be accessed via `Yii::$app->session`. * Session is a Web application component that can be accessed via `Yii::$app->session`.
*
* To start the session, call [[open()]]; To complete and send out session data, call [[close()]]; * To start the session, call [[open()]]; To complete and send out session data, call [[close()]];
* To destroy the session, call [[destroy()]]. * To destroy the session, call [[destroy()]].
* *
@ -82,6 +82,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
public $flashVar = '__flash'; public $flashVar = '__flash';
/** /**
* @var array parameter-value pairs to override default session cookie parameters that are used for session_set_cookie_params() function * @var array parameter-value pairs to override default session cookie parameters that are used for session_set_cookie_params() function
* Array may have the following possible keys: 'lifetime', 'path', 'domain', 'secure', 'httpOnly'
* @see http://www.php.net/manual/en/function.session-set-cookie-params.php * @see http://www.php.net/manual/en/function.session-set-cookie-params.php
*/ */
private $_cookieParams = ['httpOnly' => true]; private $_cookieParams = ['httpOnly' => true];

2
framework/yii/web/UploadedFile.php

@ -74,7 +74,7 @@ class UploadedFile extends Object
* For example, '[1]file' for tabular file uploading; and 'file[1]' for an element in a file array. * For example, '[1]file' for tabular file uploading; and 'file[1]' for an element in a file array.
* @return UploadedFile the instance of the uploaded file. * @return UploadedFile the instance of the uploaded file.
* Null is returned if no file is uploaded for the specified model attribute. * Null is returned if no file is uploaded for the specified model attribute.
* @see getInstanceByName * @see getInstanceByName()
*/ */
public static function getInstance($model, $attribute) public static function getInstance($model, $attribute)
{ {

22
framework/yii/web/UrlManager.php

@ -14,6 +14,22 @@ use yii\caching\Cache;
/** /**
* UrlManager handles HTTP request parsing and creation of URLs based on a set of rules. * UrlManager handles HTTP request parsing and creation of URLs based on a set of rules.
* *
* UrlManager is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->urlManager`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'urlManager' => [
* 'enablePrettyUrl' => true,
* 'rules' => [
* // your rules go here
* ],
* // ...
* ]
* ~~~
*
* @property string $baseUrl The base URL that is used by [[createUrl()]] to prepend URLs it creates. * @property string $baseUrl The base URL that is used by [[createUrl()]] to prepend URLs it creates.
* @property string $hostInfo The host info (e.g. "http://www.example.com") that is used by * @property string $hostInfo The host info (e.g. "http://www.example.com") that is used by
* [[createAbsoluteUrl()]] to prepend URLs it creates. * [[createAbsoluteUrl()]] to prepend URLs it creates.
@ -169,7 +185,7 @@ class UrlManager extends Component
{ {
if ($this->enablePrettyUrl) { if ($this->enablePrettyUrl) {
$pathInfo = $request->getPathInfo(); $pathInfo = $request->getPathInfo();
/** @var $rule UrlRule */ /** @var UrlRule $rule */
foreach ($this->rules as $rule) { foreach ($this->rules as $rule) {
if (($result = $rule->parseRequest($this, $request)) !== false) { if (($result = $rule->parseRequest($this, $request)) !== false) {
Yii::trace("Request parsed with URL rule: {$rule->name}", __METHOD__); Yii::trace("Request parsed with URL rule: {$rule->name}", __METHOD__);
@ -224,7 +240,7 @@ class UrlManager extends Component
$baseUrl = $this->getBaseUrl(); $baseUrl = $this->getBaseUrl();
if ($this->enablePrettyUrl) { if ($this->enablePrettyUrl) {
/** @var $rule UrlRule */ /** @var UrlRule $rule */
foreach ($this->rules as $rule) { foreach ($this->rules as $rule) {
if (($url = $rule->createUrl($this, $route, $params)) !== false) { if (($url = $rule->createUrl($this, $route, $params)) !== false) {
if ($rule->host !== null) { if ($rule->host !== null) {
@ -282,7 +298,7 @@ class UrlManager extends Component
public function getBaseUrl() public function getBaseUrl()
{ {
if ($this->_baseUrl === null) { if ($this->_baseUrl === null) {
/** @var $request \yii\web\Request */ /** @var \yii\web\Request $request */
$request = Yii::$app->getRequest(); $request = Yii::$app->getRequest();
$this->_baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $request->getScriptUrl() : $request->getBaseUrl(); $this->_baseUrl = $this->showScriptName || !$this->enablePrettyUrl ? $request->getScriptUrl() : $request->getBaseUrl();
} }

12
framework/yii/web/UrlRule.php

@ -11,7 +11,17 @@ use yii\base\Object;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
/** /**
* UrlRule represents a rule used for parsing and generating URLs. * UrlRule represents a rule used by [[UrlManager]] for parsing and generating URLs.
*
* To define your own URL parsing and creation logic you can extend from this class
* and add it to [[UrlManager::rules]] like this:
*
* ~~~
* 'rules' => [
* ['class' => 'MyUrlRule', 'pattern' => '...', 'route' => 'site/index', ...],
* // ...
* ]
* ~~~
* *
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0

27
framework/yii/web/User.php

@ -20,6 +20,21 @@ use yii\base\InvalidConfigException;
* User works with a class implementing the [[IdentityInterface]]. This class implements * User works with a class implementing the [[IdentityInterface]]. This class implements
* the actual user authentication logic and is often backed by a user database table. * the actual user authentication logic and is often backed by a user database table.
* *
* User is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->user`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'user' => [
* 'identityClass' => 'app\models\User', // User must implement the IdentityInterface
* 'enableAutoLogin' => true,
* // 'loginUrl' => ['user/login'],
* // ...
* ]
* ~~~
*
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest. * @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
* This property is read-only. * This property is read-only.
* @property IdentityInterface $identity The identity object associated with the currently logged user. Null * @property IdentityInterface $identity The identity object associated with the currently logged user. Null
@ -129,8 +144,8 @@ class User extends Component
* Returns the identity object associated with the currently logged user. * Returns the identity object associated with the currently logged user.
* @return IdentityInterface the identity object associated with the currently logged user. * @return IdentityInterface the identity object associated with the currently logged user.
* Null is returned if the user is not logged in (not authenticated). * Null is returned if the user is not logged in (not authenticated).
* @see login * @see login()
* @see logout * @see logout()
*/ */
public function getIdentity() public function getIdentity()
{ {
@ -139,7 +154,7 @@ class User extends Component
if ($id === null) { if ($id === null) {
$this->_identity = null; $this->_identity = null;
} else { } else {
/** @var $class IdentityInterface */ /** @var IdentityInterface $class */
$class = $this->identityClass; $class = $this->identityClass;
$this->_identity = $class::findIdentity($id); $this->_identity = $class::findIdentity($id);
} }
@ -202,7 +217,7 @@ class User extends Component
$data = json_decode($value, true); $data = json_decode($value, true);
if (count($data) === 3 && isset($data[0], $data[1], $data[2])) { if (count($data) === 3 && isset($data[0], $data[1], $data[2])) {
list ($id, $authKey, $duration) = $data; list ($id, $authKey, $duration) = $data;
/** @var $class IdentityInterface */ /** @var IdentityInterface $class */
$class = $this->identityClass; $class = $this->identityClass;
$identity = $class::findIdentity($id); $identity = $class::findIdentity($id);
if ($identity !== null && $identity->validateAuthKey($authKey)) { if ($identity !== null && $identity->validateAuthKey($authKey)) {
@ -266,7 +281,7 @@ class User extends Component
* If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to. * If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to.
* Please refer to [[setReturnUrl()]] on accepted format of the URL. * Please refer to [[setReturnUrl()]] on accepted format of the URL.
* @return string the URL that the user should be redirected to after login. * @return string the URL that the user should be redirected to after login.
* @see loginRequired * @see loginRequired()
*/ */
public function getReturnUrl($defaultUrl = null) public function getReturnUrl($defaultUrl = null)
{ {
@ -413,7 +428,7 @@ class User extends Component
* information in the cookie. * information in the cookie.
* @param IdentityInterface $identity * @param IdentityInterface $identity
* @param integer $duration number of seconds that the user can remain in logged-in status. * @param integer $duration number of seconds that the user can remain in logged-in status.
* @see loginByCookie * @see loginByCookie()
*/ */
protected function sendIdentityCookie($identity, $duration) protected function sendIdentityCookie($identity, $duration)
{ {

30
framework/yii/web/View.php

@ -22,6 +22,22 @@ use yii\base\InvalidConfigException;
* *
* View provides a set of methods (e.g. [[render()]]) for rendering purpose. * View provides a set of methods (e.g. [[render()]]) for rendering purpose.
* *
* View is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->view`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'view' => [
* 'theme' => 'app\themes\MyTheme',
* 'renderers' => [
* // you may add Smarty or Twig renderer here
* ]
* // ...
* ]
* ~~~
*
* @property \yii\web\AssetManager $assetManager The asset manager. Defaults to the "assetManager" application * @property \yii\web\AssetManager $assetManager The asset manager. Defaults to the "assetManager" application
* component. * component.
* *
@ -72,7 +88,7 @@ class View extends \yii\base\View
/** /**
* @var AssetBundle[] list of the registered asset bundles. The keys are the bundle names, and the values * @var AssetBundle[] list of the registered asset bundles. The keys are the bundle names, and the values
* are the registered [[AssetBundle]] objects. * are the registered [[AssetBundle]] objects.
* @see registerAssetBundle * @see registerAssetBundle()
*/ */
public $assetBundles = []; public $assetBundles = [];
/** /**
@ -81,32 +97,32 @@ class View extends \yii\base\View
public $title; public $title;
/** /**
* @var array the registered meta tags. * @var array the registered meta tags.
* @see registerMetaTag * @see registerMetaTag()
*/ */
public $metaTags; public $metaTags;
/** /**
* @var array the registered link tags. * @var array the registered link tags.
* @see registerLinkTag * @see registerLinkTag()
*/ */
public $linkTags; public $linkTags;
/** /**
* @var array the registered CSS code blocks. * @var array the registered CSS code blocks.
* @see registerCss * @see registerCss()
*/ */
public $css; public $css;
/** /**
* @var array the registered CSS files. * @var array the registered CSS files.
* @see registerCssFile * @see registerCssFile()
*/ */
public $cssFiles; public $cssFiles;
/** /**
* @var array the registered JS code blocks * @var array the registered JS code blocks
* @see registerJs * @see registerJs()
*/ */
public $js; public $js;
/** /**
* @var array the registered JS files. * @var array the registered JS files.
* @see registerJsFile * @see registerJsFile()
*/ */
public $jsFiles; public $jsFiles;

2
framework/yii/web/XmlResponseFormatter.php

@ -17,6 +17,8 @@ use yii\helpers\StringHelper;
/** /**
* XmlResponseFormatter formats the given data into an XML response content. * XmlResponseFormatter formats the given data into an XML response content.
* *
* It is used by [[Response]] to format response data.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/web/YiiAsset.php

@ -8,6 +8,8 @@
namespace yii\web; namespace yii\web;
/** /**
* This asset bundle provides the base javascript files for the Yii Framework.
*
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
*/ */

2
framework/yii/widgets/ActiveForm.php

@ -220,7 +220,7 @@ class ActiveForm extends Widget
$lines = []; $lines = [];
foreach ($models as $model) { foreach ($models as $model) {
/** @var $model Model */ /** @var Model $model */
foreach ($model->getFirstErrors() as $error) { foreach ($model->getFirstErrors() as $error) {
$lines[] = Html::encode($error); $lines[] = Html::encode($error);
} }

6
framework/yii/widgets/Menu.php

@ -104,7 +104,7 @@ class Menu extends Widget
/** /**
* @var boolean whether to automatically activate items according to whether their route setting * @var boolean whether to automatically activate items according to whether their route setting
* matches the currently requested route. * matches the currently requested route.
* @see isItemActive * @see isItemActive()
*/ */
public $activateItems = true; public $activateItems = true;
/** /**
@ -137,14 +137,14 @@ class Menu extends Widget
* @var string the route used to determine if a menu item is active or not. * @var string the route used to determine if a menu item is active or not.
* If not set, it will use the route of the current request. * If not set, it will use the route of the current request.
* @see params * @see params
* @see isItemActive * @see isItemActive()
*/ */
public $route; public $route;
/** /**
* @var array the parameters used to determine if a menu item is active or not. * @var array the parameters used to determine if a menu item is active or not.
* If not set, it will use `$_GET`. * If not set, it will use `$_GET`.
* @see route * @see route
* @see isItemActive * @see isItemActive()
*/ */
public $params; public $params;

6
tests/unit/data/views/layout.php

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
* @var $content string * @var string $content
*/ */
?> ?>
<?php $this->beginPage(); ?> <?php $this->beginPage(); ?>
@ -19,4 +19,4 @@
<?php $this->endBody(); ?> <?php $this->endBody(); ?>
</body> </body>
</html> </html>
<?php $this->endPage(); ?> <?php $this->endPage(); ?>

4
tests/unit/data/views/rawlayout.php

@ -1,5 +1,5 @@
<?php <?php
/** /**
* @var $this \yii\web\View * @var \yii\web\View $this
*/ */
?><?php $this->beginPage(); ?>1<?php $this->head(); ?>2<?php $this->beginBody(); ?>3<?php $this->endBody(); ?>4<?php $this->endPage(); ?> ?><?php $this->beginPage(); ?>1<?php $this->head(); ?>2<?php $this->beginBody(); ?>3<?php $this->endBody(); ?>4<?php $this->endPage(); ?>

2
tests/unit/extensions/swiftmailer/MessageTest.php

@ -306,7 +306,7 @@ class MessageTest extends VendorTestCase
$htmlPresent = false; $htmlPresent = false;
foreach ($messageParts as $part) { foreach ($messageParts as $part) {
if (!($part instanceof \Swift_Mime_Attachment)) { if (!($part instanceof \Swift_Mime_Attachment)) {
/* @var $part \Swift_Mime_MimePart */ /* @var \Swift_Mime_MimePart $part */
if ($part->getContentType() == 'text/plain') { if ($part->getContentType() == 'text/plain') {
$textPresent = true; $textPresent = true;
} }

6
tests/unit/framework/db/ActiveRecordTest.php

@ -117,7 +117,7 @@ class ActiveRecordTest extends DatabaseTestCase
public function testFindLazy() public function testFindLazy()
{ {
/** @var $customer Customer */ /** @var Customer $customer */
$customer = Customer::find(2); $customer = Customer::find(2);
$orders = $customer->orders; $orders = $customer->orders;
$this->assertEquals(2, count($orders)); $this->assertEquals(2, count($orders));
@ -137,7 +137,7 @@ class ActiveRecordTest extends DatabaseTestCase
public function testFindLazyVia() public function testFindLazyVia()
{ {
/** @var $order Order */ /** @var Order $order */
$order = Order::find(1); $order = Order::find(1);
$this->assertEquals(1, $order->id); $this->assertEquals(1, $order->id);
$this->assertEquals(2, count($order->items)); $this->assertEquals(2, count($order->items));
@ -162,7 +162,7 @@ class ActiveRecordTest extends DatabaseTestCase
public function testFindLazyViaTable() public function testFindLazyViaTable()
{ {
/** @var $order Order */ /** @var Order $order */
$order = Order::find(1); $order = Order::find(1);
$this->assertEquals(1, $order->id); $this->assertEquals(1, $order->id);
$this->assertEquals(2, count($order->books)); $this->assertEquals(2, count($order->books));

4
tests/unit/framework/validators/ValidatorTest.php

@ -30,7 +30,7 @@ class ValidatorTest extends TestCase
public function testCreateValidator() public function testCreateValidator()
{ {
$model = FakedValidationModel::createWithAttributes(['attr_test1' => 'abc', 'attr_test2' => '2013']); $model = FakedValidationModel::createWithAttributes(['attr_test1' => 'abc', 'attr_test2' => '2013']);
/** @var $numberVal NumberValidator */ /** @var NumberValidator $numberVal */
$numberVal = TestValidator::createValidator('number', $model, ['attr_test1']); $numberVal = TestValidator::createValidator('number', $model, ['attr_test1']);
$this->assertInstanceOf(NumberValidator::className(), $numberVal); $this->assertInstanceOf(NumberValidator::className(), $numberVal);
$numberVal = TestValidator::createValidator('integer', $model, ['attr_test2']); $numberVal = TestValidator::createValidator('integer', $model, ['attr_test2']);
@ -229,4 +229,4 @@ class ValidatorTest extends TestCase
$errors = $m->getErrors('attr_msg_val'); $errors = $m->getErrors('attr_msg_val');
$this->assertEquals('attr_msg_val::abc::param_value', $errors[0]); $this->assertEquals('attr_msg_val::abc::param_value', $errors[0]);
} }
} }

Loading…
Cancel
Save