Browse Source

coding style fixes

ar-bug
Nikola Kovacs 8 years ago
parent
commit
9d327baa8b
  1. 3
      framework/base/ActionFilter.php
  2. 1
      framework/base/Configurable.php
  3. 2
      framework/behaviors/SluggableBehavior.php
  4. 2
      framework/captcha/Captcha.php
  5. 3
      framework/console/controllers/FixtureController.php
  6. 4
      framework/console/controllers/MessageController.php
  7. 4
      framework/console/controllers/MigrateController.php
  8. 2
      framework/console/controllers/ServeController.php
  9. 2
      framework/db/ActiveQuery.php
  10. 2
      framework/db/BaseActiveRecord.php
  11. 2
      framework/db/cubrid/Schema.php
  12. 2
      framework/db/pgsql/Schema.php
  13. 1
      framework/db/sqlite/ColumnSchemaBuilder.php
  14. 4
      framework/grid/DataColumn.php
  15. 2
      framework/helpers/BaseInflector.php
  16. 2
      framework/helpers/BaseJson.php
  17. 4
      framework/i18n/DbMessageSource.php
  18. 72
      framework/i18n/Formatter.php
  19. 2
      framework/messages/config.php
  20. 1
      framework/test/ArrayFixture.php
  21. 13
      framework/validators/FileValidator.php
  22. 10
      framework/validators/ImageValidator.php
  23. 8
      framework/validators/IpValidator.php
  24. 2
      framework/web/UrlRule.php

3
framework/base/ActionFilter.php

@ -118,7 +118,8 @@ class ActionFilter extends Behavior
* @return string
* @since 2.0.7
*/
protected function getActionId($action) {
protected function getActionId($action)
{
if ($this->owner instanceof Module) {
$mid = $this->owner->getUniqueId();
$id = $action->getUniqueId();

1
framework/base/Configurable.php

@ -29,4 +29,3 @@ namespace yii\base;
interface Configurable
{
}

2
framework/behaviors/SluggableBehavior.php

@ -223,7 +223,7 @@ class SluggableBehavior extends AttributeBehavior
/* @var $model BaseActiveRecord */
$validator = Yii::createObject(array_merge(
[
'class' => UniqueValidator::className()
'class' => UniqueValidator::className(),
],
$this->uniqueValidator
));

2
framework/captcha/Captcha.php

@ -150,7 +150,7 @@ class Captcha extends InputWidget
$options = [
'refreshUrl' => Url::toRoute($route),
'hashKey' => 'yiiCaptcha/' . trim($route[0], '/')
'hashKey' => 'yiiCaptcha/' . trim($route[0], '/'),
];
return $options;

3
framework/console/controllers/FixtureController.php

@ -78,7 +78,7 @@ class FixtureController extends Controller
{
return array_merge(parent::optionAliases(), [
'g' => 'globalFixtures',
'n' => 'namespace'
'n' => 'namespace',
]);
}
@ -490,5 +490,4 @@ class FixtureController extends Controller
{
return Yii::getAlias('@' . str_replace('\\', '/', $this->namespace));
}
}

4
framework/console/controllers/MessageController.php

@ -156,7 +156,7 @@ class MessageController extends Controller
'sourceMessageTable',
'messageTable',
'catalog',
'ignoreCategories'
'ignoreCategories',
]);
}
@ -180,7 +180,7 @@ class MessageController extends Controller
't' => 'translator',
'm' => 'sourceMessageTable',
's' => 'sourcePath',
'r' => 'removeUnused'
'r' => 'removeUnused',
]);
}

4
framework/console/controllers/MigrateController.php

@ -80,7 +80,7 @@ class MigrateController extends BaseMigrateController
'drop_table' => '@yii/views/dropTableMigration.php',
'add_column' => '@yii/views/addColumnMigration.php',
'drop_column' => '@yii/views/dropColumnMigration.php',
'create_junction' => '@yii/views/createTableMigration.php'
'create_junction' => '@yii/views/createTableMigration.php',
];
/**
* @var boolean indicates whether the table names generated should consider
@ -295,7 +295,7 @@ class MigrateController extends BaseMigrateController
$foreignKeys[$column] = [
'idx' => $this->generateTableName("idx-$table-$column"),
'fk' => $this->generateTableName("fk-$table-$column"),
'relatedTable' => $this->generateTableName($relatedTable)
'relatedTable' => $this->generateTableName($relatedTable),
];
}

2
framework/console/controllers/ServeController.php

@ -103,7 +103,7 @@ class ServeController extends Controller
return array_merge(parent::optionAliases(), [
't' => 'docroot',
'p' => 'port',
'r' => 'router'
'r' => 'router',
]);
}

2
framework/db/ActiveQuery.php

@ -405,7 +405,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
// relation is defined with an alias, adjust callback to apply alias
list(, $relation, $alias) = $matches;
$name = $relation;
$callback = function($query) use ($callback, $alias) {
$callback = function ($query) use ($callback, $alias) {
/** @var $query ActiveQuery */
$query->alias($alias);
if ($callback !== null) {

2
framework/db/BaseActiveRecord.php

@ -912,7 +912,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
public function afterSave($insert, $changedAttributes)
{
$this->trigger($insert ? self::EVENT_AFTER_INSERT : self::EVENT_AFTER_UPDATE, new AfterSaveEvent([
'changedAttributes' => $changedAttributes
'changedAttributes' => $changedAttributes,
]));
}

2
framework/db/cubrid/Schema.php

@ -155,7 +155,7 @@ class Schema extends \yii\db\Schema
} else {
$table->foreignKeys[$key['FK_NAME']] = [
$key['PKTABLE_NAME'],
$key['FKCOLUMN_NAME'] => $key['PKCOLUMN_NAME']
$key['FKCOLUMN_NAME'] => $key['PKCOLUMN_NAME'],
];
}
}

