Commit 4c2aaee4 by Qiang Xue

Merge pull request #2061 from lucianobaraglia/some-codestyle-fixes

Some codestyle fixes
parents ab882a3c fe3ff6dd
......@@ -16,7 +16,7 @@ $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
if (!is_dir($frameworkPath)) {
echo '<h1>Error</h1>';
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) .'</abbr>.</p>';
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
}
......
......@@ -16,7 +16,7 @@ $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
if (!is_dir($frameworkPath)) {
echo '<h1>Error</h1>';
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) .'</abbr>.</p>';
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
}
......
......@@ -33,8 +33,8 @@ class LoginFormTest extends TestCase
$this->specify('user should not be able to login with wrong password', function () use ($model) {
$this->assertFalse($model->login());
$this->assertArrayHasKey('password',$model->errors);
$this->assertTrue(Yii::$app->user->isGuest,'user should not be logged in');
$this->assertArrayHasKey('password', $model->errors);
$this->assertTrue(Yii::$app->user->isGuest, 'user should not be logged in');
});
}
......@@ -47,7 +47,7 @@ class LoginFormTest extends TestCase
$this->specify('user should be able to login with correct credentials', function() use ($model) {
$this->assertTrue($model->login());
$this->assertArrayNotHasKey('password',$model->errors);
$this->assertArrayNotHasKey('password', $model->errors);
$this->assertFalse(Yii::$app->user->isGuest,'user should be logged in');
});
}
......@@ -59,4 +59,4 @@ class LoginFormTest extends TestCase
return $loginForm;
}
}
\ No newline at end of file
}
......@@ -298,7 +298,7 @@ class PhpDocController extends Controller
if (isset($prop['get']) && isset($prop['set'])) {
if ($prop['get']['type'] != $prop['set']['type']) {
$note = ' Note that the type of this property differs in getter and setter.'
. ' See [[get'.ucfirst($propName).'()]] and [[set'.ucfirst($propName).'()]] for details.';
. ' See [[get' . ucfirst($propName) . '()]] and [[set' . ucfirst($propName) . '()]] for details.';
}
} elseif (isset($prop['get'])) {
// check if parent class has setter defined
......
......@@ -84,22 +84,22 @@ class BaseDoc extends Object
// TODO
public function loadSource($reflection)
{
$this->sourcePath=str_replace('\\','/',str_replace(YII_PATH,'',$reflection->getFileName()));
$this->startLine=$reflection->getStartLine();
$this->endLine=$reflection->getEndLine();
$this->sourcePath = str_replace('\\', '/', str_replace(YII_PATH, '', $reflection->getFileName()));
$this->startLine = $reflection->getStartLine();
$this->endLine = $reflection->getEndLine();
}
public function getSourceUrl($baseUrl,$line=null)
public function getSourceUrl($baseUrl, $line=null)
{
if($line===null)
return $baseUrl.$this->sourcePath;
if($line === null)
return $baseUrl . $this->sourcePath;
else
return $baseUrl.$this->sourcePath.'#'.$line;
return $baseUrl . $this->sourcePath . '#' . $line;
}
public function getSourceCode()
{
$lines=file(YII_PATH.$this->sourcePath);
return implode("",array_slice($lines,$this->startLine-1,$this->endLine-$this->startLine+1));
$lines = file(YII_PATH . $this->sourcePath);
return implode("", array_slice($lines, $this->startLine - 1, $this->endLine - $this->startLine + 1));
}
}
\ No newline at end of file
}
......@@ -239,7 +239,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
break;
}
}
return implode(" &raquo;\n",$parents);
return implode(" &raquo;\n", $parents);
}
/**
......@@ -257,7 +257,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$interfaces[] = $interface; // TODO link to php.net
}
}
return implode(', ',$interfaces);
return implode(', ', $interfaces);
}
/**
......@@ -275,7 +275,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$traits[] = $trait; // TODO link to php.net
}
}
return implode(', ',$traits);
return implode(', ', $traits);
}
/**
......@@ -293,7 +293,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$classes[] = $class; // TODO link to php.net
}
}
return implode(', ',$classes);
return implode(', ', $classes);
}
/**
......@@ -350,4 +350,4 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
{
return Yii::getAlias('@yii/apidoc/templates/html/views/' . $view);
}
}
\ No newline at end of file
}
......@@ -173,10 +173,10 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
$curlOptions = $this->mergeCurlOptions(
$this->defaultCurlOptions(),
$this->getCurlOptions(),
array(
[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
),
],
$this->composeRequestCurlOptions(strtoupper($method), $url, $params)
);
$curlResource = curl_init();
......@@ -217,7 +217,7 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
while (!empty($args)) {
$next = array_shift($args);
foreach ($next as $k => $v) {
$res[$k]=$v;
$res[$k] = $v;
}
}
return $res;
......@@ -507,4 +507,4 @@ abstract class BaseOAuth extends BaseClient implements ClientInterface
* @throws Exception on failure.
*/
abstract protected function apiInternal($accessToken, $url, $method, array $params);
}
\ No newline at end of file
}
......@@ -28,7 +28,7 @@ echo GridView::widget([
'value' => function ($data) {
$timeInSeconds = $data['time'] / 1000;
$millisecondsDiff = (int)(($timeInSeconds - (int)$timeInSeconds) * 1000);
return date('H:i:s.',$timeInSeconds) . sprintf('%03d',$millisecondsDiff);
return date('H:i:s.', $timeInSeconds) . sprintf('%03d', $millisecondsDiff);
},
'headerOptions' => [
'class' => 'sort-numerical'
......@@ -70,4 +70,4 @@ echo GridView::widget([
],
],
]);
?>
\ No newline at end of file
?>
......@@ -28,7 +28,7 @@ echo GridView::widget([
[
'attribute' => 'duration',
'value' => function ($data) {
return sprintf('%.1f ms',$data['duration']);
return sprintf('%.1f ms', $data['duration']);
},
'options' => [
'width' => '10%',
......
......@@ -367,7 +367,7 @@ class ActiveRecord extends BaseActiveRecord
* For example, to change the status to be 1 for all customers whose status is 2:
*
* ~~~
* Customer::updateAll(array('status' => 1), array(2, 3, 4));
* Customer::updateAll(['status' => 1], [2, 3, 4]);
* ~~~
*
* @param array $attributes attribute values (name-value pairs) to be saved into the table
......
......@@ -138,7 +138,7 @@ class QueryBuilder extends \yii\base\Object
*/
public function buildCondition($condition)
{
static $builders = array(
static $builders = [
'not' => 'buildNotCondition',
'and' => 'buildAndCondition',
'or' => 'buildAndCondition',
......@@ -150,7 +150,7 @@ class QueryBuilder extends \yii\base\Object
'not like' => 'buildLikeCondition',
'or like' => 'buildLikeCondition',
'or not like' => 'buildLikeCondition',
);
];
if (empty($condition)) {
return [];
......
......@@ -89,7 +89,7 @@ class Customer extends \yii\elasticsearch\ActiveRecord
*/
public static function active($query)
{
$query->andWhere(array('status' => 1));
$query->andWhere(['status' => 1]);
}
}
```
......
......@@ -335,4 +335,4 @@ $.fn.extend({
});
})(jQuery);
\ No newline at end of file
})(jQuery);
......@@ -289,7 +289,7 @@ class ErrorHandler extends Component
*/
public function createHttpStatusLink($statusCode, $statusDescription)
{
return '<a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#' . (int)$statusCode .'" target="_blank">HTTP ' . (int)$statusCode . ' &ndash; ' . $statusDescription . '</a>';
return '<a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#' . (int)$statusCode . '" target="_blank">HTTP ' . (int)$statusCode . ' &ndash; ' . $statusDescription . '</a>';
}
/**
......
......@@ -333,7 +333,7 @@ class Migration extends \yii\base\Component
*/
public function addPrimaryKey($name, $table, $columns)
{
echo " > add primary key $name on $table (".(is_array($columns) ? implode(',', $columns) : $columns).") ...";
echo " > add primary key $name on $table (" . (is_array($columns) ? implode(',', $columns) : $columns).") ...";
$time = microtime(true);
$this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute();
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
......
......@@ -93,8 +93,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/
public function alterColumn($table, $column, $type)
{
$type=$this->getColumnType($type);
$sql='ALTER TABLE ' . $this->db->quoteTableName($table) . ' ALTER COLUMN '
$type = $this->getColumnType($type);
$sql = 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ALTER COLUMN '
. $this->db->quoteColumnName($column) . ' '
. $this->getColumnType($type);
return $sql;
......
......@@ -146,7 +146,7 @@ class DbManager extends Manager
}
$query = new Query;
$rows = $query->from($this->itemTable)
->where(['or', 'name=:name1', 'name=:name2'], [':name1' => $itemName, ':name2' => $childName])
->where(['or', 'name=:name1', 'name=:name2'], [':name1' => $itemName, ':name2' => $childName])
->createCommand($this->db)
->queryAll();
if (count($rows) == 2) {
......@@ -299,7 +299,7 @@ class DbManager extends Manager
$query = new Query;
return $query->select(['item_name'])
->from($this->assignmentTable)
->where(['user_id' => $userId, 'item_name' => $itemName])
->where(['user_id' => $userId, 'item_name' => $itemName])
->createCommand($this->db)
->queryScalar() !== false;
}
......@@ -315,7 +315,7 @@ class DbManager extends Manager
{
$query = new Query;
$row = $query->from($this->assignmentTable)
->where(['user_id' => $userId, 'item_name' => $itemName])
->where(['user_id' => $userId, 'item_name' => $itemName])
->createCommand($this->db)
->queryOne();
if ($row !== false) {
......
......@@ -39,9 +39,9 @@ class MaskedInput extends InputWidget
/**
* @var string the input mask (e.g. '99/99/9999' for date input). The following characters are predefined:
*
* - `a`: represents an alpha character (A-Z,a-z)
* - `a`: represents an alpha character (A-Z, a-z)
* - `9`: represents a numeric character (0-9)
* - `*`: represents an alphanumeric character (A-Z,a-z,0-9)
* - `*`: represents an alphanumeric character (A-Z, a-z, 0-9)
* - `?`: anything listed after '?' within the mask is considered optional user input
*
* Additional characters can be defined by specifying the [[charMap]] property.
......
......@@ -32,12 +32,12 @@ class Customer extends ActiveRecord
public function getOrders()
{
return $this->hasMany(Order::className(), array('customer_id' => 'id'))->orderBy('created_at');
return $this->hasMany(Order::className(), ['customer_id' => 'id'])->orderBy('created_at');
}
public static function active($query)
{
$query->andWhere(array('status' => 1));
$query->andWhere(['status' => 1]);
}
public function afterSave($insert)
......
......@@ -180,13 +180,13 @@ class BaseOAuthTest extends TestCase
*/
public function determineContentTypeByRawDataProvider()
{
return array(
return [
['{name: value}', 'json'],
['name=value', 'urlencoded'],
['name1=value1&name2=value2', 'urlencoded'],
['<?xml version="1.0" encoding="UTF-8"?><tag>Value</tag>', 'xml'],
['<tag>Value</tag>', 'xml'],
);
];
}
/**
......@@ -248,4 +248,4 @@ class BaseOAuthTest extends TestCase
$this->assertEquals($expectedApiFullUrl, $oauthClient->api($apiSubUrl));
}
}
\ No newline at end of file
}
......@@ -35,14 +35,14 @@ class RedisConnectionTest extends RedisTestCase
public function keyValueData()
{
return array(
array(123),
array(-123),
array(0),
array('test'),
array("test\r\ntest"),
array(''),
);
return [
[123],
[-123],
[0],
['test'],
["test\r\ntest"],
[''],
];
}
/**
......@@ -55,4 +55,4 @@ class RedisConnectionTest extends RedisTestCase
$db->set('hi', $data);
$this->assertEquals($data, $db->get('hi'));
}
}
\ No newline at end of file
}
......@@ -58,7 +58,7 @@ class ActiveRecordTest extends DatabaseTestCase
public function testFindScalar()
{
// query scalar
$customerName = $this->callCustomerFind()->where(array('id' => 2))->select('name')->scalar();
$customerName = $this->callCustomerFind()->where(['id' => 2])->select('name')->scalar();
$this->assertEquals('user2', $customerName);
}
......
......@@ -84,7 +84,7 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
public function testBatchInsert()
{
$sql = $this->getQueryBuilder()->batchInsert('{{tbl_customer}} t', ['t.id','t.name'], array(array(1,'a'), array(2,'b')));
$sql = $this->getQueryBuilder()->batchInsert('{{tbl_customer}} t', ['t.id','t.name'], [[1,'a'], [2,'b']]);
$this->assertEquals("INSERT INTO {{tbl_customer}} t (`t`.`id`, `t`.`name`) SELECT 1, 'a' UNION ALL 2, 'b'", $sql);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment