Merge master into doc-fixes

Conflicts:
	framework/web/AssetManager.php
This commit is contained in:
Robert Korulczyk
2016-11-13 15:35:18 +01:00
23 changed files with 65 additions and 62 deletions

View File

@ -13,7 +13,7 @@ use Yii;
* Component is the base class that implements the *property*, *event* and *behavior* features.
*
* Component provides the *event* and *behavior* features, in addition to the *property* feature which is implemented in
* its parent class [[Object]].
* its parent class [[\yii\base\Object|Object]].
*
* Event is a way to "inject" custom code into existing code at certain places. For example, a comment object can trigger
* an "add" event when the user adds a comment. We can write custom code and attach it to this event so that when the event

View File

@ -55,12 +55,12 @@ class Security extends Component
];
/**
* @var string Hash algorithm for key derivation. Recommend sha256, sha384 or sha512.
* @see hash_algos()
* @see [hash_algos()](http://php.net/manual/en/function.hash-algos.php)
*/
public $kdfHash = 'sha256';
/**
* @var string Hash algorithm for message authentication. Recommend sha256, sha384 or sha512.
* @see hash_algos()
* @see [hash_algos()](http://php.net/manual/en/function.hash-algos.php)
*/
public $macHash = 'sha256';
/**

View File

@ -67,7 +67,7 @@ class AttributeBehavior extends Behavior
public $attributes = [];
/**
* @var mixed the value that will be assigned to the current attributes. This can be an anonymous function,
* callable in array format (e.g. `[$this, 'methodName']`), an [[Expression]] object representing a DB expression
* callable in array format (e.g. `[$this, 'methodName']`), an [[\yii\db\Expression|Expression]] object representing a DB expression
* (e.g. `new Expression('NOW()')`), scalar, string or an arbitrary value. If the former, the return value of the
* function will be assigned to the attributes.
* The signature of the function should be as follows,

View File

@ -286,7 +286,7 @@ class MemCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param mixed $value the value to be cached.
* @see \MemcachePool::set()
* @see [Memcache::set()](http://php.net/manual/en/memcache.set.php)
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
* @return bool true if the value is successfully stored into cache, false otherwise
*/
@ -327,7 +327,7 @@ class MemCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param mixed $value the value to be cached
* @see \MemcachePool::set()
* @see [Memcache::set()](http://php.net/manual/en/memcache.set.php)
* @param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
* @return bool true if the value is successfully stored into cache, false otherwise
*/

View File

@ -46,7 +46,7 @@ use yii\widgets\InputWidget;
* ]);
* ```
*
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
* You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php

View File

@ -84,7 +84,7 @@ class CaptchaValidator extends Validator
/**
* @inheritdoc
*/
public function clientValidateAttribute($object, $attribute, $view)
public function clientValidateAttribute($model, $attribute, $view)
{
$captcha = $this->createCaptchaAction();
$code = $captcha->getVerifyCode(false);
@ -94,7 +94,7 @@ class CaptchaValidator extends Validator
'hashKey' => 'yiiCaptcha/' . $captcha->getUniqueId(),
'caseSensitive' => $this->caseSensitive,
'message' => Yii::$app->getI18n()->format($this->message, [
'attribute' => $object->getAttributeLabel($attribute),
'attribute' => $model->getAttributeLabel($attribute),
], Yii::$app->language),
];
if ($this->skipOnEmpty) {

View File

@ -336,7 +336,7 @@ class Controller extends \yii\base\Controller
* where the keys is alias name for option and value is option name.
*
* @since 2.0.8
* @see options($actionID)
* @see options()
*/
public function optionAliases()
{

View File

@ -54,7 +54,10 @@ class Markdown extends \cebe\markdown\Parser
}
/**
* @inheritdoc
* Render a paragraph block
*
* @param string $block
* @return string
*/
protected function renderParagraph($block)
{

View File

@ -284,10 +284,10 @@ class ActiveQuery extends Query implements ActiveQueryInterface
/**
* Executes query and returns a single row of result.
* @param Connection $db the DB connection used to create the DB command.
* If null, the DB connection returned by [[modelClass]] will be used.
* @param Connection|null $db the DB connection used to create the DB command.
* If `null`, the DB connection returned by [[modelClass]] will be used.
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]],
* the query result may be either an array or an ActiveRecord object. Null will be returned
* the query result may be either an array or an ActiveRecord object. `null` will be returned
* if the query results in nothing.
*/
public function one($db = null)
@ -303,8 +303,8 @@ class ActiveQuery extends Query implements ActiveQueryInterface
/**
* Creates a DB command that can be used to execute this query.
* @param Connection $db the DB connection used to create the DB command.
* If null, the DB connection returned by [[modelClass]] will be used.
* @param Connection|null $db the DB connection used to create the DB command.
* If `null`, the DB connection returned by [[modelClass]] will be used.
* @return Command the created DB command instance.
*/
public function createCommand($db = null)

View File

@ -32,7 +32,7 @@ interface ActiveQueryInterface extends QueryInterface
/**
* Executes query and returns a single row of result.
* @param Connection $db the DB connection used to create the DB command.
* If `null`, the DB connection returned by [[modelClass]] will be used.
* If `null`, the DB connection returned by [[ActiveQueryTrait::$modelClass|modelClass]] will be used.
* @return ActiveRecordInterface|array|null a single row of query result. Depending on the setting of [[asArray]],
* the query result may be either an array or an ActiveRecord object. `null` will be returned
* if the query results in nothing.

View File

@ -276,7 +276,7 @@ interface ActiveRecordInterface
* $customer->save();
* ```
*
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
* before saving the record. Defaults to `true`. If the validation fails, the record
* will not be saved to the database and this method will return `false`.
* @param array $attributeNames list of attribute names that need to be saved. Defaults to `null`,
@ -297,7 +297,7 @@ interface ActiveRecordInterface
* $customer->insert();
* ```
*
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
* before saving the record. Defaults to `true`. If the validation fails, the record
* will not be saved to the database and this method will return `false`.
* @param array $attributes list of attributes that need to be saved. Defaults to `null`,
@ -318,7 +318,7 @@ interface ActiveRecordInterface
* $customer->update();
* ```
*
* @param bool $runValidation whether to perform validation (calling [[Model::validate()|validate()]])
* @param bool $runValidation whether to perform validation (calling [[\yii\base\Model::validate()|validate()]])
* before saving the record. Defaults to `true`. If the validation fails, the record
* will not be saved to the database and this method will return `false`.
* @param array $attributeNames list of attributes that need to be saved. Defaults to `null`,