2
framework/db/pgsql/Schema.php

@ -105,7 +105,7 @@ class Schema extends \yii\db\Schema
'uuid' => self::TYPE_STRING,
'json' => self::TYPE_STRING,
'jsonb' => self::TYPE_STRING,
'xml' => self::TYPE_STRING
'xml' => self::TYPE_STRING,
];

1
framework/db/sqlite/ColumnSchemaBuilder.php

@ -9,7 +9,6 @@ namespace yii\db\sqlite;
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
/**
* ColumnSchemaBuilder is the schema builder for Sqlite databases.
*

4
framework/grid/DataColumn.php

@ -144,11 +144,11 @@ class DataColumn extends Column
/* @var $model Model */
$model = new $provider->query->modelClass;
$label = $model->getAttributeLabel($this->attribute);
} else if ($provider instanceof ArrayDataProvider && $provider->modelClass !== null) {
} elseif ($provider instanceof ArrayDataProvider && $provider->modelClass !== null) {
/* @var $model Model */
$model = new $provider->modelClass;
$label = $model->getAttributeLabel($this->attribute);
} else if ($this->grid->filterModel !== null && $this->grid->filterModel instanceof Model) {
} elseif ($this->grid->filterModel !== null && $this->grid->filterModel instanceof Model) {
$label = $this->grid->filterModel->getAttributeLabel($this->attribute);
} else {
$models = $provider->getModels();

2
framework/helpers/BaseInflector.php

@ -362,7 +362,7 @@ class BaseInflector
$label = trim(strtolower(str_replace([
'-',
'_',
'.'
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name))));
return $ucwords ? ucwords($label) : $label;

2
framework/helpers/BaseJson.php

@ -53,7 +53,7 @@ class BaseJson
{
$expressions = [];
$value = static::processData($value, $expressions, uniqid('', true));
set_error_handler(function() {
set_error_handler(function () {
static::handleJsonError(JSON_ERROR_SYNTAX);
}, E_WARNING);
$json = json_encode($value, $options);

4
framework/i18n/DbMessageSource.php

@ -146,7 +146,7 @@ class DbMessageSource extends MessageSource
->where([
't1.id' => new Expression('[[t2.id]]'),
't1.category' => $category,
't2.language' => $language
't2.language' => $language,
]);
$fallbackLanguage = substr($language, 0, 2);
@ -181,7 +181,7 @@ class DbMessageSource extends MessageSource
->where([
't1.id' => new Expression('[[t2.id]]'),
't1.category' => $category,
't2.language' => $fallbackLanguage
't2.language' => $fallbackLanguage,
])->andWhere([
'NOT IN', 't2.id', (new Query())->select('[[id]]')->from($this->messageTable)->where(['language' => $language])
]);

72
framework/i18n/Formatter.php

@ -1146,21 +1146,33 @@ class Formatter extends Component
if ($this->sizeFormatBase == 1024) {
switch ($position) {
case 0: return Yii::t('yii', '{nFormatted} B', $params, $this->locale);
case 1: return Yii::t('yii', '{nFormatted} KiB', $params, $this->locale);
case 2: return Yii::t('yii', '{nFormatted} MiB', $params, $this->locale);
case 3: return Yii::t('yii', '{nFormatted} GiB', $params, $this->locale);
case 4: return Yii::t('yii', '{nFormatted} TiB', $params, $this->locale);
default: return Yii::t('yii', '{nFormatted} PiB', $params, $this->locale);
case 0:
return Yii::t('yii', '{nFormatted} B', $params, $this->locale);
case 1:
return Yii::t('yii', '{nFormatted} KiB', $params, $this->locale);
case 2:
return Yii::t('yii', '{nFormatted} MiB', $params, $this->locale);
case 3:
return Yii::t('yii', '{nFormatted} GiB', $params, $this->locale);
case 4:
return Yii::t('yii', '{nFormatted} TiB', $params, $this->locale);
default:
return Yii::t('yii', '{nFormatted} PiB', $params, $this->locale);
}
} else {
switch ($position) {
case 0: return Yii::t('yii', '{nFormatted} B', $params, $this->locale);
case 1: return Yii::t('yii', '{nFormatted} KB', $params, $this->locale);
case 2: return Yii::t('yii', '{nFormatted} MB', $params, $this->locale);
case 3: return Yii::t('yii', '{nFormatted} GB', $params, $this->locale);
case 4: return Yii::t('yii', '{nFormatted} TB', $params, $this->locale);
default: return Yii::t('yii', '{nFormatted} PB', $params, $this->locale);
case 0:
return Yii::t('yii', '{nFormatted} B', $params, $this->locale);
case 1:
return Yii::t('yii', '{nFormatted} KB', $params, $this->locale);
case 2:
return Yii::t('yii', '{nFormatted} MB', $params, $this->locale);
case 3:
return Yii::t('yii', '{nFormatted} GB', $params, $this->locale);
case 4:
return Yii::t('yii', '{nFormatted} TB', $params, $this->locale);
default:
return Yii::t('yii', '{nFormatted} PB', $params, $this->locale);
}
}
}
@ -1190,21 +1202,33 @@ class Formatter extends Component
if ($this->sizeFormatBase == 1024) {
switch ($position) {
case 0: return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
case 1: return Yii::t('yii', '{nFormatted} {n, plural, =1{kibibyte} other{kibibytes}}', $params, $this->locale);
case 2: return Yii::t('yii', '{nFormatted} {n, plural, =1{mebibyte} other{mebibytes}}', $params, $this->locale);
case 3: return Yii::t('yii', '{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}', $params, $this->locale);
case 4: return Yii::t('yii', '{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}', $params, $this->locale);
default: return Yii::t('yii', '{nFormatted} {n, plural, =1{pebibyte} other{pebibytes}}', $params, $this->locale);
case 0:
return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
case 1:
return Yii::t('yii', '{nFormatted} {n, plural, =1{kibibyte} other{kibibytes}}', $params, $this->locale);
case 2:
return Yii::t('yii', '{nFormatted} {n, plural, =1{mebibyte} other{mebibytes}}', $params, $this->locale);
case 3:
return Yii::t('yii', '{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}', $params, $this->locale);
case 4:
return Yii::t('yii', '{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}', $params, $this->locale);
default:
return Yii::t('yii', '{nFormatted} {n, plural, =1{pebibyte} other{pebibytes}}', $params, $this->locale);
}
} else {
switch ($position) {
case 0: return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
case 1: return Yii::t('yii', '{nFormatted} {n, plural, =1{kilobyte} other{kilobytes}}', $params, $this->locale);
case 2: return Yii::t('yii', '{nFormatted} {n, plural, =1{megabyte} other{megabytes}}', $params, $this->locale);
case 3: return Yii::t('yii', '{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}', $params, $this->locale);
case 4: return Yii::t('yii', '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}', $params, $this->locale);
default: return Yii::t('yii', '{nFormatted} {n, plural, =1{petabyte} other{petabytes}}', $params, $this->locale);
case 0:
return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->locale);
case 1:
return Yii::t('yii', '{nFormatted} {n, plural, =1{kilobyte} other{kilobytes}}', $params, $this->locale);
case 2:
return Yii::t('yii', '{nFormatted} {n, plural, =1{megabyte} other{megabytes}}', $params, $this->locale);
case 3:
return Yii::t('yii', '{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}', $params, $this->locale);
case 4:
return Yii::t('yii', '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}', $params, $this->locale);
default:
return Yii::t('yii', '{nFormatted} {n, plural, =1{petabyte} other{petabytes}}', $params, $this->locale);
}
}
}

2
framework/messages/config.php

@ -7,7 +7,7 @@ return [
'messagePath' => __DIR__,
// array, required, list of language codes that the extracted messages
// should be translated to. For example, ['zh-CN', 'de'].
'languages' => ['ar', 'az', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'es', 'et', 'fa', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ka', 'kk', 'ko', 'lt', 'lv', 'ms', 'nb-NO', 'nl', 'pl', 'pt', 'pt-BR', 'ro', 'ru', 'sk', 'sl', 'sr', 'sr-Latn', 'sv', 'th', 'tj', 'uk', 'vi', 'zh-CN','zh-TW'],
'languages' => ['ar', 'az', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'es', 'et', 'fa', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'it', 'ja', 'ka', 'kk', 'ko', 'lt', 'lv', 'ms', 'nb-NO', 'nl', 'pl', 'pt', 'pt-BR', 'ro', 'ru', 'sk', 'sl', 'sr', 'sr-Latn', 'sv', 'th', 'tj', 'uk', 'vi', 'zh-CN', 'zh-TW'],
// string, the name of the function for translating messages.
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
// translated. You may use a string for single function name or an array for

1
framework/test/ArrayFixture.php

@ -73,5 +73,4 @@ class ArrayFixture extends Fixture implements \IteratorAggregate, \ArrayAccess,
parent::unload();
$this->data = [];
}
}

13
framework/validators/FileValidator.php

@ -236,8 +236,8 @@ class FileValidator extends Validator
[
'file' => $file->name,
'limit' => $this->getSizeLimit(),
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit())
]
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
],
];
} elseif ($this->minSize !== null && $file->size < $this->minSize) {
return [
@ -245,22 +245,21 @@ class FileValidator extends Validator
[
'file' => $file->name,
'limit' => $this->minSize,
'formattedLimit' => Yii::$app->formatter->asShortSize($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)]];
} else {
return null;
}
return null;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return [$this->tooBig, [
'file' => $file->name,
'limit' => $this->getSizeLimit(),
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit())
'formattedLimit' => Yii::$app->formatter->asShortSize($this->getSizeLimit()),
]];
case UPLOAD_ERR_PARTIAL:
Yii::warning('File was only partially uploaded: ' . $file->name, __METHOD__);

