Commit 94844231 by Qiang Xue

Merge pull request #2672 from lucianobaraglia/code-style-fixes

Code style fixes
parents 80cb3e71 269d1303
......@@ -25,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title;
to view the mail message on the mail panel of the debugger.
<?php if (Yii::$app->mail->useFileTransport): ?>
Because the application is in development mode, the email is not sent but saved as
a file under <code><?= Yii::getAlias(Yii::$app->mail->fileTransportPath); ?></code>.
a file under <code><?= Yii::getAlias(Yii::$app->mail->fileTransportPath) ?></code>.
Please configure the <code>useFileTransport</code> property of the <code>mail</code>
application component to be false to enable email sending.
<?php endif; ?>
......
......@@ -56,7 +56,7 @@ class ApiController extends BaseController
if (file_exists($referenceFile)) {
$renderer->guideUrl = $guideUrl;
$renderer->guideReferences = [];
foreach(explode("\n", file_get_contents($referenceFile)) as $reference) {
foreach (explode("\n", file_get_contents($referenceFile)) as $reference) {
$renderer->guideReferences[BaseRenderer::GUIDE_PREFIX . $reference]['url'] = $renderer->generateGuideUrl($reference);
}
}
......@@ -69,7 +69,7 @@ class ApiController extends BaseController
// load context from cache
$context = $this->loadContext($targetDir);
$this->stdout('Checking for updated files... ');
foreach($context->files as $file => $sha) {
foreach ($context->files as $file => $sha) {
if (!file_exists($file)) {
$this->stdout('At least one file has been removed. Rebuilding the context...');
$context = new Context();
......@@ -89,7 +89,7 @@ class ApiController extends BaseController
$this->stdout($fileCount . ' file' . ($fileCount == 1 ? '' : 's') . ' to update.' . PHP_EOL);
Console::startProgress(0, $fileCount, 'Processing files... ', false);
$done = 0;
foreach($files as $file) {
foreach ($files as $file) {
$context->addFile($file);
Console::updateProgress(++$done, $fileCount);
}
......
......@@ -63,14 +63,14 @@ class GuideController extends BaseController
$renderer->render($files, $targetDir);
$this->stdout('Publishing images...');
foreach($sourceDirs as $source) {
foreach ($sourceDirs as $source) {
FileHelper::copyDirectory(rtrim($source, '/\\') . '/images', $targetDir . '/images');
}
$this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
// generate api references.txt
$references = [];
foreach($files as $file) {
foreach ($files as $file) {
$references[] = basename($file, '.md');
}
file_put_contents($targetDir . '/guide-references.txt', implode("\n", $references));
......
......@@ -62,8 +62,8 @@ abstract class BaseController extends Controller
$exclude = [];
}
foreach($sourceDirs as $source) {
foreach($this->findFiles($source, $exclude) as $fileName) {
foreach ($sourceDirs as $source) {
foreach ($this->findFiles($source, $exclude) as $fileName) {
$files[$fileName] = $fileName;
}
}
......
......@@ -163,9 +163,9 @@ class Context extends Component
protected function inheritDocs($class)
{
// TODO also for properties?
foreach($class->methods as $m) {
foreach ($class->methods as $m) {
$inheritedMethod = $this->inheritMethodRecursive($m, $class);
foreach(['shortDescription', 'description', 'params', 'return', 'returnType', 'returnTypes', 'exceptions'] as $property) {
foreach (['shortDescription', 'description', 'params', 'return', 'returnType', 'returnTypes', 'exceptions'] as $property) {
if (empty($m->$property)) {
$m->$property = $inheritedMethod->$property;
}
......
......@@ -68,7 +68,7 @@ abstract class BaseRenderer extends Component
$title = null;
}
$links = [];
foreach($types as $type) {
foreach ($types as $type) {
$postfix = '';
if (!is_object($type)) {
if (substr($type, -2, 2) == '[]') {
......
......@@ -40,7 +40,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
$types = array_merge($context->classes, $context->interfaces, $context->traits);
$extTypes = [];
foreach($this->extensions as $k => $ext) {
foreach ($this->extensions as $k => $ext) {
$extType = $this->filterTypes($types, $ext);
if (empty($extType)) {
unset($this->extensions[$k]);
......@@ -56,7 +56,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
$this->controller->stdout('generating extension index files...');
}
foreach($extTypes as $ext => $extType) {
foreach ($extTypes as $ext => $extType) {
$readme = @file_get_contents("https://raw.github.com/yiisoft/yii2-$ext/master/README.md");
$indexFileContent = $this->renderWithLayout($this->indexView, [
'docContext' => $context,
......@@ -108,7 +108,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
break;
}
if($line === null)
if ($line === null)
return $baseUrl . $url;
else
return $baseUrl . $url . '#L' . $line;
......
......@@ -39,7 +39,7 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
$types = array_merge($this->apiContext->classes, $this->apiContext->interfaces, $this->apiContext->traits);
$extTypes = [];
foreach($this->extensions as $k => $ext) {
foreach ($this->extensions as $k => $ext) {
$extType = $this->filterTypes($types, $ext);
if (empty($extType)) {
unset($this->extensions[$k]);
......
......@@ -99,7 +99,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
Console::startProgress(0, $typeCount, 'Rendering files: ', false);
}
$done = 0;
foreach($types as $type) {
foreach ($types as $type) {
$fileContent = $this->renderWithLayout($this->typeView, [
'type' => $type,
'apiContext' => $context,
......@@ -145,7 +145,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
$parents = [];
$parents[] = $this->createTypeLink($class);
while ($class->parentClass !== null) {
if(isset($this->apiContext->classes[$class->parentClass])) {
if (isset($this->apiContext->classes[$class->parentClass])) {
$class = $this->apiContext->classes[$class->parentClass];
$parents[] = $this->createTypeLink($class);
} else {
......@@ -164,8 +164,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{
$interfaces = [];
sort($names, SORT_STRING);
foreach($names as $interface) {
if(isset($this->apiContext->interfaces[$interface])) {
foreach ($names as $interface) {
if (isset($this->apiContext->interfaces[$interface])) {
$interfaces[] = $this->createTypeLink($this->apiContext->interfaces[$interface]);
} else {
$interfaces[] = $this->createTypeLink($interface);
......@@ -182,8 +182,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{
$traits = [];
sort($names, SORT_STRING);
foreach($names as $trait) {
if(isset($this->apiContext->traits[$trait])) {
foreach ($names as $trait) {
if (isset($this->apiContext->traits[$trait])) {
$traits[] = $this->createTypeLink($this->apiContext->traits[$trait]);
} else {
$traits[] = $this->createTypeLink($trait);
......@@ -200,8 +200,8 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
{
$classes = [];
sort($names, SORT_STRING);
foreach($names as $class) {
if(isset($this->apiContext->classes[$class])) {
foreach ($names as $class) {
if (isset($this->apiContext->classes[$class])) {
$classes[] = $this->createTypeLink($this->apiContext->classes[$class]);
} else {
$classes[] = $this->createTypeLink($class);
......@@ -237,7 +237,7 @@ class ApiRenderer extends BaseApiRenderer implements ViewContextInterface
public function renderMethodSignature($method)
{
$params = [];
foreach($method->params as $param) {
foreach ($method->params as $param) {
$params[] = (empty($param->typeHint) ? '' : $param->typeHint . ' ')
. ($param->isPassedByReference ? '<b>&</b>' : '')
. $param->name
......
......@@ -78,7 +78,7 @@ abstract class GuideRenderer extends BaseGuideRenderer
$done = 0;
$fileData = [];
$headlines = [];
foreach($files as $file) {
foreach ($files as $file) {
$fileData[$file] = file_get_contents($file);
if (basename($file) == 'index.md') {
continue; // to not add index file to nav
......@@ -90,7 +90,7 @@ abstract class GuideRenderer extends BaseGuideRenderer
}
}
foreach($fileData as $file => $content) {
foreach ($fileData as $file => $content) {
$output = ApiMarkdown::process($content); // TODO generate links to yiiframework.com by default
$output = $this->fixMarkdownLinks($output);
if ($this->layout !== false) {
......
......@@ -32,8 +32,8 @@ ArrayHelper::multisort($events, 'name');
<?php echo $event->trigger->signature; ?>
</div>*/ ?>
<?= ApiMarkdown::process($event->description, $type); ?>
<?= ApiMarkdown::process($event->description, $type) ?>
<?= $this->render('seeAlso', ['object' => $event]); ?>
<?= $this->render('seeAlso', ['object' => $event]) ?>
<?php endforeach; ?>
......@@ -48,9 +48,9 @@ ArrayHelper::multisort($methods, 'name');
<?php endforeach; ?>
<?php if (!empty($method->return)): ?>
<tr>
<th class="paramNameCol"><?= 'return'; ?></th>
<td class="paramTypeCol"><?= $renderer->createTypeLink($method->returnTypes); ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($method->return, $type); ?></td>
<th class="paramNameCol"><?= 'return' ?></th>
<td class="paramTypeCol"><?= $renderer->createTypeLink($method->returnTypes) ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($method->return, $type) ?></td>
</tr>
<?php endif; ?>
<?php foreach ($method->exceptions as $exception => $description): ?>
......@@ -61,7 +61,7 @@ ArrayHelper::multisort($methods, 'name');
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if(($sourceUrl = $renderer->getSourceUrl($method->definedBy, $method->startLine)) !== null): ?>
<?php if (($sourceUrl = $renderer->getSourceUrl($method->definedBy, $method->startLine)) !== null): ?>
<tr>
<td colspan="3">Source Code: <a href="<?= $sourceUrl ?>"><?= $sourceUrl ?></a></td>
</tr>
......@@ -73,6 +73,6 @@ ArrayHelper::multisort($methods, 'name');
<p><strong><?= ApiMarkdown::process($method->shortDescription, $type, true) ?></strong></p>
<?= ApiMarkdown::process($method->description, $type) ?>
<?= $this->render('seeAlso', ['object' => $method]); ?>
<?= $this->render('seeAlso', ['object' => $method]) ?>
<?php endforeach; ?>
......@@ -40,6 +40,6 @@ ArrayHelper::multisort($properties, 'name');
<?= ApiMarkdown::process($property->description, $type) ?>
<?= $this->render('seeAlso', ['object' => $property]); ?>
<?= $this->render('seeAlso', ['object' => $property]) ?>
<?php endforeach; ?>
......@@ -71,7 +71,7 @@ $renderer = $this->context;
<?php if (!empty($type->since)): ?>
<tr><th>Available since version</th><td><?= $type->since ?></td></tr>
<?php endif; ?>
<?php if(($sourceUrl = $renderer->getSourceUrl($type)) !== null): ?>
<?php if (($sourceUrl = $renderer->getSourceUrl($type)) !== null): ?>
<tr>
<th>Source Code</th>
<td><a href="<?= $sourceUrl ?>"><?= $sourceUrl ?></a></td>
......
......@@ -26,11 +26,11 @@ $redirectJavaScript .= 'popupWindowRedirect(' . Json::encode($url) . ', ' . Json
<!DOCTYPE html>
<html>
<head>
<?= Html::script($redirectJavaScript); ?>
<?= Html::script($redirectJavaScript) ?>
</head>
<body>
<h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name; ?>&quot;...</h2>
<h3 id="link"><a href="<?= $url; ?>">Click here to return to the &quot;<?= Yii::$app->name; ?>&quot;.</a></h3>
<h2 id="title" style="display:none;">Redirecting back to the &quot;<?= Yii::$app->name ?>&quot;...</h2>
<h3 id="link"><a href="<?= $url ?>">Click here to return to the &quot;<?= Yii::$app->name ?>&quot;.</a></h3>
<script type="text/javascript">
document.getElementById('title').style.display = '';
document.getElementById('link').style.display = 'none';
......
......@@ -39,7 +39,7 @@ use yii\authclient\ClientInterface;
* ]); ?>
* <ul>
* <?php foreach ($authChoice->getClients() as $client): ?>
* <li><?= $authChoice->clientLink($client); ?></li>
* <li><?= $authChoice->clientLink($client) ?></li>
* <?php endforeach; ?>
* </ul>
* <?php Choice::end(); ?>
......
......@@ -439,7 +439,7 @@ class ActiveRecord extends BaseActiveRecord
// TODO do this via command
$url = [static::index(), static::type(), '_bulk'];
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$n = 0;
$errors = [];
foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) {
......@@ -502,7 +502,7 @@ class ActiveRecord extends BaseActiveRecord
// TODO do this via command
$url = [static::index(), static::type(), '_bulk'];
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$n = 0;
$errors = [];
foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) {
......@@ -556,7 +556,7 @@ class ActiveRecord extends BaseActiveRecord
// TODO do this via command
$url = [static::index(), static::type(), '_bulk'];
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$n = 0;
$errors = [];
foreach ($response['items'] as $item) {
if (isset($item['delete']['error'])) {
......
......@@ -245,7 +245,7 @@ class Connection extends Component
return mb_strlen($data, '8bit');
},
CURLOPT_HEADERFUNCTION => function($curl, $data) use (&$headers) {
foreach(explode("\r\n", $data) as $row) {
foreach (explode("\r\n", $data) as $row) {
if (($pos = strpos($row, ':')) !== false) {
$headers[strtolower(substr($row, 0, $pos))] = trim(substr($row, $pos + 1));
}
......
......@@ -7,9 +7,9 @@
* @var string $tableName full table name
* @var string $className class name
* @var yii\db\TableSchema $tableSchema
* @var string[] $labels list of attribute labels (name=>label)
* @var string[] $labels list of attribute labels (name => label)
* @var string[] $rules list of validation rules
* @var array $relations list of relations (name=>relation declaration)
* @var array $relations list of relations (name => relation declaration)
*/
echo "<?php\n";
......
......@@ -59,7 +59,7 @@ class ActiveRecord extends BaseActiveRecord
* You may also define default conditions that should apply to all queries unless overridden:
*
* ```php
* public static function createQuery($config= [])
* public static function createQuery($config = [])
* {
* return parent::createQuery($config)->where(['deleted' => false]);
* }
......@@ -171,7 +171,7 @@ class ActiveRecord extends BaseActiveRecord
return 0;
}
$db = static::getDb();
$n=0;
$n = 0;
foreach (static::fetchPks($condition) as $pk) {
$newPk = $pk;
$pk = static::buildKey($pk);
......@@ -223,7 +223,7 @@ class ActiveRecord extends BaseActiveRecord
return 0;
}
$db = static::getDb();
$n=0;
$n = 0;
foreach (static::fetchPks($condition) as $pk) {
$key = static::keyPrefix() . ':a:' . static::buildKey($pk);
foreach ($counters as $attribute => $value) {
......
......@@ -49,7 +49,7 @@ class Column extends Object
/**
* @var array the HTML attributes for the filter cell tag.
*/
public $filterOptions=[];
public $filterOptions = [];
/**
......
......@@ -57,7 +57,7 @@ class SchemaTest extends SphinxTestCase
[1337, \PDO::PARAM_INT],
[true, \PDO::PARAM_BOOL],
[false, \PDO::PARAM_BOOL],
[$fp=fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
[$fp = fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
];
$schema = $this->getConnection()->schema;
......
......@@ -70,7 +70,7 @@ class MessageControllerTest extends TestCase
} else {
$dirHandle = opendir($fileSystemObjectFullName);
while (($fileSystemObjectName = readdir($dirHandle)) !== false) {
if ($fileSystemObjectName==='.' || $fileSystemObjectName==='..') {
if ($fileSystemObjectName === '.' || $fileSystemObjectName === '..') {
continue;
}
$this->removeFileSystemObject($fileSystemObjectFullName . DIRECTORY_SEPARATOR . $fileSystemObjectName);
......
......@@ -79,7 +79,7 @@ class SchemaTest extends DatabaseTestCase
[1337, \PDO::PARAM_INT],
[true, \PDO::PARAM_BOOL],
[false, \PDO::PARAM_BOOL],
[$fp=fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
[$fp = fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
];
/** @var Schema $schema */
......
......@@ -22,7 +22,7 @@ class CubridSchemaTest extends SchemaTest
[1337, \PDO::PARAM_INT],
[true, \PDO::PARAM_INT],
[false, \PDO::PARAM_INT],
[$fp=fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
[$fp = fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
];
/** @var Schema $schema */
......
......@@ -173,7 +173,7 @@ class FileValidatorTest extends TestCase
$this->assertTrue($m->hasErrors('attr_files_empty'));
$this->assertSame($val->uploadRequired, current($m->getErrors('attr_files_empty')));
// single File with skipOnEmpty=false
// single File with skipOnEmpty = false
$val = new FileValidator(['skipOnEmpty' => false]);
$m = $this->createModelForAttributeTest();
$val->validateAttribute($m, 'attr_files');
......
......@@ -34,7 +34,7 @@ class SpacelessTest extends \yiiunit\TestCase
echo "\t<p>Bye!</p>\n";
echo "</body>\n";
$expected="<body>\n<div class='wrapper'><div class='left-column'><p>This is a left bar!</p>".
$expected = "<body>\n<div class='wrapper'><div class='left-column'><p>This is a left bar!</p>".
"</div><div class='right-column'><p>This is a right bar!</p></div></div>\t<p>Bye!</p>\n</body>\n";
$this->assertEquals($expected, ob_get_clean());
}
......
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