View File

@ -947,7 +947,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* already the new, updated values.
*
* Note that no automatic type conversion performed by default. You may use
* [[yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting.
* [[\yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting.
* See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.
*/
public function afterSave($insert, $changedAttributes)

View File

@ -283,7 +283,7 @@ class Connection extends Component
'cubrid' => 'yii\db\cubrid\Schema', // CUBRID
];
/**
* @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[yii\db\mssql\PDO]] when MSSQL is used.
* @var string Custom PDO wrapper class. If not set, it will use [[PDO]] or [[\yii\db\mssql\PDO]] when MSSQL is used.
* @see pdo
*/
public $pdoClass;

View File

@ -65,9 +65,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
/**
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2012 or newer.
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
* @param array $orderBy the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
* @param int $limit the limit number. See [[Query::limit]] for more details.
* @param int $offset the offset number. See [[Query::offset]] for more details.
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
* @param int $limit the limit number. See [[\yii\db\Query::limit]] for more details.
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
*/
protected function newBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)
@ -92,9 +92,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
/**
* Builds the ORDER BY/LIMIT/OFFSET clauses for SQL SERVER 2005 to 2008.
* @param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
* @param array $orderBy the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
* @param int $limit the limit number. See [[Query::limit]] for more details.
* @param int $offset the offset number. See [[Query::offset]] for more details.
* @param array $orderBy the order by columns. See [[\yii\db\Query::orderBy]] for more details on how to specify this parameter.
* @param int $limit the limit number. See [[\yii\db\Query::limit]] for more details.
* @param int $offset the offset number. See [[\yii\db\Query::offset]] for more details.
* @return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)
*/
protected function oldBuildOrderByAndLimit($sql, $orderBy, $limit, $offset)

View File

@ -207,7 +207,7 @@ class Cors extends ActionFilter
/**
* Adds the CORS headers to the response
* @param Response $response
* @param array CORS headers which have been computed
* @param array $headers CORS headers which have been computed
*/
public function addCorsHeaders($response, $headers)
{

View File

@ -480,8 +480,8 @@ class BaseInflector
* of the helper.
*
* @param string $string input string
* @param string|\Transliterator $transliterator either a [[Transliterator]] or a string
* from which a [[Transliterator]] can be built.
* @param string|\Transliterator $transliterator either a [[\Transliterator]] or a string
* from which a [[\Transliterator]] can be built.
* @return string
* @since 2.0.7 this method is public.
*/

View File

@ -1131,7 +1131,7 @@ class Formatter extends Component
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
* @return string the formatted result.
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
* @see sizeFormat
* @see sizeFormatBase
* @see asSize
*/
public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
@ -1187,7 +1187,7 @@ class Formatter extends Component
* @param array $textOptions optional configuration for the number formatter. This parameter will be merged with [[numberFormatterTextOptions]].
* @return string the formatted result.
* @throws InvalidParamException if the input value is not numeric or the formatting failed.
* @see sizeFormat
* @see sizeFormatBase
* @see asShortSize
*/
public function asSize($value, $decimals = null, $options = [], $textOptions = [])

View File

@ -42,7 +42,7 @@ class EachValidator extends Validator
{
/**
* @var array|Validator definition of the validation rule, which should be used on array values.
* It should be specified in the same format as at [[yii\base\Model::rules()]], except it should not
* It should be specified in the same format as at [[\yii\base\Model::rules()]], except it should not
* contain attribute list as the first element.
* For example:
*
@ -51,7 +51,7 @@ class EachValidator extends Validator
* ['match', 'pattern' => '/[a-z]/is']
* ```
*
* Please refer to [[yii\base\Model::rules()]] for more details.
* Please refer to [[\yii\base\Model::rules()]] for more details.
*/
public $rule;
/**

View File

@ -222,56 +222,56 @@ class FileValidator extends Validator
/**
* @inheritdoc
*/
protected function validateValue($file)
protected function validateValue($value)
{
if (!$file instanceof UploadedFile || $file->error == UPLOAD_ERR_NO_FILE) {
if (!$value instanceof UploadedFile || $value->error == UPLOAD_ERR_NO_FILE) {
return [$this->uploadRequired, []];
}
switch ($file->error) {
switch ($value->error) {
case UPLOAD_ERR_OK:
if ($this->maxSize !== null && $file->size > $this->getSizeLimit()) {
if ($this->maxSize !== null && $value->size > $this->getSizeLimit()) {
return [
$this->tooBig,
[
'file' => $file->name,
'file' => $value->name,
'limit' => $this->getSizeLimit(),
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
],
];
} elseif ($this->minSize !== null && $file->size < $this->minSize) {
} elseif ($this->minSize !== null && $value->size < $this->minSize) {
return [
$this->tooSmall,
[
'file' => $file->name,
'file' => $value->name,
'limit' => $this->minSize,
'formattedLimit' => Yii::$app->formatter->asShortSize($this->minSize),
],
];
} elseif (!empty($this->extensions) && !$this->validateExtension($file)) {
return [$this->wrongExtension, ['file' => $file->name, 'extensions' => implode(', ', $this->extensions)]];
} elseif (!empty($this->mimeTypes) && !$this->validateMimeType($file)) {
return [$this->wrongMimeType, ['file' => $file->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]];
} elseif (!empty($this->extensions) && !$this->validateExtension($value)) {
return [$this->wrongExtension, ['file' => $value->name, 'extensions' => implode(', ', $this->extensions)]];
} elseif (!empty($this->mimeTypes) && !$this->validateMimeType($value)) {
return [$this->wrongMimeType, ['file' => $value->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]];
}
return null;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return [$this->tooBig, [
'file' => $file->name,
'file' => $value->name,
'limit' => $this->getSizeLimit(),
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
]];
case UPLOAD_ERR_PARTIAL:
Yii::warning('File was only partially uploaded: ' . $file->name, __METHOD__);
Yii::warning('File was only partially uploaded: ' . $value->name, __METHOD__);
break;
case UPLOAD_ERR_NO_TMP_DIR:
Yii::warning('Missing the temporary folder to store the uploaded file: ' . $file->name, __METHOD__);
Yii::warning('Missing the temporary folder to store the uploaded file: ' . $value->name, __METHOD__);
break;
case UPLOAD_ERR_CANT_WRITE:
Yii::warning('Failed to write the uploaded file to disk: ' . $file->name, __METHOD__);
Yii::warning('Failed to write the uploaded file to disk: ' . $value->name, __METHOD__);
break;
case UPLOAD_ERR_EXTENSION:
Yii::warning('File upload was stopped by some PHP extension: ' . $file->name, __METHOD__);
Yii::warning('File upload was stopped by some PHP extension: ' . $value->name, __METHOD__);
break;
default:
break;
@ -312,6 +312,7 @@ class FileValidator extends Validator
/**
* @inheritdoc
* @param bool $trim
*/
public function isEmpty($value, $trim = false)
{

View File

@ -115,11 +115,11 @@ class ImageValidator extends FileValidator
/**
* @inheritdoc
*/
protected function validateValue($file)
protected function validateValue($value)
{
$result = parent::validateValue($file);
$result = parent::validateValue($value);
return empty($result) ? $this->validateImage($file) : $result;
return empty($result) ? $this->validateImage($value) : $result;
}
/**

View File

@ -291,9 +291,9 @@ class AssetManager extends Component
/**
* Returns the actual URL for the specified asset.
* The actual URL is obtained by prepending either [[baseUrl]] or [[AssetManager::baseUrl]] to the given asset path.
* The actual URL is obtained by prepending either [[AssetBundle::$baseUrl]] or [[AssetManager::$baseUrl]] to the given asset path.
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
* @param string $asset the asset path. This should be one of the assets listed in [[js]] or [[css]].
* @param string $asset the asset path. This should be one of the assets listed in [[AssetBundle::$js]] or [[AssetBundle::$css]].
* @return string the actual URL for the specified asset.
*/
public function getAssetUrl($bundle, $asset)
@ -327,7 +327,7 @@ class AssetManager extends Component
/**
* Returns the actual file path for the specified asset.
* @param AssetBundle $bundle the asset bundle which the asset file belongs to
* @param string $asset the asset path. This should be one of the assets listed in [[js]] or [[css]].
* @param string $asset the asset path. This should be one of the assets listed in [[AssetBundle::$js]] or [[AssetBundle::$css]].
* @return string|false the actual file path, or `false` if the asset is specified as an absolute URL
*/
public function getAssetPath($bundle, $asset)

View File

@ -406,7 +406,6 @@ class User extends Component
* @return Response the redirection response if [[loginUrl]] is set
* @throws ForbiddenHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set or a redirect is
* not applicable.
* @see checkAcceptHeader
*/
public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
{

View File

@ -29,7 +29,7 @@ use yii\web\View;
* ]);
* ```
*
* You can also use this widget in an [[yii\widgets\ActiveForm|ActiveForm]] using the [[yii\widgets\ActiveField::widget()|widget()]]
* You can also use this widget in an [[ActiveForm]] using the [[ActiveField::widget()|widget()]]
* method, for example like this:
*
* ```php