Commit 51211898 by Alexander Mohorev

Control statements based on the if and elseif constructs must have a single…

Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional and a single space after the closing parenthesis.
parent 66b27fca
...@@ -21,7 +21,7 @@ if (empty($params['env'])) { ...@@ -21,7 +21,7 @@ if (empty($params['env'])) {
exit(1); exit(1);
} }
if(isset($envNames[$answer])) { if (isset($envNames[$answer])) {
$envName = $envNames[$answer]; $envName = $envNames[$answer];
} }
} }
......
...@@ -115,7 +115,7 @@ class PhpDocController extends Controller ...@@ -115,7 +115,7 @@ class PhpDocController extends Controller
if (trim($lines[1]) == '*' || substr(trim($lines[1]), 0, 3) == '* @') { if (trim($lines[1]) == '*' || substr(trim($lines[1]), 0, 3) == '* @') {
$this->stderr("[WARN] Class $className has no short description.\n", Console::FG_YELLOW, Console::BOLD); $this->stderr("[WARN] Class $className has no short description.\n", Console::FG_YELLOW, Console::BOLD);
} }
foreach($lines as $line) { foreach ($lines as $line) {
if (substr(trim($line), 0, 9) == '* @since ') { if (substr(trim($line), 0, 9) == '* @since ') {
$seenSince = true; $seenSince = true;
} elseif (substr(trim($line), 0, 10) == '* @author ') { } elseif (substr(trim($line), 0, 10) == '* @author ') {
...@@ -138,7 +138,7 @@ class PhpDocController extends Controller ...@@ -138,7 +138,7 @@ class PhpDocController extends Controller
$newFileContent = []; $newFileContent = [];
$n = count($fileContent); $n = count($fileContent);
for($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
if ($i > $start || $i < $docStart) { if ($i > $start || $i < $docStart) {
$newFileContent[] = $fileContent[$i]; $newFileContent[] = $fileContent[$i];
} else { } else {
...@@ -164,7 +164,7 @@ class PhpDocController extends Controller ...@@ -164,7 +164,7 @@ class PhpDocController extends Controller
{ {
$lines = explode("\n", $doc); $lines = explode("\n", $doc);
$n = count($lines); $n = count($lines);
for($i = 0; $i < $n; $i++) { for ($i = 0; $i < $n; $i++) {
$lines[$i] = rtrim($lines[$i]); $lines[$i] = rtrim($lines[$i]);
if (trim($lines[$i]) == '*' && trim($lines[$i + 1]) == '*') { if (trim($lines[$i]) == '*' && trim($lines[$i + 1]) == '*') {
unset($lines[$i]); unset($lines[$i]);
...@@ -184,7 +184,7 @@ class PhpDocController extends Controller ...@@ -184,7 +184,7 @@ class PhpDocController extends Controller
$lines = explode("\n", $doc); $lines = explode("\n", $doc);
$propertyPart = false; $propertyPart = false;
$propertyPosition = false; $propertyPosition = false;
foreach($lines as $i => $line) { foreach ($lines as $i => $line) {
if (substr(trim($line), 0, 12) == '* @property ') { if (substr(trim($line), 0, 12) == '* @property ') {
$propertyPart = true; $propertyPart = true;
} elseif ($propertyPart && trim($line) == '*') { } elseif ($propertyPart && trim($line) == '*') {
...@@ -200,7 +200,7 @@ class PhpDocController extends Controller ...@@ -200,7 +200,7 @@ class PhpDocController extends Controller
} }
} }
$finalDoc = ''; $finalDoc = '';
foreach($lines as $i => $line) { foreach ($lines as $i => $line) {
$finalDoc .= $line . "\n"; $finalDoc .= $line . "\n";
if ($i == $propertyPosition) { if ($i == $propertyPosition) {
$finalDoc .= $properties; $finalDoc .= $properties;
......
...@@ -89,7 +89,7 @@ class BlogController extends Controller ...@@ -89,7 +89,7 @@ class BlogController extends Controller
$post = Post::find($id); $post = Post::find($id);
$text = $post->text; $text = $post->text;
if($version) { if ($version) {
$text = $post->getHistory($version); $text = $post->getHistory($version);
} }
...@@ -121,13 +121,13 @@ class BlogController extends Controller ...@@ -121,13 +121,13 @@ class BlogController extends Controller
public function actionUpdate($id) public function actionUpdate($id)
{ {
$post = Post::find($id); $post = Post::find($id);
if(!$post) { if (!$post) {
throw new HttpException(404); throw new HttpException(404);
} }
if(\Yii::$app->request->isPost)) { if (\Yii::$app->request->isPost)) {
$post->load($_POST); $post->load($_POST);
if($post->save()) { if ($post->save()) {
$this->redirect(['view', 'id' => $post->id]); $this->redirect(['view', 'id' => $post->id]);
} }
} }
......
...@@ -179,7 +179,7 @@ $model->save(); ...@@ -179,7 +179,7 @@ $model->save();
$postTags = []; $postTags = [];
$tagsCount = count($_POST['PostTag']); $tagsCount = count($_POST['PostTag']);
while($tagsCount-- > 0){ while ($tagsCount-- > 0) {
$postTags[] = new PostTag(['post_id' => $model->id]); $postTags[] = new PostTag(['post_id' => $model->id]);
} }
Model::loadMultiple($postTags, $_POST); Model::loadMultiple($postTags, $_POST);
......
...@@ -305,7 +305,7 @@ Then we're using it in `index.php` view where we display a list of users: ...@@ -305,7 +305,7 @@ Then we're using it in `index.php` view where we display a list of users:
```php ```php
<div class="user-index"> <div class="user-index">
<?php <?php
foreach($users as $user) { foreach ($users as $user) {
echo $this->render('_profile', [ echo $this->render('_profile', [
'username' => $user->name, 'username' => $user->name,
'tagline' => $user->tagline, 'tagline' => $user->tagline,
......
...@@ -515,7 +515,7 @@ class BaseYii ...@@ -515,7 +515,7 @@ class BaseYii
return self::$app->getI18n()->translate($category, $message, $params, $language ?: self::$app->language); return self::$app->getI18n()->translate($category, $message, $params, $language ?: self::$app->language);
} else { } else {
$p = []; $p = [];
foreach((array) $params as $name => $value) { foreach ((array) $params as $name => $value) {
$p['{' . $name . '}'] = $value; $p['{' . $name . '}'] = $value;
} }
return ($p === []) ? $message : strtr($message, $p); return ($p === []) ? $message : strtr($message, $p);
......
...@@ -519,7 +519,7 @@ class View extends Component ...@@ -519,7 +519,7 @@ class View extends Component
$this->trigger(self::EVENT_END_PAGE); $this->trigger(self::EVENT_END_PAGE);
$content = ob_get_clean(); $content = ob_get_clean();
foreach(array_keys($this->assetBundles) as $bundle) { foreach (array_keys($this->assetBundles) as $bundle) {
$this->registerAssetFiles($bundle); $this->registerAssetFiles($bundle);
} }
echo strtr($content, [ echo strtr($content, [
...@@ -549,7 +549,7 @@ class View extends Component ...@@ -549,7 +549,7 @@ class View extends Component
return; return;
} }
$bundle = $this->assetBundles[$name]; $bundle = $this->assetBundles[$name];
foreach($bundle->depends as $dep) { foreach ($bundle->depends as $dep) {
$this->registerAssetFiles($dep); $this->registerAssetFiles($dep);
} }
$bundle->registerAssetFiles($this); $bundle->registerAssetFiles($this);
......
...@@ -139,7 +139,7 @@ class RedisCache extends Cache ...@@ -139,7 +139,7 @@ class RedisCache extends Cache
$response = $this->_connection->executeCommand('MGET', $keys); $response = $this->_connection->executeCommand('MGET', $keys);
$result = []; $result = [];
$i = 0; $i = 0;
foreach($keys as $key) { foreach ($keys as $key) {
$result[$key] = $response[$i++]; $result[$key] = $response[$i++];
} }
return $result; return $result;
......
...@@ -170,7 +170,7 @@ class ActiveDataProvider extends BaseDataProvider ...@@ -170,7 +170,7 @@ class ActiveDataProvider extends BaseDataProvider
if (($sort = $this->getSort()) !== false && empty($sort->attributes) && $this->query instanceof ActiveQuery) { if (($sort = $this->getSort()) !== false && empty($sort->attributes) && $this->query instanceof ActiveQuery) {
/** @var Model $model */ /** @var Model $model */
$model = new $this->query->modelClass; $model = new $this->query->modelClass;
foreach($model->attributes() as $attribute) { foreach ($model->attributes() as $attribute) {
$sort->attributes[$attribute] = [ $sort->attributes[$attribute] = [
'asc' => [$attribute => Sort::ASC], 'asc' => [$attribute => Sort::ASC],
'desc' => [$attribute => Sort::DESC], 'desc' => [$attribute => Sort::DESC],
......
...@@ -147,7 +147,7 @@ class Schema extends \yii\db\Schema ...@@ -147,7 +147,7 @@ class Schema extends \yii\db\Schema
} }
$foreignKeys = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $table->name); $foreignKeys = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_IMPORTED_KEYS, $table->name);
foreach($foreignKeys as $key) { foreach ($foreignKeys as $key) {
if (isset($table->foreignKeys[$key['FK_NAME']])) { if (isset($table->foreignKeys[$key['FK_NAME']])) {
$table->foreignKeys[$key['FK_NAME']][$key['FKCOLUMN_NAME']] = $key['PKCOLUMN_NAME']; $table->foreignKeys[$key['FK_NAME']][$key['FKCOLUMN_NAME']] = $key['PKCOLUMN_NAME'];
} else { } else {
...@@ -230,7 +230,7 @@ class Schema extends \yii\db\Schema ...@@ -230,7 +230,7 @@ class Schema extends \yii\db\Schema
$this->db->open(); $this->db->open();
$tables = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE); $tables = $this->db->pdo->cubrid_schema(\PDO::CUBRID_SCH_TABLE);
$tableNames = []; $tableNames = [];
foreach($tables as $table) { foreach ($tables as $table) {
// do not list system tables // do not list system tables
if ($table['TYPE'] != 0) { if ($table['TYPE'] != 0) {
$tableNames[] = $table['NAME']; $tableNames[] = $table['NAME'];
......
...@@ -17,7 +17,7 @@ public function action<?= Inflector::id2camel(trim(basename($generator->viewName ...@@ -17,7 +17,7 @@ public function action<?= Inflector::id2camel(trim(basename($generator->viewName
$model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "" : "(['scenario' => '{$generator->scenarioName}'])" ?>; $model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "" : "(['scenario' => '{$generator->scenarioName}'])" ?>;
if ($model->load($_POST)) { if ($model->load($_POST)) {
if($model->validate()) { if ($model->validate()) {
// form inputs are valid, do something here // form inputs are valid, do something here
return; return;
} }
......
...@@ -34,19 +34,19 @@ foreach ($generator->templates as $name => $path) { ...@@ -34,19 +34,19 @@ foreach ($generator->templates as $name => $path) {
]); ?> ]); ?>
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
<?=$this->renderFile($generator->formView(), [ <?= $this->renderFile($generator->formView(), [
'generator' => $generator, 'generator' => $generator,
'form' => $form, 'form' => $form,
]); ?> ]) ?>
<?=$form->field($generator, 'template')->sticky() <?= $form->field($generator, 'template')->sticky()
->label('Code Template') ->label('Code Template')
->dropDownList($templates)->hint(' ->dropDownList($templates)->hint('
Please select which set of the templates should be used to generated the code. Please select which set of the templates should be used to generated the code.
'); ?> ') ?>
<div class="form-group"> <div class="form-group">
<?= Html::submitButton('Preview', ['name' => 'preview', 'class' => 'btn btn-primary']) ?> <?= Html::submitButton('Preview', ['name' => 'preview', 'class' => 'btn btn-primary']) ?>
<?php if(isset($files)): ?> <?php if (isset($files)): ?>
<?= Html::submitButton('Generate', ['name' => 'generate', 'class' => 'btn btn-success']) ?> <?= Html::submitButton('Generate', ['name' => 'generate', 'class' => 'btn btn-success']) ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
......
...@@ -190,7 +190,7 @@ class MessageFormatter extends Component ...@@ -190,7 +190,7 @@ class MessageFormatter extends Component
$pattern = $parts[0]; $pattern = $parts[0];
$d = 0; $d = 0;
$stack = []; $stack = [];
for($i = 1; $i < $c; $i++) { for ($i = 1; $i < $c; $i++) {
if (preg_match('~^(\s*)([\d\w]+)(\s*)([},])(\s*)(.*)$~us', $parts[$i], $matches)) { if (preg_match('~^(\s*)([\d\w]+)(\s*)([},])(\s*)(.*)$~us', $parts[$i], $matches)) {
// if we are not inside a plural or select this is a message // if we are not inside a plural or select this is a message
if (!isset($stack[$d]) || $stack[$d] != 'plural' && $stack[$d] != 'select') { if (!isset($stack[$d]) || $stack[$d] != 'plural' && $stack[$d] != 'select') {
...@@ -257,7 +257,7 @@ class MessageFormatter extends Component ...@@ -257,7 +257,7 @@ class MessageFormatter extends Component
return [$pattern]; return [$pattern];
} }
$tokens = [mb_substr($pattern, 0, $pos)]; $tokens = [mb_substr($pattern, 0, $pos)];
while(true) { while (true) {
$open = mb_strpos($pattern, '{', $pos + 1); $open = mb_strpos($pattern, '{', $pos + 1);
$close = mb_strpos($pattern, '}', $pos + 1); $close = mb_strpos($pattern, '}', $pos + 1);
if ($open === false && $close === false) { if ($open === false && $close === false) {
...@@ -326,7 +326,7 @@ class MessageFormatter extends Component ...@@ -326,7 +326,7 @@ class MessageFormatter extends Component
$select = static::tokenizePattern($token[2]); $select = static::tokenizePattern($token[2]);
$c = count($select); $c = count($select);
$message = false; $message = false;
for($i = 0; $i + 1 < $c; $i++) { for ($i = 0; $i + 1 < $c; $i++) {
if (is_array($select[$i]) || !is_array($select[$i + 1])) { if (is_array($select[$i]) || !is_array($select[$i + 1])) {
return false; return false;
} }
...@@ -352,7 +352,7 @@ class MessageFormatter extends Component ...@@ -352,7 +352,7 @@ class MessageFormatter extends Component
$c = count($plural); $c = count($plural);
$message = false; $message = false;
$offset = 0; $offset = 0;
for($i = 0; $i + 1 < $c; $i++) { for ($i = 0; $i + 1 < $c; $i++) {
if (is_array($plural[$i]) || !is_array($plural[$i + 1])) { if (is_array($plural[$i]) || !is_array($plural[$i + 1])) {
return false; return false;
} }
......
...@@ -384,7 +384,7 @@ class Connection extends Component ...@@ -384,7 +384,7 @@ class Connection extends Component
private function parseResponse($command) private function parseResponse($command)
{ {
if(($line = fgets($this->_socket)) === false) { if (($line = fgets($this->_socket)) === false) {
throw new Exception("Failed to read from socket.\nRedis command was: " . $command); throw new Exception("Failed to read from socket.\nRedis command was: " . $command);
} }
$type = $line[0]; $type = $line[0];
...@@ -405,7 +405,7 @@ class Connection extends Component ...@@ -405,7 +405,7 @@ class Connection extends Component
$length = $line + 2; $length = $line + 2;
$data = ''; $data = '';
while ($length > 0) { while ($length > 0) {
if(($block = fread($this->_socket, $line + 2)) === false) { if (($block = fread($this->_socket, $line + 2)) === false) {
throw new Exception("Failed to read from socket.\nRedis command was: " . $command); throw new Exception("Failed to read from socket.\nRedis command was: " . $command);
} }
$data .= $block; $data .= $block;
...@@ -415,7 +415,7 @@ class Connection extends Component ...@@ -415,7 +415,7 @@ class Connection extends Component
case '*': // Multi-bulk replies case '*': // Multi-bulk replies
$count = (int) $line; $count = (int) $line;
$data = []; $data = [];
for($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$data[] = $this->parseResponse($command); $data[] = $this->parseResponse($command);
} }
return $data; return $data;
......
...@@ -24,11 +24,11 @@ class RedisCacheTest extends CacheTestCase ...@@ -24,11 +24,11 @@ class RedisCacheTest extends CacheTestCase
'dataTimeout' => 0.1, 'dataTimeout' => 0.1,
]; ];
$dsn = $config['hostname'] . ':' .$config['port']; $dsn = $config['hostname'] . ':' .$config['port'];
if(!@stream_socket_client($dsn, $errorNumber, $errorDescription, 0.5)) { if (!@stream_socket_client($dsn, $errorNumber, $errorDescription, 0.5)) {
$this->markTestSkipped('No redis server running at ' . $dsn .' : ' . $errorNumber . ' - ' . $errorDescription); $this->markTestSkipped('No redis server running at ' . $dsn .' : ' . $errorNumber . ' - ' . $errorDescription);
} }
if($this->_cacheInstance === null) { if ($this->_cacheInstance === null) {
$this->_cacheInstance = new RedisCache($config); $this->_cacheInstance = new RedisCache($config);
} }
return $this->_cacheInstance; return $this->_cacheInstance;
......
...@@ -73,7 +73,7 @@ class ConsoleTest extends TestCase ...@@ -73,7 +73,7 @@ class ConsoleTest extends TestCase
/* public function testScreenSize() /* public function testScreenSize()
{ {
for($i = 1; $i < 20; $i++) { for ($i = 1; $i < 20; $i++) {
echo implode(', ', Console::getScreenSize(true)) . "\n"; echo implode(', ', Console::getScreenSize(true)) . "\n";
ob_flush(); ob_flush();
sleep(1); sleep(1);
......
...@@ -59,7 +59,7 @@ class UrlValidatorTest extends TestCase ...@@ -59,7 +59,7 @@ class UrlValidatorTest extends TestCase
public function testValidateWithIdn() public function testValidateWithIdn()
{ {
if(!function_exists('idn_to_ascii')) { if (!function_exists('idn_to_ascii')) {
$this->markTestSkipped('intl package required'); $this->markTestSkipped('intl package required');
return; return;
} }
......
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