10
framework/validators/ImageValidator.php

@ -180,7 +180,7 @@ class ImageValidator extends FileValidator
if ($this->notImage !== null) {
$options['notImage'] = Yii::$app->getI18n()->format($this->notImage, [
'attribute' => $label
'attribute' => $label,
], Yii::$app->language);
}
@ -188,7 +188,7 @@ class ImageValidator extends FileValidator
$options['minWidth'] = $this->minWidth;
$options['underWidth'] = Yii::$app->getI18n()->format($this->underWidth, [
'attribute' => $label,
'limit' => $this->minWidth
'limit' => $this->minWidth,
], Yii::$app->language);
}
@ -196,7 +196,7 @@ class ImageValidator extends FileValidator
$options['maxWidth'] = $this->maxWidth;
$options['overWidth'] = Yii::$app->getI18n()->format($this->overWidth, [
'attribute' => $label,
'limit' => $this->maxWidth
'limit' => $this->maxWidth,
], Yii::$app->language);
}
@ -204,7 +204,7 @@ class ImageValidator extends FileValidator
$options['minHeight'] = $this->minHeight;
$options['underHeight'] = Yii::$app->getI18n()->format($this->underHeight, [
'attribute' => $label,
'limit' => $this->minHeight
'limit' => $this->minHeight,
], Yii::$app->language);
}
@ -212,7 +212,7 @@ class ImageValidator extends FileValidator
$options['maxHeight'] = $this->maxHeight;
$options['overHeight'] = Yii::$app->getI18n()->format($this->overHeight, [
'attribute' => $label,
'limit' => $this->maxHeight
'limit' => $this->maxHeight,
], Yii::$app->language);
}

