Commit 95ea1c20 by Alexander Mohorev

code style. FOREACH

parent b2f1b00b
...@@ -25,7 +25,7 @@ use yii\widgets\ActiveForm; ...@@ -25,7 +25,7 @@ use yii\widgets\ActiveForm;
$this->title = 'Posts'; $this->title = 'Posts';
?> ?>
<!-- Separate PHP blocks are preferred for foreach, for, if etc. --> <!-- Separate PHP blocks are preferred for foreach, for, if etc. -->
<?php foreach($posts as $post): ?> <?php foreach ($posts as $post): ?>
<!-- Note indentation level here. --> <!-- Note indentation level here. -->
<h2><?= Html::encode($post['title']) ?></h2> <h2><?= Html::encode($post['title']) ?></h2>
<p><?= Html::encode($post['shortDescription']) ?></p> <p><?= Html::encode($post['shortDescription']) ?></p>
......
...@@ -15,7 +15,7 @@ $composerAutoload = [ ...@@ -15,7 +15,7 @@ $composerAutoload = [
__DIR__ . '/../../autoload.php', // script is installed as a composer binary __DIR__ . '/../../autoload.php', // script is installed as a composer binary
]; ];
$vendorPath = null; $vendorPath = null;
foreach($composerAutoload as $autoload) { foreach ($composerAutoload as $autoload) {
if (file_exists($autoload)) { if (file_exists($autoload)) {
require($autoload); require($autoload);
$vendorPath = dirname($autoload); $vendorPath = dirname($autoload);
...@@ -27,7 +27,7 @@ $yiiDirs = [ ...@@ -27,7 +27,7 @@ $yiiDirs = [
__DIR__ . '/vendor/yiisoft/yii2', // standalone with "composer install" run __DIR__ . '/vendor/yiisoft/yii2', // standalone with "composer install" run
__DIR__ . '/../../yiisoft/yii2', // script is installed as a composer binary __DIR__ . '/../../yiisoft/yii2', // script is installed as a composer binary
]; ];
foreach($yiiDirs as $dir) { foreach ($yiiDirs as $dir) {
if (file_exists($dir . '/Yii.php')) { if (file_exists($dir . '/Yii.php')) {
require($dir . '/Yii.php'); require($dir . '/Yii.php');
break; break;
......
...@@ -58,8 +58,8 @@ class RenderController extends Controller ...@@ -58,8 +58,8 @@ class RenderController extends Controller
$this->stdout('Searching files to process... '); $this->stdout('Searching files to process... ');
$files = []; $files = [];
foreach($sourceDirs as $source) { foreach ($sourceDirs as $source) {
foreach($this->findFiles($source) as $fileName) { foreach ($this->findFiles($source) as $fileName) {
$files[$fileName] = $fileName; $files[$fileName] = $fileName;
} }
} }
...@@ -80,7 +80,7 @@ class RenderController extends Controller ...@@ -80,7 +80,7 @@ class RenderController extends Controller
$this->stdout('done.' . PHP_EOL, Console::FG_GREEN); $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
$this->stdout('Checking for updated files... '); $this->stdout('Checking for updated files... ');
foreach($context->files as $file => $sha) { foreach ($context->files as $file => $sha) {
if (sha1_file($file) === $sha) { if (sha1_file($file) === $sha) {
unset($files[$file]); unset($files[$file]);
} }
...@@ -92,7 +92,7 @@ class RenderController extends Controller ...@@ -92,7 +92,7 @@ class RenderController extends Controller
$this->stdout($fileCount . ' file' . ($fileCount == 1 ? '' : 's') . ' to update.' . PHP_EOL); $this->stdout($fileCount . ' file' . ($fileCount == 1 ? '' : 's') . ' to update.' . PHP_EOL);
Console::startProgress(0, $fileCount, 'Processing files... ', false); Console::startProgress(0, $fileCount, 'Processing files... ', false);
$done = 0; $done = 0;
foreach($files as $file) { foreach ($files as $file) {
$context->addFile($file); $context->addFile($file);
Console::updateProgress(++$done, $fileCount); Console::updateProgress(++$done, $fileCount);
} }
......
...@@ -76,7 +76,7 @@ class BaseDoc extends Object ...@@ -76,7 +76,7 @@ class BaseDoc extends Object
$this->phpDocContext = $docblock->getContext(); $this->phpDocContext = $docblock->getContext();
$this->tags = $docblock->getTags(); $this->tags = $docblock->getTags();
foreach($this->tags as $i => $tag) { foreach ($this->tags as $i => $tag) {
if ($tag instanceof SinceTag) { if ($tag instanceof SinceTag) {
$this->since = $tag->getVersion(); $this->since = $tag->getVersion();
unset($this->tags[$i]); unset($this->tags[$i]);
......
...@@ -45,12 +45,12 @@ class ClassDoc extends TypeDoc ...@@ -45,12 +45,12 @@ class ClassDoc extends TypeDoc
if (($subject = parent::findSubject($subjectName)) !== null) { if (($subject = parent::findSubject($subjectName)) !== null) {
return $subject; return $subject;
} }
foreach($this->events as $name => $event) { foreach ($this->events as $name => $event) {
if ($subjectName == $name) { if ($subjectName == $name) {
return $event; return $event;
} }
} }
foreach($this->constants as $name => $constant) { foreach ($this->constants as $name => $constant) {
if ($subjectName == $name) { if ($subjectName == $name) {
return $constant; return $constant;
} }
...@@ -64,7 +64,7 @@ class ClassDoc extends TypeDoc ...@@ -64,7 +64,7 @@ class ClassDoc extends TypeDoc
public function getNativeEvents() public function getNativeEvents()
{ {
$events = []; $events = [];
foreach($this->events as $name => $event) { foreach ($this->events as $name => $event) {
if ($event->definedBy != $this->name) { if ($event->definedBy != $this->name) {
continue; continue;
} }
...@@ -93,13 +93,13 @@ class ClassDoc extends TypeDoc ...@@ -93,13 +93,13 @@ class ClassDoc extends TypeDoc
$this->isAbstract = $reflector->isAbstract(); $this->isAbstract = $reflector->isAbstract();
$this->isFinal = $reflector->isFinal(); $this->isFinal = $reflector->isFinal();
foreach($reflector->getInterfaces() as $interface) { foreach ($reflector->getInterfaces() as $interface) {
$this->interfaces[] = ltrim($interface, '\\'); $this->interfaces[] = ltrim($interface, '\\');
} }
foreach($reflector->getTraits() as $trait) { foreach ($reflector->getTraits() as $trait) {
$this->traits[] = ltrim($trait, '\\'); $this->traits[] = ltrim($trait, '\\');
} }
foreach($reflector->getConstants() as $constantReflector) { foreach ($reflector->getConstants() as $constantReflector) {
$docblock = $constantReflector->getDocBlock(); $docblock = $constantReflector->getDocBlock();
if ($docblock !== null && count($docblock->getTagsByName('event')) > 0) { if ($docblock !== null && count($docblock->getTagsByName('event')) > 0) {
$event = new EventDoc($constantReflector); $event = new EventDoc($constantReflector);
......
...@@ -57,15 +57,15 @@ class Context extends Component ...@@ -57,15 +57,15 @@ class Context extends Component
$reflection = new FileReflector($fileName, true); $reflection = new FileReflector($fileName, true);
$reflection->process(); $reflection->process();
foreach($reflection->getClasses() as $class) { foreach ($reflection->getClasses() as $class) {
$class = new ClassDoc($class, $this, ['sourceFile' => $fileName]); $class = new ClassDoc($class, $this, ['sourceFile' => $fileName]);
$this->classes[$class->name] = $class; $this->classes[$class->name] = $class;
} }
foreach($reflection->getInterfaces() as $interface) { foreach ($reflection->getInterfaces() as $interface) {
$interface = new InterfaceDoc($interface, $this, ['sourceFile' => $fileName]); $interface = new InterfaceDoc($interface, $this, ['sourceFile' => $fileName]);
$this->interfaces[$interface->name] = $interface; $this->interfaces[$interface->name] = $interface;
} }
foreach($reflection->getTraits() as $trait) { foreach ($reflection->getTraits() as $trait) {
$trait = new TraitDoc($trait, $this, ['sourceFile' => $fileName]); $trait = new TraitDoc($trait, $this, ['sourceFile' => $fileName]);
$this->traits[$trait->name] = $trait; $this->traits[$trait->name] = $trait;
} }
...@@ -74,7 +74,7 @@ class Context extends Component ...@@ -74,7 +74,7 @@ class Context extends Component
public function updateReferences() public function updateReferences()
{ {
// update all subclass references // update all subclass references
foreach($this->classes as $class) { foreach ($this->classes as $class) {
$className = $class->name; $className = $class->name;
while (isset($this->classes[$class->parentClass])) { while (isset($this->classes[$class->parentClass])) {
$class = $this->classes[$class->parentClass]; $class = $this->classes[$class->parentClass];
...@@ -82,12 +82,12 @@ class Context extends Component ...@@ -82,12 +82,12 @@ class Context extends Component
} }
} }
// update interfaces of subclasses // update interfaces of subclasses
foreach($this->classes as $class) { foreach ($this->classes as $class) {
$this->updateSubclassInferfacesTraits($class); $this->updateSubclassInferfacesTraits($class);
} }
// update implementedBy and usedBy for interfaces and traits // update implementedBy and usedBy for interfaces and traits
foreach($this->classes as $class) { foreach ($this->classes as $class) {
foreach($class->traits as $trait) { foreach ($class->traits as $trait) {
if (isset($this->traits[$trait])) { if (isset($this->traits[$trait])) {
$trait = $this->traits[$trait]; $trait = $this->traits[$trait];
$trait->usedBy[] = $class->name; $trait->usedBy[] = $class->name;
...@@ -95,12 +95,12 @@ class Context extends Component ...@@ -95,12 +95,12 @@ class Context extends Component
$class->methods = array_merge($trait->methods, $class->methods); $class->methods = array_merge($trait->methods, $class->methods);
} }
} }
foreach($class->interfaces as $interface) { foreach ($class->interfaces as $interface) {
if (isset($this->interfaces[$interface])) { if (isset($this->interfaces[$interface])) {
$this->interfaces[$interface]->implementedBy[] = $class->name; $this->interfaces[$interface]->implementedBy[] = $class->name;
if ($class->isAbstract) { if ($class->isAbstract) {
// add not implemented interface methods // add not implemented interface methods
foreach($this->interfaces[$interface]->methods as $method) { foreach ($this->interfaces[$interface]->methods as $method) {
if (!isset($class->methods[$method->name])) { if (!isset($class->methods[$method->name])) {
$class->methods[$method->name] = $method; $class->methods[$method->name] = $method;
} }
...@@ -110,11 +110,11 @@ class Context extends Component ...@@ -110,11 +110,11 @@ class Context extends Component
} }
} }
// inherit properties, methods, contants and events to subclasses // inherit properties, methods, contants and events to subclasses
foreach($this->classes as $class) { foreach ($this->classes as $class) {
$this->updateSubclassInheritance($class); $this->updateSubclassInheritance($class);
} }
// add properties from getters and setters // add properties from getters and setters
foreach($this->classes as $class) { foreach ($this->classes as $class) {
$this->handlePropertyFeature($class); $this->handlePropertyFeature($class);
} }
...@@ -127,7 +127,7 @@ class Context extends Component ...@@ -127,7 +127,7 @@ class Context extends Component
*/ */
protected function updateSubclassInferfacesTraits($class) protected function updateSubclassInferfacesTraits($class)
{ {
foreach($class->subclasses as $subclass) { foreach ($class->subclasses as $subclass) {
$subclass = $this->classes[$subclass]; $subclass = $this->classes[$subclass];
$subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces)); $subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces));
$subclass->traits = array_unique(array_merge($subclass->traits, $class->traits)); $subclass->traits = array_unique(array_merge($subclass->traits, $class->traits));
...@@ -141,7 +141,7 @@ class Context extends Component ...@@ -141,7 +141,7 @@ class Context extends Component
*/ */
protected function updateSubclassInheritance($class) protected function updateSubclassInheritance($class)
{ {
foreach($class->subclasses as $subclass) { foreach ($class->subclasses as $subclass) {
$subclass = $this->classes[$subclass]; $subclass = $this->classes[$subclass];
$subclass->events = array_merge($class->events, $subclass->events); $subclass->events = array_merge($class->events, $subclass->events);
$subclass->constants = array_merge($class->constants, $subclass->constants); $subclass->constants = array_merge($class->constants, $subclass->constants);
...@@ -160,7 +160,7 @@ class Context extends Component ...@@ -160,7 +160,7 @@ class Context extends Component
if (!$this->isSubclassOf($class, 'yii\base\Object')) { if (!$this->isSubclassOf($class, 'yii\base\Object')) {
return; return;
} }
foreach($class->getPublicMethods() as $name => $method) { foreach ($class->getPublicMethods() as $name => $method) {
if ($method->isStatic) { if ($method->isStatic) {
continue; continue;
} }
...@@ -232,7 +232,7 @@ class Context extends Component ...@@ -232,7 +232,7 @@ class Context extends Component
*/ */
private function paramsOptional($method, $number = 0) private function paramsOptional($method, $number = 0)
{ {
foreach($method->params as $param) { foreach ($method->params as $param) {
if (!$param->isOptional && $number-- <= 0) { if (!$param->isOptional && $number-- <= 0) {
return false; return false;
} }
...@@ -246,7 +246,7 @@ class Context extends Component ...@@ -246,7 +246,7 @@ class Context extends Component
*/ */
private function getFirstNotOptionalParameter($method) private function getFirstNotOptionalParameter($method)
{ {
foreach($method->params as $param) { foreach ($method->params as $param) {
if (!$param->isOptional) { if (!$param->isOptional) {
return $param; return $param;
} }
......
...@@ -34,7 +34,7 @@ class EventDoc extends ConstDoc ...@@ -34,7 +34,7 @@ class EventDoc extends ConstDoc
return; return;
} }
foreach($this->tags as $i => $tag) { foreach ($this->tags as $i => $tag) {
if ($tag->getName() == 'event') { if ($tag->getName() == 'event') {
$eventTag = new ReturnTag('event', $tag->getContent(), $tag->getDocBlock(), $tag->getLocation()); $eventTag = new ReturnTag('event', $tag->getContent(), $tag->getDocBlock(), $tag->getLocation());
$this->type = $eventTag->getType(); $this->type = $eventTag->getType();
......
...@@ -45,12 +45,12 @@ class FunctionDoc extends BaseDoc ...@@ -45,12 +45,12 @@ class FunctionDoc extends BaseDoc
$this->isReturnByReference = $reflector->isByRef(); $this->isReturnByReference = $reflector->isByRef();
foreach($reflector->getArguments() as $arg) { foreach ($reflector->getArguments() as $arg) {
$arg = new ParamDoc($arg, $context, ['sourceFile' => $this->sourceFile]); $arg = new ParamDoc($arg, $context, ['sourceFile' => $this->sourceFile]);
$this->params[$arg->name] = $arg; $this->params[$arg->name] = $arg;
} }
foreach($this->tags as $i => $tag) { foreach ($this->tags as $i => $tag) {
if ($tag instanceof ThrowsTag) { if ($tag instanceof ThrowsTag) {
$this->exceptions[$tag->getType()] = $tag->getDescription(); $this->exceptions[$tag->getType()] = $tag->getDescription();
unset($this->tags[$i]); unset($this->tags[$i]);
......
...@@ -33,11 +33,11 @@ class InterfaceDoc extends TypeDoc ...@@ -33,11 +33,11 @@ class InterfaceDoc extends TypeDoc
return; return;
} }
foreach($reflector->getParentInterfaces() as $interface) { foreach ($reflector->getParentInterfaces() as $interface) {
$this->parentInterfaces[] = ltrim($interface, '\\'); $this->parentInterfaces[] = ltrim($interface, '\\');
} }
foreach($this->methods as $method) { foreach ($this->methods as $method) {
$method->isAbstract = true; $method->isAbstract = true;
} }
......
...@@ -63,7 +63,7 @@ class PropertyDoc extends BaseDoc ...@@ -63,7 +63,7 @@ class PropertyDoc extends BaseDoc
$this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default); $this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
} }
foreach($this->tags as $tag) { foreach ($this->tags as $tag) {
if ($tag instanceof VarTag) { if ($tag instanceof VarTag) {
$this->type = $tag->getType(); $this->type = $tag->getType();
$this->types = $tag->getTypes(); $this->types = $tag->getTypes();
......
...@@ -34,7 +34,7 @@ class TraitDoc extends TypeDoc ...@@ -34,7 +34,7 @@ class TraitDoc extends TypeDoc
return; return;
} }
foreach($reflector->getTraits() as $trait) { foreach ($reflector->getTraits() as $trait) {
$this->traits[] = ltrim($trait, '\\'); $this->traits[] = ltrim($trait, '\\');
} }
} }
......
...@@ -41,7 +41,7 @@ class TypeDoc extends BaseDoc ...@@ -41,7 +41,7 @@ class TypeDoc extends BaseDoc
public function findSubject($subjectName) public function findSubject($subjectName)
{ {
if ($subjectName[0] != '$') { if ($subjectName[0] != '$') {
foreach($this->methods as $name => $method) { foreach ($this->methods as $name => $method) {
if (rtrim($subjectName, '()') == $name) { if (rtrim($subjectName, '()') == $name) {
return $method; return $method;
} }
...@@ -53,7 +53,7 @@ class TypeDoc extends BaseDoc ...@@ -53,7 +53,7 @@ class TypeDoc extends BaseDoc
if ($this->properties === null) { if ($this->properties === null) {
return null; return null;
} }
foreach($this->properties as $name => $property) { foreach ($this->properties as $name => $property) {
if (ltrim($subjectName, '$') == ltrim($name, '$')) { if (ltrim($subjectName, '$') == ltrim($name, '$')) {
return $property; return $property;
} }
...@@ -93,7 +93,7 @@ class TypeDoc extends BaseDoc ...@@ -93,7 +93,7 @@ class TypeDoc extends BaseDoc
private function getFilteredMethods($visibility = null, $definedBy = null) private function getFilteredMethods($visibility = null, $definedBy = null)
{ {
$methods = []; $methods = [];
foreach($this->methods as $name => $method) { foreach ($this->methods as $name => $method) {
if ($visibility !== null && $method->visibility != $visibility) { if ($visibility !== null && $method->visibility != $visibility) {
continue; continue;
} }
...@@ -140,7 +140,7 @@ class TypeDoc extends BaseDoc ...@@ -140,7 +140,7 @@ class TypeDoc extends BaseDoc
return []; return [];
} }
$properties = []; $properties = [];
foreach($this->properties as $name => $property) { foreach ($this->properties as $name => $property) {
if ($visibility !== null && $property->visibility != $visibility) { if ($visibility !== null && $property->visibility != $visibility) {
continue; continue;
} }
...@@ -167,14 +167,14 @@ class TypeDoc extends BaseDoc ...@@ -167,14 +167,14 @@ class TypeDoc extends BaseDoc
return; return;
} }
foreach($this->tags as $i => $tag) { foreach ($this->tags as $i => $tag) {
if ($tag instanceof AuthorTag) { if ($tag instanceof AuthorTag) {
$this->authors[$tag->getAuthorName()] = $tag->getAuthorEmail(); $this->authors[$tag->getAuthorName()] = $tag->getAuthorEmail();
unset($this->tags[$i]); unset($this->tags[$i]);
} }
} }
foreach($reflector->getProperties() as $propertyReflector) { foreach ($reflector->getProperties() as $propertyReflector) {
if ($propertyReflector->getVisibility() != 'private') { if ($propertyReflector->getVisibility() != 'private') {
$property = new PropertyDoc($propertyReflector, $context, ['sourceFile' => $this->sourceFile]); $property = new PropertyDoc($propertyReflector, $context, ['sourceFile' => $this->sourceFile]);
$property->definedBy = $this->name; $property->definedBy = $this->name;
...@@ -182,7 +182,7 @@ class TypeDoc extends BaseDoc ...@@ -182,7 +182,7 @@ class TypeDoc extends BaseDoc
} }
} }
foreach($reflector->getMethods() as $methodReflector) { foreach ($reflector->getMethods() as $methodReflector) {
if ($methodReflector->getVisibility() != 'private') { if ($methodReflector->getVisibility() != 'private') {
$method = new MethodDoc($methodReflector, $context, ['sourceFile' => $this->sourceFile]); $method = new MethodDoc($methodReflector, $context, ['sourceFile' => $this->sourceFile]);
$method->definedBy = $this->name; $method->definedBy = $this->name;
......
...@@ -60,7 +60,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -60,7 +60,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
$types = array_merge($context->classes, $context->interfaces, $context->traits); $types = array_merge($context->classes, $context->interfaces, $context->traits);
$controller->stdout('generating extension index files...'); $controller->stdout('generating extension index files...');
foreach($this->extensions as $ext) { foreach ($this->extensions as $ext) {
$readme = @file_get_contents("https://raw.github.com/yiisoft/yii2-$ext/master/README.md"); $readme = @file_get_contents("https://raw.github.com/yiisoft/yii2-$ext/master/README.md");
$indexFileContent = $this->renderWithLayout($this->indexView, [ $indexFileContent = $this->renderWithLayout($this->indexView, [
'docContext' => $context, 'docContext' => $context,
...@@ -151,7 +151,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -151,7 +151,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
$done = 0; $done = 0;
$fileData = []; $fileData = [];
$headlines = []; $headlines = [];
foreach($files as $file) { foreach ($files as $file) {
$fileData[$file] = file_get_contents($file); $fileData[$file] = file_get_contents($file);
if (basename($file) == 'index.md') { if (basename($file) == 'index.md') {
continue; // to not add index file to nav continue; // to not add index file to nav
...@@ -163,7 +163,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -163,7 +163,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
} }
} }
foreach($fileData as $file => $content) { foreach ($fileData as $file => $content) {
$output = ApiMarkdown::process($content); // TODO generate links to yiiframework.com by default $output = ApiMarkdown::process($content); // TODO generate links to yiiframework.com by default
$output = $this->fixMarkdownLinks($output); $output = $this->fixMarkdownLinks($output);
if ($this->guideLayout !== false) { if ($this->guideLayout !== false) {
...@@ -191,7 +191,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -191,7 +191,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
public function getGuideReferences() public function getGuideReferences()
{ {
$refs = []; $refs = [];
foreach($this->markDownFiles as $file) { foreach ($this->markDownFiles as $file) {
$refName = 'guide-' . basename($file, '.md'); $refName = 'guide-' . basename($file, '.md');
$refs[$refName] = ['url' => $this->generateGuideFileName($file)]; $refs[$refName] = ['url' => $this->generateGuideFileName($file)];
} }
......
...@@ -151,7 +151,7 @@ class SideNavWidget extends \yii\bootstrap\Widget ...@@ -151,7 +151,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
$label .= ' ' . Html::tag('b', '', ['class' => 'caret']); $label .= ' ' . Html::tag('b', '', ['class' => 'caret']);
if (is_array($items)) { if (is_array($items)) {
if ($active === false) { if ($active === false) {
foreach($items as $subItem) { foreach ($items as $subItem) {
if (isset($subItem['active']) && $subItem['active']) { if (isset($subItem['active']) && $subItem['active']) {
$active = true; $active = true;
} }
......
...@@ -14,7 +14,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> ...@@ -14,7 +14,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
$types = $this->context->getNavTypes(isset($type) ? $type : null, $types); $types = $this->context->getNavTypes(isset($type) ? $type : null, $types);
ksort($types); ksort($types);
$nav = []; $nav = [];
foreach($types as $i=>$class) { foreach ($types as $i => $class) {
$namespace = $class->namespace; $namespace = $class->namespace;
if (empty($namespace)) { if (empty($namespace)) {
$namespace = 'Not namespaced classes'; $namespace = 'Not namespaced classes';
......
...@@ -17,7 +17,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> ...@@ -17,7 +17,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
'url' => './guide_index.html', 'url' => './guide_index.html',
'active' => isset($currentFile) && (basename($currentFile) == 'index.md'), 'active' => isset($currentFile) && (basename($currentFile) == 'index.md'),
]; ];
foreach($headlines as $file => $headline) { foreach ($headlines as $file => $headline) {
// if (!isset($nav[$namespace])) { // if (!isset($nav[$namespace])) {
// $nav[$namespace] = [ // $nav[$namespace] = [
// 'label' => $namespace, // 'label' => $namespace,
......
...@@ -46,7 +46,7 @@ $this->beginPage(); ...@@ -46,7 +46,7 @@ $this->beginPage();
'view' => $this, 'view' => $this,
]); ]);
$extItems = []; $extItems = [];
foreach($this->context->extensions as $ext) { foreach ($this->context->extensions as $ext) {
$extItems[] = [ $extItems[] = [
'label' => $ext, 'label' => $ext,
'url' => "./ext_{$ext}_index.html", 'url' => "./ext_{$ext}_index.html",
......
...@@ -26,7 +26,7 @@ if (isset($readme)) { ...@@ -26,7 +26,7 @@ if (isset($readme)) {
</tr> </tr>
<?php <?php
ksort($types); ksort($types);
foreach($types as $i=>$class): foreach ($types as $i => $class):
?> ?>
<tr> <tr>
<td><?= $this->context->typeLink($class, $class->name) ?></td> <td><?= $this->context->typeLink($class, $class->name) ?></td>
......
...@@ -105,7 +105,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -105,7 +105,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$typeCount = count($types) + 1; $typeCount = count($types) + 1;
Console::startProgress(0, $typeCount, 'Rendering files: ', false); Console::startProgress(0, $typeCount, 'Rendering files: ', false);
$done = 0; $done = 0;
foreach($types as $type) { foreach ($types as $type) {
$fileContent = $this->renderWithLayout($this->typeView, [ $fileContent = $this->renderWithLayout($this->typeView, [
'type' => $type, 'type' => $type,
'docContext' => $context, 'docContext' => $context,
...@@ -147,7 +147,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -147,7 +147,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
$types = [$types]; $types = [$types];
} }
$links = []; $links = [];
foreach($types as $type) { foreach ($types as $type) {
$postfix = ''; $postfix = '';
if (!is_object($type)) { if (!is_object($type)) {
if (substr($type, -2, 2) == '[]') { if (substr($type, -2, 2) == '[]') {
...@@ -254,7 +254,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -254,7 +254,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
{ {
$interfaces = []; $interfaces = [];
sort($names, SORT_STRING); sort($names, SORT_STRING);
foreach($names as $interface) { foreach ($names as $interface) {
if (isset($this->context->interfaces[$interface])) { if (isset($this->context->interfaces[$interface])) {
$interfaces[] = $this->typeLink($this->context->interfaces[$interface]); $interfaces[] = $this->typeLink($this->context->interfaces[$interface]);
} else { } else {
...@@ -272,7 +272,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -272,7 +272,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
{ {
$traits = []; $traits = [];
sort($names, SORT_STRING); sort($names, SORT_STRING);
foreach($names as $trait) { foreach ($names as $trait) {
if (isset($this->context->traits[$trait])) { if (isset($this->context->traits[$trait])) {
$traits[] = $this->typeLink($this->context->traits[$trait]); $traits[] = $this->typeLink($this->context->traits[$trait]);
} else { } else {
...@@ -290,7 +290,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -290,7 +290,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
{ {
$classes = []; $classes = [];
sort($names, SORT_STRING); sort($names, SORT_STRING);
foreach($names as $class) { foreach ($names as $class) {
if (isset($this->context->classes[$class])) { if (isset($this->context->classes[$class])) {
$classes[] = $this->typeLink($this->context->classes[$class]); $classes[] = $this->typeLink($this->context->classes[$class]);
} else { } else {
...@@ -326,7 +326,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface ...@@ -326,7 +326,7 @@ abstract class Renderer extends BaseRenderer implements ViewContextInterface
public function renderMethodSignature($method) public function renderMethodSignature($method)
{ {
$params = []; $params = [];
foreach($method->params as $param) { foreach ($method->params as $param) {
$params[] = (empty($param->typeHint) ? '' : $param->typeHint . ' ') $params[] = (empty($param->typeHint) ? '' : $param->typeHint . ' ')
. ($param->isPassedByReference ? '<b>&</b>' : '') . ($param->isPassedByReference ? '<b>&</b>' : '')
. $param->name . $param->name
......
...@@ -29,7 +29,7 @@ ArrayHelper::multisort($constants, 'name'); ...@@ -29,7 +29,7 @@ ArrayHelper::multisort($constants, 'name');
<tr> <tr>
<th>Constant</th><th>Value</th><th>Description</th><th>Defined By</th> <th>Constant</th><th>Value</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($constants as $constant): ?> <?php foreach ($constants as $constant): ?>
<tr<?= $constant->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>"> <tr<?= $constant->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $constant->name ?>">
<td><?= $constant->name ?><a name="<?= $constant->name ?>-detail"></a></td> <td><?= $constant->name ?><a name="<?= $constant->name ?>-detail"></a></td>
<td><?= $constant->value ?></td> <td><?= $constant->value ?></td>
......
...@@ -16,7 +16,7 @@ if (empty($events)) { ...@@ -16,7 +16,7 @@ if (empty($events)) {
ArrayHelper::multisort($events, 'name'); ArrayHelper::multisort($events, 'name');
?> ?>
<h2>Event Details</h2> <h2>Event Details</h2>
<?php foreach($events as $event): ?> <?php foreach ($events as $event): ?>
<div class="detailHeader h3" id="<?= $event->name.'-detail' ?>"> <div class="detailHeader h3" id="<?= $event->name.'-detail' ?>">
<?= $event->name ?> <?= $event->name ?>
<span class="detailHeaderTag small"> <span class="detailHeaderTag small">
......
...@@ -29,7 +29,7 @@ ArrayHelper::multisort($events, 'name'); ...@@ -29,7 +29,7 @@ ArrayHelper::multisort($events, 'name');
<tr> <tr>
<th>Event</th><th>Type</th><th>Description</th><th>Defined By</th> <th>Event</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr> </tr>
<?php foreach($events as $event): ?> <?php foreach ($events as $event): ?>
<tr<?= $event->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>"> <tr<?= $event->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $event->name ?>">
<td><?= $this->context->subjectLink($event) ?></td> <td><?= $this->context->subjectLink($event) ?></td>
<td><?= $this->context->typeLink($event->types) ?></td> <td><?= $this->context->typeLink($event->types) ?></td>
......
...@@ -18,7 +18,7 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -18,7 +18,7 @@ ArrayHelper::multisort($methods, 'name');
?> ?>
<h2>Method Details</h2> <h2>Method Details</h2>
<?php foreach($methods as $method): ?> <?php foreach ($methods as $method): ?>
<div class="detailHeader h3" id="<?= $method->name . '()-detail' ?>"> <div class="detailHeader h3" id="<?= $method->name . '()-detail' ?>">
<?= $method->name ?>() <?= $method->name ?>()
...@@ -36,7 +36,7 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -36,7 +36,7 @@ ArrayHelper::multisort($methods, 'name');
<div class="signature2"><?= $this->context->renderMethodSignature($method) ?></div> <div class="signature2"><?= $this->context->renderMethodSignature($method) ?></div>
</td></tr> </td></tr>
<?php if (!empty($method->params) || !empty($method->return) || !empty($method->exceptions)): ?> <?php if (!empty($method->params) || !empty($method->return) || !empty($method->exceptions)): ?>
<?php foreach($method->params as $param): ?> <?php foreach ($method->params as $param): ?>
<tr> <tr>
<td class="paramNameCol"><?= $param->name ?></td> <td class="paramNameCol"><?= $param->name ?></td>
<td class="paramTypeCol"><?= $this->context->typeLink($param->types) ?></td> <td class="paramTypeCol"><?= $this->context->typeLink($param->types) ?></td>
...@@ -50,7 +50,7 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -50,7 +50,7 @@ ArrayHelper::multisort($methods, 'name');
<td class="paramDescCol"><?= ApiMarkdown::process($method->return, $type); ?></td> <td class="paramDescCol"><?= ApiMarkdown::process($method->return, $type); ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php foreach($method->exceptions as $exception => $description): ?> <?php foreach ($method->exceptions as $exception => $description): ?>
<tr> <tr>
<td class="paramNameCol"><?= 'throws' ?></td> <td class="paramNameCol"><?= 'throws' ?></td>
<td class="paramTypeCol"><?= $this->context->typeLink($exception) ?></td> <td class="paramTypeCol"><?= $this->context->typeLink($exception) ?></td>
......
...@@ -33,7 +33,7 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou ...@@ -33,7 +33,7 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou
<?php <?php
$methods = $type->methods; $methods = $type->methods;
ArrayHelper::multisort($methods, 'name'); ArrayHelper::multisort($methods, 'name');
foreach($methods as $method): ?> foreach ($methods as $method): ?>
<?php if ($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected'): ?> <?php if ($protected && $method->visibility == 'protected' || !$protected && $method->visibility != 'protected'): ?>
<tr<?= $method->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $method->name ?>()"> <tr<?= $method->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $method->name ?>()">
<td><?= $this->context->subjectLink($method, $method->name.'()') ?></td> <td><?= $this->context->subjectLink($method, $method->name.'()') ?></td>
......
...@@ -18,7 +18,7 @@ ArrayHelper::multisort($properties, 'name'); ...@@ -18,7 +18,7 @@ ArrayHelper::multisort($properties, 'name');
?> ?>
<h2>Property Details</h2> <h2>Property Details</h2>
<?php foreach($properties as $property): ?> <?php foreach ($properties as $property): ?>
<div class="detailHeader h3" id="<?= $property->name.'-detail' ?>"> <div class="detailHeader h3" id="<?= $property->name.'-detail' ?>">
<?= $property->name ?> <?= $property->name ?>
......
...@@ -33,7 +33,7 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected && ...@@ -33,7 +33,7 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected &&
<?php <?php
$properties = $type->properties; $properties = $type->properties;
ArrayHelper::multisort($properties, 'name'); ArrayHelper::multisort($properties, 'name');
foreach($properties as $property): ?> foreach ($properties as $property): ?>
<?php if ($protected && $property->visibility == 'protected' || !$protected && $property->visibility != 'protected'): ?> <?php if ($protected && $property->visibility == 'protected' || !$protected && $property->visibility != 'protected'): ?>
<tr<?= $property->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>"> <tr<?= $property->definedBy != $type->name ? ' class="inherited"' : '' ?> id="<?= $property->name ?>">
<td><?= $this->context->subjectLink($property) ?></td> <td><?= $this->context->subjectLink($property) ?></td>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
$see = []; $see = [];
foreach($object->tags as $tag) { foreach ($object->tags as $tag) {
/** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */ /** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
if (get_class($tag) == 'phpDocumentor\Reflection\DocBlock\Tag\SeeTag') { if (get_class($tag) == 'phpDocumentor\Reflection\DocBlock\Tag\SeeTag') {
$ref = $tag->getReference(); $ref = $tag->getReference();
...@@ -24,7 +24,7 @@ if (empty($see)) { ...@@ -24,7 +24,7 @@ if (empty($see)) {
<div class="SeeAlso"> <div class="SeeAlso">
<h4>See Also</h4> <h4>See Also</h4>
<ul> <ul>
<?php foreach($see as $ref): ?> <?php foreach ($see as $ref): ?>
<li><?= \yii\apidoc\helpers\ApiMarkdown::process($ref, $object->definedBy, true) ?></li> <li><?= \yii\apidoc\helpers\ApiMarkdown::process($ref, $object->definedBy, true) ?></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
......
...@@ -22,7 +22,7 @@ use yii\apidoc\models\TraitDoc; ...@@ -22,7 +22,7 @@ use yii\apidoc\models\TraitDoc;
</tr> </tr>
<?php <?php
ksort($types); ksort($types);
foreach($types as $i=>$class): foreach ($types as $i=>$class):
?> ?>
<tr> <tr>
<td><?= $this->context->typeLink($class, $class->name) ?></td> <td><?= $this->context->typeLink($class, $class->name) ?></td>
......
...@@ -37,7 +37,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -37,7 +37,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
$controller->stdout("writing packages file..."); $controller->stdout("writing packages file...");
$packages = []; $packages = [];
$notNamespaced = []; $notNamespaced = [];
foreach(array_merge($context->classes, $context->interfaces, $context->traits) as $type) { foreach (array_merge($context->classes, $context->interfaces, $context->traits) as $type) {
/** @var TypeDoc $type */ /** @var TypeDoc $type */
if (empty($type->namespace)) { if (empty($type->namespace)) {
$notNamespaced[] = str_replace('\\', '-', $type->name); $notNamespaced[] = str_replace('\\', '-', $type->name);
...@@ -47,7 +47,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer ...@@ -47,7 +47,7 @@ class Renderer extends \yii\apidoc\templates\html\Renderer
} }
ksort($packages); ksort($packages);
$packages = array_merge(['Not namespaced' => $notNamespaced], $packages); $packages = array_merge(['Not namespaced' => $notNamespaced], $packages);
foreach($packages as $name => $classes) { foreach ($packages as $name => $classes) {
sort($packages[$name]); sort($packages[$name]);
} }
file_put_contents($dir . '/packages.txt', serialize($packages)); file_put_contents($dir . '/packages.txt', serialize($packages));
......
...@@ -22,7 +22,7 @@ use yii\apidoc\models\TraitDoc; ...@@ -22,7 +22,7 @@ use yii\apidoc\models\TraitDoc;
</tr> </tr>
<?php <?php
ksort($types); ksort($types);
foreach($types as $i=>$class): foreach ($types as $i=>$class):
?> ?>
<tr> <tr>
<td><?= $this->context->typeLink($class, $class->name) ?></td> <td><?= $this->context->typeLink($class, $class->name) ?></td>
......
...@@ -192,7 +192,7 @@ class Installer extends LibraryInstaller ...@@ -192,7 +192,7 @@ class Installer extends LibraryInstaller
if (!file_exists($yiiDir)) { if (!file_exists($yiiDir)) {
mkdir($yiiDir, 0777, true); mkdir($yiiDir, 0777, true);
} }
foreach(['Yii.php', 'BaseYii.php', 'classes.php'] as $file) { foreach (['Yii.php', 'BaseYii.php', 'classes.php'] as $file) {
file_put_contents($yiiDir . '/' . $file, <<<EOF file_put_contents($yiiDir . '/' . $file, <<<EOF
<?php <?php
/** /**
...@@ -213,7 +213,7 @@ EOF ...@@ -213,7 +213,7 @@ EOF
protected function removeBaseYiiFiles() protected function removeBaseYiiFiles()
{ {
$yiiDir = $this->vendorDir . '/yiisoft/yii2'; $yiiDir = $this->vendorDir . '/yiisoft/yii2';
foreach(['Yii.php', 'BaseYii.php', 'classes.php'] as $file) { foreach (['Yii.php', 'BaseYii.php', 'classes.php'] as $file) {
if (file_exists($yiiDir . '/' . $file)) { if (file_exists($yiiDir . '/' . $file)) {
unlink($yiiDir . '/' . $file); unlink($yiiDir . '/' . $file);
} }
......
...@@ -23,7 +23,7 @@ use yii\helpers\Html; ...@@ -23,7 +23,7 @@ use yii\helpers\Html;
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($values as $name => $value): ?> <?php foreach ($values as $name => $value): ?>
<tr> <tr>
<th style="width: 200px;"><?= Html::encode($name) ?></th> <th style="width: 200px;"><?= Html::encode($name) ?></th>
<td style="overflow:auto"><?= Html::encode($value) ?></td> <td style="overflow:auto"><?= Html::encode($value) ?></td>
......
...@@ -23,7 +23,7 @@ use yii\helpers\VarDumper; ...@@ -23,7 +23,7 @@ use yii\helpers\VarDumper;
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach($values as $name => $value): ?> <?php foreach ($values as $name => $value): ?>
<tr> <tr>
<th style="width: 200px;"><?= Html::encode($name) ?></th> <th style="width: 200px;"><?= Html::encode($name) ?></th>
<td><?= htmlspecialchars(VarDumper::dumpAsString($value), ENT_QUOTES|ENT_SUBSTITUTE, \Yii::$app->charset, true) ?></td> <td><?= htmlspecialchars(VarDumper::dumpAsString($value), ENT_QUOTES|ENT_SUBSTITUTE, \Yii::$app->charset, true) ?></td>
......
...@@ -156,7 +156,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -156,7 +156,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
} }
$models = $this->createModels($result['hits']['hits']); $models = $this->createModels($result['hits']['hits']);
if ($this->asArray && !$this->indexBy) { if ($this->asArray && !$this->indexBy) {
foreach($models as $key => $model) { foreach ($models as $key => $model) {
if ($pk === '_id') { if ($pk === '_id') {
$model['_source']['_id'] = $model['_id']; $model['_source']['_id'] = $model['_id'];
} }
...@@ -168,7 +168,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -168,7 +168,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
...@@ -226,7 +226,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -226,7 +226,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
/** @var ActiveRecord $modelClass */ /** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass; $modelClass = $this->modelClass;
$pk = $modelClass::primaryKey()[0]; $pk = $modelClass::primaryKey()[0];
foreach($models as $key => $model) { foreach ($models as $key => $model) {
if ($pk === '_id') { if ($pk === '_id') {
$model['_source']['_id'] = $model['_id']; $model['_source']['_id'] = $model['_id'];
} }
...@@ -238,7 +238,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -238,7 +238,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -122,7 +122,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -122,7 +122,7 @@ class ActiveRecord extends BaseActiveRecord
$command = static::getDb()->createCommand(); $command = static::getDb()->createCommand();
$result = $command->mget(static::index(), static::type(), $primaryKeys, $options); $result = $command->mget(static::index(), static::type(), $primaryKeys, $options);
$models = []; $models = [];
foreach($result['docs'] as $doc) { foreach ($result['docs'] as $doc) {
if ($doc['exists']) { if ($doc['exists']) {
$model = static::instantiate($doc); $model = static::instantiate($doc);
static::populateRecord($model, $doc); static::populateRecord($model, $doc);
...@@ -422,7 +422,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -422,7 +422,7 @@ class ActiveRecord extends BaseActiveRecord
return 0; return 0;
} }
$bulk = ''; $bulk = '';
foreach($primaryKeys as $pk) { foreach ($primaryKeys as $pk) {
$action = Json::encode([ $action = Json::encode([
"update" => [ "update" => [
"_id" => $pk, "_id" => $pk,
...@@ -441,7 +441,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -441,7 +441,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk); $response = static::getDb()->post($url, [], $bulk);
$n=0; $n=0;
$errors = []; $errors = [];
foreach($response['items'] as $item) { foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) { if (isset($item['update']['error'])) {
$errors[] = $item['update']; $errors[] = $item['update'];
} elseif ($item['update']['ok']) { } elseif ($item['update']['ok']) {
...@@ -480,7 +480,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -480,7 +480,7 @@ class ActiveRecord extends BaseActiveRecord
return 0; return 0;
} }
$bulk = ''; $bulk = '';
foreach($primaryKeys as $pk) { foreach ($primaryKeys as $pk) {
$action = Json::encode([ $action = Json::encode([
"update" => [ "update" => [
"_id" => $pk, "_id" => $pk,
...@@ -489,7 +489,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -489,7 +489,7 @@ class ActiveRecord extends BaseActiveRecord
], ],
]); ]);
$script = ''; $script = '';
foreach($counters as $counter => $value) { foreach ($counters as $counter => $value) {
$script .= "ctx._source.$counter += $counter;\n"; $script .= "ctx._source.$counter += $counter;\n";
} }
$data = Json::encode([ $data = Json::encode([
...@@ -504,7 +504,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -504,7 +504,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk); $response = static::getDb()->post($url, [], $bulk);
$n=0; $n=0;
$errors = []; $errors = [];
foreach($response['items'] as $item) { foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) { if (isset($item['update']['error'])) {
$errors[] = $item['update']; $errors[] = $item['update'];
} elseif ($item['update']['ok']) { } elseif ($item['update']['ok']) {
...@@ -543,7 +543,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -543,7 +543,7 @@ class ActiveRecord extends BaseActiveRecord
return 0; return 0;
} }
$bulk = ''; $bulk = '';
foreach($primaryKeys as $pk) { foreach ($primaryKeys as $pk) {
$bulk .= Json::encode([ $bulk .= Json::encode([
"delete" => [ "delete" => [
"_id" => $pk, "_id" => $pk,
...@@ -558,7 +558,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -558,7 +558,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk); $response = static::getDb()->post($url, [], $bulk);
$n=0; $n=0;
$errors = []; $errors = [];
foreach($response['items'] as $item) { foreach ($response['items'] as $item) {
if (isset($item['delete']['error'])) { if (isset($item['delete']['error'])) {
$errors[] = $item['delete']; $errors[] = $item['delete'];
} elseif ($item['delete']['found'] && $item['delete']['ok']) { } elseif ($item['delete']['found'] && $item['delete']['ok']) {
......
...@@ -63,7 +63,7 @@ class Connection extends Component ...@@ -63,7 +63,7 @@ class Connection extends Component
public function init() public function init()
{ {
foreach($this->nodes as $node) { foreach ($this->nodes as $node) {
if (!isset($node['http_address'])) { if (!isset($node['http_address'])) {
throw new InvalidConfigException('Elasticsearch node needs at least a http_address configured.'); throw new InvalidConfigException('Elasticsearch node needs at least a http_address configured.');
} }
...@@ -245,7 +245,7 @@ class Connection extends Component ...@@ -245,7 +245,7 @@ class Connection extends Component
return mb_strlen($data, '8bit'); return mb_strlen($data, '8bit');
}, },
CURLOPT_HEADERFUNCTION => function($curl, $data) use (&$headers) { 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) { if (($pos = strpos($row, ':')) !== false) {
$headers[strtolower(substr($row, 0, $pos))] = trim(substr($row, $pos + 1)); $headers[strtolower(substr($row, 0, $pos))] = trim(substr($row, $pos + 1));
} }
......
...@@ -177,7 +177,7 @@ class QueryBuilder extends \yii\base\Object ...@@ -177,7 +177,7 @@ class QueryBuilder extends \yii\base\Object
private function buildHashCondition($condition) private function buildHashCondition($condition)
{ {
$parts = []; $parts = [];
foreach($condition as $attribute => $value) { foreach ($condition as $attribute => $value) {
if ($attribute == '_id') { if ($attribute == '_id') {
if ($value == null) { // there is no null pk if ($value == null) { // there is no null pk
$parts[] = ['script' => ['script' => '0==1']]; $parts[] = ['script' => ['script' => '0==1']];
......
...@@ -18,7 +18,7 @@ namespace <?= $generator->ns ?>; ...@@ -18,7 +18,7 @@ namespace <?= $generator->ns ?>;
class <?= $generator->getControllerClass() ?> extends <?= '\\' . trim($generator->baseClass, '\\') . "\n" ?> class <?= $generator->getControllerClass() ?> extends <?= '\\' . trim($generator->baseClass, '\\') . "\n" ?>
{ {
<?php foreach($generator->getActionIDs() as $action): ?> <?php foreach ($generator->getActionIDs() as $action): ?>
public function action<?= Inflector::id2camel($action) ?>() public function action<?= Inflector::id2camel($action) ?>()
{ {
return $this->render('<?= $action ?>'); return $this->render('<?= $action ?>');
......
...@@ -111,7 +111,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -111,7 +111,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -56,7 +56,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -56,7 +56,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -87,7 +87,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -87,7 +87,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
// TODO add support for orderBy // TODO add support for orderBy
$data = $this->executeScript($db, 'All'); $data = $this->executeScript($db, 'All');
$rows = []; $rows = [];
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$row = []; $row = [];
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
...@@ -101,7 +101,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -101,7 +101,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
...@@ -336,7 +336,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -336,7 +336,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
if (count($this->where) == 1) { if (count($this->where) == 1) {
$pks = (array) reset($this->where); $pks = (array) reset($this->where);
} else { } else {
foreach($this->where as $values) { foreach ($this->where as $values) {
if (is_array($values)) { if (is_array($values)) {
// TODO support composite IN for composite PK // TODO support composite IN for composite PK
throw new NotSupportedException('Find by composite PK is not supported by redis ActiveRecord.'); throw new NotSupportedException('Find by composite PK is not supported by redis ActiveRecord.');
...@@ -357,7 +357,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -357,7 +357,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
} }
$i = 0; $i = 0;
$data = []; $data = [];
foreach($pks as $pk) { foreach ($pks as $pk) {
if (++$i > $start && ($limit === null || $i <= $start + $limit)) { if (++$i > $start && ($limit === null || $i <= $start + $limit)) {
$key = $modelClass::keyPrefix() . ':a:' . $modelClass::buildKey($pk); $key = $modelClass::keyPrefix() . ':a:' . $modelClass::buildKey($pk);
$result = $db->executeCommand('HGETALL', [$key]); $result = $db->executeCommand('HGETALL', [$key]);
...@@ -380,7 +380,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -380,7 +380,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return count($data); return count($data);
case 'Column': case 'Column':
$column = []; $column = [];
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$row = []; $row = [];
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
...@@ -391,7 +391,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -391,7 +391,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $column; return $column;
case 'Sum': case 'Sum':
$sum = 0; $sum = 0;
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
if ($dataRow[$i++] == $columnName) { if ($dataRow[$i++] == $columnName) {
...@@ -404,7 +404,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -404,7 +404,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
case 'Average': case 'Average':
$sum = 0; $sum = 0;
$count = 0; $count = 0;
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$count++; $count++;
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
...@@ -417,7 +417,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -417,7 +417,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $sum / $count; return $sum / $count;
case 'Min': case 'Min':
$min = null; $min = null;
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
if ($dataRow[$i++] == $columnName && ($min == null || $dataRow[$i] < $min)) { if ($dataRow[$i++] == $columnName && ($min == null || $dataRow[$i] < $min)) {
...@@ -429,7 +429,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface ...@@ -429,7 +429,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $min; return $min;
case 'Max': case 'Max':
$max = null; $max = null;
foreach($data as $dataRow) { foreach ($data as $dataRow) {
$c = count($dataRow); $c = count($dataRow);
for($i = 0; $i < $c; ) { for($i = 0; $i < $c; ) {
if ($dataRow[$i++] == $columnName && ($max == null || $dataRow[$i] > $max)) { if ($dataRow[$i++] == $columnName && ($max == null || $dataRow[$i] > $max)) {
......
...@@ -139,7 +139,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -139,7 +139,7 @@ class ActiveRecord extends BaseActiveRecord
$key = static::keyPrefix() . ':a:' . static::buildKey($pk); $key = static::keyPrefix() . ':a:' . static::buildKey($pk);
// save attributes // save attributes
$args = [$key]; $args = [$key];
foreach($values as $attribute => $value) { foreach ($values as $attribute => $value) {
$args[] = $attribute; $args[] = $attribute;
$args[] = $value; $args[] = $value;
} }
...@@ -172,13 +172,13 @@ class ActiveRecord extends BaseActiveRecord ...@@ -172,13 +172,13 @@ class ActiveRecord extends BaseActiveRecord
} }
$db = static::getDb(); $db = static::getDb();
$n=0; $n=0;
foreach(static::fetchPks($condition) as $pk) { foreach (static::fetchPks($condition) as $pk) {
$newPk = $pk; $newPk = $pk;
$pk = static::buildKey($pk); $pk = static::buildKey($pk);
$key = static::keyPrefix() . ':a:' . $pk; $key = static::keyPrefix() . ':a:' . $pk;
// save attributes // save attributes
$args = [$key]; $args = [$key];
foreach($attributes as $attribute => $value) { foreach ($attributes as $attribute => $value) {
if (isset($newPk[$attribute])) { if (isset($newPk[$attribute])) {
$newPk[$attribute] = $value; $newPk[$attribute] = $value;
} }
...@@ -224,9 +224,9 @@ class ActiveRecord extends BaseActiveRecord ...@@ -224,9 +224,9 @@ class ActiveRecord extends BaseActiveRecord
} }
$db = static::getDb(); $db = static::getDb();
$n=0; $n=0;
foreach(static::fetchPks($condition) as $pk) { foreach (static::fetchPks($condition) as $pk) {
$key = static::keyPrefix() . ':a:' . static::buildKey($pk); $key = static::keyPrefix() . ':a:' . static::buildKey($pk);
foreach($counters as $attribute => $value) { foreach ($counters as $attribute => $value) {
$db->executeCommand('HINCRBY', [$key, $attribute, $value]); $db->executeCommand('HINCRBY', [$key, $attribute, $value]);
} }
$n++; $n++;
...@@ -254,7 +254,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -254,7 +254,7 @@ class ActiveRecord extends BaseActiveRecord
$attributeKeys = []; $attributeKeys = [];
$pks = static::fetchPks($condition); $pks = static::fetchPks($condition);
$db->executeCommand('MULTI'); $db->executeCommand('MULTI');
foreach($pks as $pk) { foreach ($pks as $pk) {
$pk = static::buildKey($pk); $pk = static::buildKey($pk);
$db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]); $db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]);
$attributeKeys[] = static::keyPrefix() . ':a:' . $pk; $attributeKeys[] = static::keyPrefix() . ':a:' . $pk;
...@@ -276,9 +276,9 @@ class ActiveRecord extends BaseActiveRecord ...@@ -276,9 +276,9 @@ class ActiveRecord extends BaseActiveRecord
$primaryKey = static::primaryKey(); $primaryKey = static::primaryKey();
$pks = []; $pks = [];
foreach($records as $record) { foreach ($records as $record) {
$pk = []; $pk = [];
foreach($primaryKey as $key) { foreach ($primaryKey as $key) {
$pk[$key] = $record[$key]; $pk[$key] = $record[$key];
} }
$pks[] = $pk; $pks[] = $pk;
...@@ -304,7 +304,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -304,7 +304,7 @@ class ActiveRecord extends BaseActiveRecord
} }
ksort($key); // ensure order is always the same ksort($key); // ensure order is always the same
$isNumeric = true; $isNumeric = true;
foreach($key as $value) { foreach ($key as $value) {
if (!is_numeric($value)) { if (!is_numeric($value)) {
$isNumeric = false; $isNumeric = false;
} }
......
...@@ -145,7 +145,7 @@ class Cache extends \yii\caching\Cache ...@@ -145,7 +145,7 @@ class Cache extends \yii\caching\Cache
protected function setValues($data, $expire) protected function setValues($data, $expire)
{ {
$args = []; $args = [];
foreach($data as $key => $value) { foreach ($data as $key => $value) {
$args[] = $key; $args[] = $key;
$args[] = $value; $args[] = $value;
} }
...@@ -164,7 +164,7 @@ class Cache extends \yii\caching\Cache ...@@ -164,7 +164,7 @@ class Cache extends \yii\caching\Cache
} }
$result = $this->redis->executeCommand('EXEC'); $result = $this->redis->executeCommand('EXEC');
array_shift($result); array_shift($result);
foreach($result as $i => $r) { foreach ($result as $i => $r) {
if ($r != 1) { if ($r != 1) {
$failedKeys[] = $index[$i]; $failedKeys[] = $index[$i];
} }
......
...@@ -351,7 +351,7 @@ class Connection extends Component ...@@ -351,7 +351,7 @@ class Connection extends Component
array_unshift($params, $name); array_unshift($params, $name);
$command = '*' . count($params) . "\r\n"; $command = '*' . count($params) . "\r\n";
foreach($params as $arg) { foreach ($params as $arg) {
$command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n"; $command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
} }
......
...@@ -155,7 +155,7 @@ class LuaScriptBuilder extends \yii\base\Object ...@@ -155,7 +155,7 @@ class LuaScriptBuilder extends \yii\base\Object
$modelClass = $query->modelClass; $modelClass = $query->modelClass;
$key = $this->quoteValue($modelClass::keyPrefix()); $key = $this->quoteValue($modelClass::keyPrefix());
$loadColumnValues = ''; $loadColumnValues = '';
foreach($columns as $column => $alias) { foreach ($columns as $column => $alias) {
$loadColumnValues .= "local $alias=redis.call('HGET',$key .. ':a:' .. pk, '$column')\n"; $loadColumnValues .= "local $alias=redis.call('HGET',$key .. ':a:' .. pk, '$column')\n";
} }
......
...@@ -135,7 +135,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -135,7 +135,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
} }
$models = $this->fillUpSnippets($models); $models = $this->fillUpSnippets($models);
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -319,7 +319,7 @@ class MessageController extends Controller ...@@ -319,7 +319,7 @@ class MessageController extends Controller
} }
if ($format === 'po') { if ($format === 'po') {
$output = ''; $output = '';
foreach ($merged as $k => $v){ foreach ($merged as $k => $v) {
$k = preg_replace('/(\")|(\\\")/', "\\\"", $k); $k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$v = preg_replace('/(\")|(\\\")/', "\\\"", $v); $v = preg_replace('/(\")|(\\\")/', "\\\"", $v);
if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') { if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') {
...@@ -338,7 +338,7 @@ class MessageController extends Controller ...@@ -338,7 +338,7 @@ class MessageController extends Controller
if ($format === 'po') { if ($format === 'po') {
$merged = ''; $merged = '';
sort($messages); sort($messages);
foreach($messages as $message) { foreach ($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message); $message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n"; $merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n"; $merged .= "msgstr \"\"\n";
......
...@@ -120,7 +120,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface ...@@ -120,7 +120,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models); $this->findWith($this->with, $models);
} }
if (!$this->asArray) { if (!$this->asArray) {
foreach($models as $model) { foreach ($models as $model) {
$model->afterFind(); $model->afterFind();
} }
} }
......
...@@ -280,14 +280,14 @@ class BaseFileHelper ...@@ -280,14 +280,14 @@ class BaseFileHelper
$options['basePath'] = realpath($dir); $options['basePath'] = realpath($dir);
// this should also be done only once // this should also be done only once
if (isset($options['except'])) { if (isset($options['except'])) {
foreach($options['except'] as $key=>$value) { foreach ($options['except'] as $key => $value) {
if (is_string($value)) { if (is_string($value)) {
$options['except'][$key] = static::parseExcludePattern($value); $options['except'][$key] = static::parseExcludePattern($value);
} }
} }
} }
if (isset($options['only'])) { if (isset($options['only'])) {
foreach($options['only'] as $key=>$value) { foreach ($options['only'] as $key => $value) {
if (is_string($value)) { if (is_string($value)) {
$options['only'][$key] = static::parseExcludePattern($value); $options['only'][$key] = static::parseExcludePattern($value);
} }
...@@ -472,7 +472,7 @@ class BaseFileHelper ...@@ -472,7 +472,7 @@ class BaseFileHelper
*/ */
private static function lastExcludeMatchingFromList($basePath, $path, $excludes) private static function lastExcludeMatchingFromList($basePath, $path, $excludes)
{ {
foreach(array_reverse($excludes) as $exclude) { foreach (array_reverse($excludes) as $exclude) {
if (is_string($exclude)) { if (is_string($exclude)) {
$exclude = self::parseExcludePattern($exclude); $exclude = self::parseExcludePattern($exclude);
} }
......
...@@ -126,7 +126,7 @@ class I18N extends Component ...@@ -126,7 +126,7 @@ class I18N extends Component
} }
$p = []; $p = [];
foreach($params as $name => $value) { foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value; $p['{' . $name . '}'] = $value;
} }
return strtr($message, $p); return strtr($message, $p);
......
...@@ -143,7 +143,7 @@ class MessageFormatter extends Component ...@@ -143,7 +143,7 @@ class MessageFormatter extends Component
return false; return false;
} }
$map = []; $map = [];
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (is_array($token)) { if (is_array($token)) {
$param = trim($token[0]); $param = trim($token[0]);
if (!isset($map[$param])) { if (!isset($map[$param])) {
...@@ -169,7 +169,7 @@ class MessageFormatter extends Component ...@@ -169,7 +169,7 @@ class MessageFormatter extends Component
return false; return false;
} else { } else {
$values = []; $values = [];
foreach($result as $key => $value) { foreach ($result as $key => $value) {
$values[$map[$key]] = $value; $values[$map[$key]] = $value;
} }
return $values; return $values;
...@@ -190,7 +190,7 @@ class MessageFormatter extends Component ...@@ -190,7 +190,7 @@ class MessageFormatter extends Component
if (($tokens = self::tokenizePattern($pattern)) === false) { if (($tokens = self::tokenizePattern($pattern)) === false) {
return false; return false;
} }
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (!is_array($token)) { if (!is_array($token)) {
continue; continue;
} }
...@@ -244,7 +244,7 @@ class MessageFormatter extends Component ...@@ -244,7 +244,7 @@ class MessageFormatter extends Component
$this->_errorMessage = "Message pattern is invalid."; $this->_errorMessage = "Message pattern is invalid.";
return false; return false;
} }
foreach($tokens as $i => $token) { foreach ($tokens as $i => $token) {
if (is_array($token)) { if (is_array($token)) {
if (($tokens[$i] = $this->parseToken($token, $args, $locale)) === false) { if (($tokens[$i] = $this->parseToken($token, $args, $locale)) === false) {
$this->_errorCode = -1; $this->_errorCode = -1;
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<table class="table table-bordered"> <table class="table table-bordered">
<tr><th>Name</th><th>Result</th><th>Required By</th><th>Memo</th></tr> <tr><th>Name</th><th>Result</th><th>Required By</th><th>Memo</th></tr>
<?php foreach($requirements as $requirement): ?> <?php foreach ($requirements as $requirement): ?>
<tr class="<?php echo $requirement['condition'] ? 'success' : ($requirement['mandatory'] ? 'error' : 'warning') ?>"> <tr class="<?php echo $requirement['condition'] ? 'success' : ($requirement['mandatory'] ? 'error' : 'warning') ?>">
<td> <td>
<?php echo $requirement['name'] ?> <?php echo $requirement['name'] ?>
......
...@@ -82,7 +82,7 @@ class AssetConverter extends Component implements AssetConverterInterface ...@@ -82,7 +82,7 @@ class AssetConverter extends Component implements AssetConverterInterface
$proc = proc_open($command, $descriptor, $pipes, $basePath); $proc = proc_open($command, $descriptor, $pipes, $basePath);
$stdout = stream_get_contents($pipes[1]); $stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]); $stderr = stream_get_contents($pipes[2]);
foreach($pipes as $pipe) { foreach ($pipes as $pipe) {
fclose($pipe); fclose($pipe);
} }
$status = proc_close($proc); $status = proc_close($proc);
......
...@@ -128,7 +128,7 @@ class LinkPager extends Widget ...@@ -128,7 +128,7 @@ class LinkPager extends Widget
protected function registerLinkTags() protected function registerLinkTags()
{ {
$view = $this->getView(); $view = $this->getView();
foreach($this->pagination->getLinks() as $rel => $href) { foreach ($this->pagination->getLinks() as $rel => $href) {
$view->registerLinkTag(['rel' => $rel, 'href' => $href], $rel); $view->registerLinkTag(['rel' => $rel, 'href' => $href], $rel);
} }
} }
......
...@@ -25,7 +25,7 @@ class SchemaTest extends SphinxTestCase ...@@ -25,7 +25,7 @@ class SchemaTest extends SphinxTestCase
$indexes = $schema->getIndexSchemas(); $indexes = $schema->getIndexSchemas();
$this->assertEquals(count($schema->getIndexNames()), count($indexes)); $this->assertEquals(count($schema->getIndexNames()), count($indexes));
foreach($indexes as $index) { foreach ($indexes as $index) {
$this->assertInstanceOf('yii\sphinx\IndexSchema', $index); $this->assertInstanceOf('yii\sphinx\IndexSchema', $index);
} }
} }
...@@ -62,7 +62,7 @@ class SchemaTest extends SphinxTestCase ...@@ -62,7 +62,7 @@ class SchemaTest extends SphinxTestCase
$schema = $this->getConnection()->schema; $schema = $this->getConnection()->schema;
foreach($values as $value) { foreach ($values as $value) {
$this->assertEquals($value[1], $schema->getPdoType($value[0])); $this->assertEquals($value[1], $schema->getPdoType($value[0]));
} }
fclose($fp); fclose($fp);
......
...@@ -32,7 +32,7 @@ class SchemaTest extends DatabaseTestCase ...@@ -32,7 +32,7 @@ class SchemaTest extends DatabaseTestCase
$tables = $schema->getTableSchemas(); $tables = $schema->getTableSchemas();
$this->assertEquals(count($schema->getTableNames()), count($tables)); $this->assertEquals(count($schema->getTableNames()), count($tables));
foreach($tables as $table) { foreach ($tables as $table) {
$this->assertInstanceOf('yii\db\TableSchema', $table); $this->assertInstanceOf('yii\db\TableSchema', $table);
} }
} }
...@@ -85,7 +85,7 @@ class SchemaTest extends DatabaseTestCase ...@@ -85,7 +85,7 @@ class SchemaTest extends DatabaseTestCase
/** @var Schema $schema */ /** @var Schema $schema */
$schema = $this->getConnection()->schema; $schema = $this->getConnection()->schema;
foreach($values as $value) { foreach ($values as $value) {
$this->assertEquals($value[1], $schema->getPdoType($value[0])); $this->assertEquals($value[1], $schema->getPdoType($value[0]));
} }
fclose($fp); fclose($fp);
......
...@@ -28,7 +28,7 @@ class CubridSchemaTest extends SchemaTest ...@@ -28,7 +28,7 @@ class CubridSchemaTest extends SchemaTest
/** @var Schema $schema */ /** @var Schema $schema */
$schema = $this->getConnection()->schema; $schema = $this->getConnection()->schema;
foreach($values as $value) { foreach ($values as $value) {
$this->assertEquals($value[1], $schema->getPdoType($value[0])); $this->assertEquals($value[1], $schema->getPdoType($value[0]));
} }
fclose($fp); fclose($fp);
......
...@@ -260,8 +260,8 @@ class FileHelperTest extends TestCase ...@@ -260,8 +260,8 @@ class FileHelperTest extends TestCase
$tree = $files; $tree = $files;
$root = $files; $root = $files;
$flat = []; $flat = [];
foreach($dirs as $dir) { foreach ($dirs as $dir) {
foreach($files as $fileName=>$contents) { foreach ($files as $fileName => $contents) {
$flat[] = rtrim($basePath.$dir,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileName; $flat[] = rtrim($basePath.$dir,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileName;
} }
if ($dir === '') continue; if ($dir === '') continue;
......
...@@ -66,7 +66,7 @@ class TargetTest extends TestCase ...@@ -66,7 +66,7 @@ class TargetTest extends TestCase
$this->assertEquals(count($expected), count(static::$messages)); $this->assertEquals(count($expected), count(static::$messages));
$i = 0; $i = 0;
foreach($expected as $e) { foreach ($expected as $e) {
$this->assertEquals('test' . $e, static::$messages[$i++][0]); $this->assertEquals('test' . $e, static::$messages[$i++][0]);
} }
} }
......
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