8
framework/validators/IpValidator.php

@ -455,7 +455,8 @@ class IpValidator extends Validator
* - boolean: whether the string is negated
* - string: the string without negation (when the negation were present)
*/
private function parseNegatedRange ($string) {
private function parseNegatedRange($string)
{
$isNegated = strpos($string, static::NEGATION_CHAR) === 0;
return [$isNegated, $isNegated ? substr($string, strlen(static::NEGATION_CHAR)) : $string];
}
@ -470,7 +471,8 @@ class IpValidator extends Validator
* @return array
* @see networks
*/
private function prepareRanges($ranges) {
private function prepareRanges($ranges)
{
$result = [];
foreach ($ranges as $string) {
list($isRangeNegated, $range) = $this->parseNegatedRange($string);
@ -607,7 +609,7 @@ class IpValidator extends Validator
'ipv6' => (boolean)$this->ipv6,
'ipParsePattern' => new JsExpression(Html::escapeJsRegularExpression($this->getIpParsePattern())),
'negation' => $this->negation,
'subnet' => $this->subnet
'subnet' => $this->subnet,
];
if ($this->skipOnEmpty) {
$options['skipOnEmpty'] = 1;

2
framework/web/UrlRule.php

@ -383,7 +383,7 @@ class UrlRule extends Object implements UrlRuleInterface
* @see placeholders
* @since 2.0.7
*/
protected function substitutePlaceholderNames (array $matches)
protected function substitutePlaceholderNames(array $matches)
{
foreach ($this->placeholders as $placeholder => $name) {
if (isset($matches[$placeholder])) {

Loading…
Cancel
Save