Commit a8ef7bab by Carsten Brandt

Merge branch 'code-style'

* code-style: fix php5.4 array syntax many phpcs fixes fix phpDoc LuaScriptBuilder build @throws returned back formatting language files code style. WHILE code style. FOR code style. FOREACH code style. operator IF @param, @var, @property and @return must declare types as boolean, integer, string, array or null short echo tags short array syntax
parents fe48ae0d 1b7e1cd0
...@@ -141,7 +141,7 @@ class User extends ActiveRecord implements IdentityInterface ...@@ -141,7 +141,7 @@ class User extends ActiveRecord implements IdentityInterface
* Validates password * Validates password
* *
* @param string $password password to validate * @param string $password password to validate
* @return bool if password provided is valid for current user * @return boolean if password provided is valid for current user
*/ */
public function validatePassword($password) public function validatePassword($password)
{ {
......
...@@ -92,7 +92,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface ...@@ -92,7 +92,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
* Validates password * Validates password
* *
* @param string $password password to validate * @param string $password password to validate
* @return bool if password provided is valid for current user * @return boolean if password provided is valid for current user
*/ */
public function validatePassword($password) public function validatePassword($password)
{ {
......
...@@ -24,7 +24,7 @@ class PhpDocController extends Controller ...@@ -24,7 +24,7 @@ class PhpDocController extends Controller
public $defaultAction = 'property'; public $defaultAction = 'property';
/** /**
* @var bool whether to update class docs directly. Setting this to false will just output docs * @var boolean whether to update class docs directly. Setting this to false will just output docs
* for copy and paste. * for copy and paste.
*/ */
public $updateFiles = true; public $updateFiles = true;
...@@ -314,7 +314,7 @@ class PhpDocController extends Controller ...@@ -314,7 +314,7 @@ class PhpDocController extends Controller
// check if parent class has setter defined // check if parent class has setter defined
$c = $className; $c = $className;
$parentSetter = false; $parentSetter = false;
while($parent = get_parent_class($c)) { while ($parent = get_parent_class($c)) {
if (method_exists($parent, 'set' . ucfirst($propName))) { if (method_exists($parent, 'set' . ucfirst($propName))) {
$parentSetter = true; $parentSetter = true;
break; break;
...@@ -329,7 +329,7 @@ class PhpDocController extends Controller ...@@ -329,7 +329,7 @@ class PhpDocController extends Controller
// check if parent class has getter defined // check if parent class has getter defined
$c = $className; $c = $className;
$parentGetter = false; $parentGetter = false;
while($parent = get_parent_class($c)) { while ($parent = get_parent_class($c)) {
if (method_exists($parent, 'set' . ucfirst($propName))) { if (method_exists($parent, 'set' . ucfirst($propName))) {
$parentGetter = true; $parentGetter = true;
break; break;
......
...@@ -120,7 +120,7 @@ needs to be divisible by 10. In the rules you would define: `['attributeName', ' ...@@ -120,7 +120,7 @@ needs to be divisible by 10. In the rules you would define: `['attributeName', '
Then, your own method could look like this: Then, your own method could look like this:
```php ```php
public function myValidationMethod($attribute) { public function myValidationMethod($attribute) {
if(($this->$attribute % 10) != 0) { if (($this->$attribute % 10) != 0) {
$this->addError($attribute, 'cannot divide value by 10'); $this->addError($attribute, 'cannot divide value by 10');
} }
} }
......
...@@ -252,7 +252,7 @@ if ($event === null) { ...@@ -252,7 +252,7 @@ if ($event === null) {
} }
// the following is NOT allowed: // the following is NOT allowed:
if(!$model && null === $event) if (!$model && null === $event)
throw new Exception('test'); throw new Exception('test');
``` ```
......
...@@ -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;
......
...@@ -70,7 +70,7 @@ class ApiMarkdown extends GithubMarkdown ...@@ -70,7 +70,7 @@ class ApiMarkdown extends GithubMarkdown
if (!empty($language)) { if (!empty($language)) {
$block['language'] = $language; $block['language'] = $language;
} }
for($i = $current + 1, $count = count($lines); $i < $count; $i++) { for ($i = $current + 1, $count = count($lines); $i < $count; $i++) {
if (rtrim($line = $lines[$i]) !== $fence) { if (rtrim($line = $lines[$i]) !== $fence) {
$block['content'][] = $line; $block['content'][] = $line;
} else { } else {
...@@ -224,7 +224,7 @@ class ApiMarkdown extends GithubMarkdown ...@@ -224,7 +224,7 @@ class ApiMarkdown extends GithubMarkdown
* *
* @param string $content * @param string $content
* @param TypeDoc $context * @param TypeDoc $context
* @param bool $paragraph * @param boolean $paragraph
* @return string * @return string
*/ */
public static function process($content, $context = null, $paragraph = false) public static function process($content, $context = null, $paragraph = false)
......
...@@ -38,4 +38,4 @@ class PrettyPrinter extends \phpDocumentor\Reflection\PrettyPrinter ...@@ -38,4 +38,4 @@ class PrettyPrinter extends \phpDocumentor\Reflection\PrettyPrinter
$printer = new static(); $printer = new static();
return $printer->prettyPrintExpr($value); return $printer->prettyPrintExpr($value);
} }
} }
\ No newline at end of file
...@@ -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);
...@@ -112,4 +112,4 @@ class ClassDoc extends TypeDoc ...@@ -112,4 +112,4 @@ class ClassDoc extends TypeDoc
} }
} }
} }
} }
\ No newline at end of file
...@@ -33,4 +33,4 @@ class ConstDoc extends BaseDoc ...@@ -33,4 +33,4 @@ class ConstDoc extends BaseDoc
$this->value = $reflector->getValue(); $this->value = $reflector->getValue();
} }
} }
\ No newline at end of file
...@@ -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,15 +110,15 @@ class Context extends Component ...@@ -110,15 +110,15 @@ class Context extends Component
} }
} }
// inherit docs // inherit docs
foreach($this->classes as $class) { foreach ($this->classes as $class) {
$this->inheritDocs($class); $this->inheritDocs($class);
} }
// 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);
} }
...@@ -131,7 +131,7 @@ class Context extends Component ...@@ -131,7 +131,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));
...@@ -145,7 +145,7 @@ class Context extends Component ...@@ -145,7 +145,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);
...@@ -203,7 +203,7 @@ class Context extends Component ...@@ -203,7 +203,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;
} }
...@@ -275,7 +275,7 @@ class Context extends Component ...@@ -275,7 +275,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;
} }
...@@ -289,7 +289,7 @@ class Context extends Component ...@@ -289,7 +289,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;
} }
...@@ -309,7 +309,7 @@ class Context extends Component ...@@ -309,7 +309,7 @@ class Context extends Component
if ($classA->name == $classB) { if ($classA->name == $classB) {
return true; return true;
} }
while($classA->parentClass !== null && isset($this->classes[$classA->parentClass])) { while ($classA->parentClass !== null && isset($this->classes[$classA->parentClass])) {
$classA = $this->classes[$classA->parentClass]; $classA = $this->classes[$classA->parentClass];
if ($classA->name == $classB) { if ($classA->name == $classB) {
return true; return true;
...@@ -317,4 +317,4 @@ class Context extends Component ...@@ -317,4 +317,4 @@ class Context extends Component
} }
return false; return false;
} }
} }
\ No newline at end of file
...@@ -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();
...@@ -49,4 +49,4 @@ class EventDoc extends ConstDoc ...@@ -49,4 +49,4 @@ class EventDoc extends ConstDoc
} }
} }
} }
} }
\ No newline at end of file
...@@ -45,17 +45,17 @@ class FunctionDoc extends BaseDoc ...@@ -45,17 +45,17 @@ 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]);
} elseif ($tag instanceof PropertyTag) { } elseif ($tag instanceof PropertyTag) {
// ignore property tag // ignore property tag
} elseif ($tag instanceof ParamTag) { } elseif ($tag instanceof ParamTag) {
$paramName = $tag->getVariableName(); $paramName = $tag->getVariableName();
if (!isset($this->params[$paramName]) && $context !== null) { if (!isset($this->params[$paramName]) && $context !== null) {
......
...@@ -33,15 +33,15 @@ class InterfaceDoc extends TypeDoc ...@@ -33,15 +33,15 @@ 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;
} }
// interface can not have properties // interface can not have properties
$this->properties = null; $this->properties = null;
} }
} }
\ No newline at end of file
...@@ -53,4 +53,4 @@ class ParamDoc extends Object ...@@ -53,4 +53,4 @@ class ParamDoc extends Object
} }
$this->isPassedByReference = $reflector->isByRef(); $this->isPassedByReference = $reflector->isByRef();
} }
} }
\ No newline at end of file
...@@ -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();
...@@ -83,4 +83,4 @@ class PropertyDoc extends BaseDoc ...@@ -83,4 +83,4 @@ class PropertyDoc extends BaseDoc
]; ];
} }
} }
} }
\ No newline at end of file
...@@ -34,8 +34,8 @@ class TraitDoc extends TypeDoc ...@@ -34,8 +34,8 @@ class TraitDoc extends TypeDoc
return; return;
} }
foreach($reflector->getTraits() as $trait) { foreach ($reflector->getTraits() as $trait) {
$this->traits[] = ltrim($trait, '\\'); $this->traits[] = ltrim($trait, '\\');
} }
} }
} }
\ No newline at end of file
...@@ -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;
...@@ -190,4 +190,4 @@ class TypeDoc extends BaseDoc ...@@ -190,4 +190,4 @@ class TypeDoc extends BaseDoc
} }
} }
} }
} }
\ No newline at end of file
...@@ -153,7 +153,7 @@ class SideNavWidget extends \yii\bootstrap\Widget ...@@ -153,7 +153,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;
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\apidoc\templates\bootstrap\assets; namespace yii\apidoc\templates\bootstrap\assets;
use yii\web\View; use yii\web\View;
/** /**
......
...@@ -20,7 +20,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> ...@@ -20,7 +20,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
$types = $renderer->getNavTypes(isset($type) ? $type : null, $types); $types = $renderer->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';
......
...@@ -19,7 +19,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?> ...@@ -19,7 +19,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
'url' => $this->context->generateGuideUrl('index.md'), 'url' => $this->context->generateGuideUrl('index.md'),
'active' => isset($currentFile) && (basename($currentFile) == 'index.md'), 'active' => isset($currentFile) && (basename($currentFile) == 'index.md'),
]; ];
foreach($headlines as $file => $headline) { foreach ($headlines as $file => $headline) {
$nav[] = [ $nav[] = [
'label' => $headline, 'label' => $headline,
'url' => $this->context->generateGuideUrl($file), 'url' => $this->context->generateGuideUrl($file),
......
...@@ -54,7 +54,7 @@ $this->beginPage(); ...@@ -54,7 +54,7 @@ $this->beginPage();
if (!empty($this->context->extensions)) if (!empty($this->context->extensions))
{ {
$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",
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc; use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
/** /**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types * @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this * @var yii\web\View $this
...@@ -29,7 +30,7 @@ if (isset($readme)) { ...@@ -29,7 +30,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><?= $renderer->createTypeLink($class, $class, $class->name) ?></td> <td><?= $renderer->createTypeLink($class, $class, $class->name) ?></td>
......
...@@ -32,7 +32,7 @@ ArrayHelper::multisort($constants, 'name'); ...@@ -32,7 +32,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,12 +16,12 @@ if (empty($events)) { ...@@ -16,12 +16,12 @@ 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">
event event
<?php if(!empty($event->since)): ?> <?php if (!empty($event->since)): ?>
(available since version <?= $event->since ?>) (available since version <?= $event->since ?>)
<?php endif; ?> <?php endif; ?>
</span> </span>
......
...@@ -32,13 +32,13 @@ ArrayHelper::multisort($events, 'name'); ...@@ -32,13 +32,13 @@ 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><?= $renderer->createSubjectLink($event) ?></td> <td><?= $renderer->createSubjectLink($event) ?></td>
<td><?= $renderer->createTypeLink($event->types) ?></td> <td><?= $renderer->createTypeLink($event->types) ?></td>
<td> <td>
<?= ApiMarkdown::process($event->shortDescription, $event->definedBy, true) ?> <?= ApiMarkdown::process($event->shortDescription, $event->definedBy, true) ?>
<?php if(!empty($event->since)): ?> <?php if (!empty($event->since)): ?>
(available since version <?= $event->since ?>) (available since version <?= $event->since ?>)
<?php endif; ?> <?php endif; ?>
</td> </td>
......
...@@ -21,7 +21,7 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -21,7 +21,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 ?>()
...@@ -29,7 +29,7 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -29,7 +29,7 @@ ArrayHelper::multisort($methods, 'name');
<?= $method->visibility ?> <?= $method->visibility ?>
method method
<?php if (!empty($method->since)): ?> <?php if (!empty($method->since)): ?>
(available since version <?php echo $method->since; ?>) (available since version <?= $method->since ?>)
<?php endif; ?> <?php endif; ?>
</span> </span>
</div> </div>
...@@ -38,22 +38,22 @@ ArrayHelper::multisort($methods, 'name'); ...@@ -38,22 +38,22 @@ ArrayHelper::multisort($methods, 'name');
<tr><td colspan="3"> <tr><td colspan="3">
<div class="signature2"><?= $renderer->renderMethodSignature($method) ?></div> <div class="signature2"><?= $renderer->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"><?= $renderer->createTypeLink($param->types) ?></td> <td class="paramTypeCol"><?= $renderer->createTypeLink($param->types) ?></td>
<td class="paramDescCol"><?= ApiMarkdown::process($param->description, $type) ?></td> <td class="paramDescCol"><?= ApiMarkdown::process($param->description, $type) ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php if(!empty($method->return)): ?> <?php if (!empty($method->return)): ?>
<tr> <tr>
<td class="paramNameCol"><?= 'return'; ?></td> <td class="paramNameCol"><?= 'return'; ?></td>
<td class="paramTypeCol"><?= $renderer->createTypeLink($method->returnTypes); ?></td> <td class="paramTypeCol"><?= $renderer->createTypeLink($method->returnTypes); ?></td>
<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"><?= $renderer->createTypeLink($exception) ?></td> <td class="paramTypeCol"><?= $renderer->createTypeLink($exception) ?></td>
......
...@@ -36,8 +36,8 @@ if ($protected && count($type->getProtectedMethods()) == 0 || !$protected && cou ...@@ -36,8 +36,8 @@ 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><?= $renderer->createSubjectLink($method, $method->name.'()') ?></td> <td><?= $renderer->createSubjectLink($method, $method->name.'()') ?></td>
<td><?= ApiMarkdown::process($method->shortDescription, $method->definedBy, true) ?></td> <td><?= ApiMarkdown::process($method->shortDescription, $method->definedBy, true) ?></td>
......
...@@ -21,17 +21,17 @@ ArrayHelper::multisort($properties, 'name'); ...@@ -21,17 +21,17 @@ 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 ?>
<span class="detailHeaderTag small"> <span class="detailHeaderTag small">
<?= $property->visibility ?> <?= $property->visibility ?>
<?php if($property->getIsReadOnly()) echo ' <em>read-only</em> '; ?> <?php if ($property->getIsReadOnly()) echo ' <em>read-only</em> '; ?>
<?php if($property->getIsWriteOnly()) echo ' <em>write-only</em> '; ?> <?php if ($property->getIsWriteOnly()) echo ' <em>write-only</em> '; ?>
property property
<?php if(!empty($property->since)): ?> <?php if (!empty($property->since)): ?>
(available since version <?php echo $property->since; ?>) (available since version <?= $property->since ?>)
<?php endif; ?> <?php endif; ?>
</span> </span>
</div> </div>
......
...@@ -36,8 +36,8 @@ if ($protected && count($type->getProtectedProperties()) == 0 || !$protected && ...@@ -36,8 +36,8 @@ 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><?= $renderer->createSubjectLink($property) ?></td> <td><?= $renderer->createSubjectLink($property) ?></td>
<td><?= $renderer->createTypeLink($property->types) ?></td> <td><?= $renderer->createTypeLink($property->types) ?></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>
......
...@@ -4,6 +4,7 @@ use yii\apidoc\helpers\ApiMarkdown; ...@@ -4,6 +4,7 @@ use yii\apidoc\helpers\ApiMarkdown;
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc; use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
/** /**
* @var ClassDoc|InterfaceDoc|TraitDoc $type * @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var yii\web\View $this * @var yii\web\View $this
...@@ -30,16 +31,16 @@ $renderer = $this->context; ...@@ -30,16 +31,16 @@ $renderer = $this->context;
?></h1> ?></h1>
<div id="nav"> <div id="nav">
<a href="index.html">All Classes</a> <a href="index.html">All Classes</a>
<?php if(!($type instanceof InterfaceDoc) && !empty($type->properties)): ?> <?php if (!($type instanceof InterfaceDoc) && !empty($type->properties)): ?>
| <a href="#properties">Properties</a> | <a href="#properties">Properties</a>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($type->methods)): ?> <?php if (!empty($type->methods)): ?>
| <a href="#methods">Methods</a> | <a href="#methods">Methods</a>
<?php endif; ?> <?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->events)): ?> <?php if ($type instanceof ClassDoc && !empty($type->events)): ?>
| <a href="#events">Events</a> | <a href="#events">Events</a>
<?php endif; ?> <?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->constants)): ?> <?php if ($type instanceof ClassDoc && !empty($type->constants)): ?>
| <a href="#constants">Constants</a> | <a href="#constants">Constants</a>
<?php endif; ?> <?php endif; ?>
</div> </div>
...@@ -55,10 +56,10 @@ $renderer = $this->context; ...@@ -55,10 +56,10 @@ $renderer = $this->context;
<?php if ($type instanceof ClassDoc && !empty($type->interfaces)): ?> <?php if ($type instanceof ClassDoc && !empty($type->interfaces)): ?>
<tr><th>Implements</th><td><?= $renderer->renderInterfaces($type->interfaces) ?></td></tr> <tr><th>Implements</th><td><?= $renderer->renderInterfaces($type->interfaces) ?></td></tr>
<?php endif; ?> <?php endif; ?>
<?php if(!($type instanceof InterfaceDoc) && !empty($type->traits)): ?> <?php if (!($type instanceof InterfaceDoc) && !empty($type->traits)): ?>
<tr><th>Uses Traits</th><td><?= $renderer->renderTraits($type->traits) ?></td></tr> <tr><th>Uses Traits</th><td><?= $renderer->renderTraits($type->traits) ?></td></tr>
<?php endif; ?> <?php endif; ?>
<?php if($type instanceof ClassDoc && !empty($type->subclasses)): ?> <?php if ($type instanceof ClassDoc && !empty($type->subclasses)): ?>
<tr><th>Subclasses</th><td><?= $renderer->renderClasses($type->subclasses) ?></td></tr> <tr><th>Subclasses</th><td><?= $renderer->renderClasses($type->subclasses) ?></td></tr>
<?php endif; ?> <?php endif; ?>
<?php if ($type instanceof InterfaceDoc && !empty($type->implementedBy)): ?> <?php if ($type instanceof InterfaceDoc && !empty($type->implementedBy)): ?>
...@@ -67,7 +68,7 @@ $renderer = $this->context; ...@@ -67,7 +68,7 @@ $renderer = $this->context;
<?php if ($type instanceof TraitDoc && !empty($type->usedBy)): ?> <?php if ($type instanceof TraitDoc && !empty($type->usedBy)): ?>
<tr><th>Implemented by</th><td><?= $renderer->renderClasses($type->usedBy) ?></td></tr> <tr><th>Implemented by</th><td><?= $renderer->renderClasses($type->usedBy) ?></td></tr>
<?php endif; ?> <?php endif; ?>
<?php if(!empty($type->since)): ?> <?php if (!empty($type->since)): ?>
<tr><th>Available since version</th><td><?= $type->since ?></td></tr> <tr><th>Available since version</th><td><?= $type->since ?></td></tr>
<?php endif; ?> <?php endif; ?>
<?php if(($sourceUrl = $renderer->getSourceUrl($type)) !== null): ?> <?php if(($sourceUrl = $renderer->getSourceUrl($type)) !== null): ?>
...@@ -84,8 +85,8 @@ $renderer = $this->context; ...@@ -84,8 +85,8 @@ $renderer = $this->context;
</div> </div>
<a name="properties"></a> <a name="properties"></a>
<?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type,'protected' => false]) ?> <?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => false]) ?>
<?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type,'protected' => true]) ?> <?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => true]) ?>
<a name="methods"></a> <a name="methods"></a>
<?= $this->render('@yii/apidoc/templates/html/views/methodSummary', ['type' => $type, 'protected' => false]) ?> <?= $this->render('@yii/apidoc/templates/html/views/methodSummary', ['type' => $type, 'protected' => false]) ?>
...@@ -99,6 +100,6 @@ $renderer = $this->context; ...@@ -99,6 +100,6 @@ $renderer = $this->context;
<?= $this->render('@yii/apidoc/templates/html/views/propertyDetails', ['type' => $type]) ?> <?= $this->render('@yii/apidoc/templates/html/views/propertyDetails', ['type' => $type]) ?>
<?= $this->render('@yii/apidoc/templates/html/views/methodDetails', ['type' => $type]) ?> <?= $this->render('@yii/apidoc/templates/html/views/methodDetails', ['type' => $type]) ?>
<?php if($type instanceof ClassDoc): ?> <?php if ($type instanceof ClassDoc): ?>
<?= $this->render('@yii/apidoc/templates/html/views/eventDetails', ['type' => $type]) ?> <?= $this->render('@yii/apidoc/templates/html/views/eventDetails', ['type' => $type]) ?>
<?php endif; ?> <?php endif; ?>
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\apidoc\templates\online; namespace yii\apidoc\templates\online;
use yii\apidoc\models\Context; use yii\apidoc\models\Context;
use yii\apidoc\models\TypeDoc; use yii\apidoc\models\TypeDoc;
use yii\console\Controller; use yii\console\Controller;
...@@ -36,7 +37,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer ...@@ -36,7 +37,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
} }
$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);
...@@ -46,7 +47,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer ...@@ -46,7 +47,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
} }
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($targetDir . '/packages.txt', serialize($packages)); file_put_contents($targetDir . '/packages.txt', serialize($packages));
...@@ -64,4 +65,4 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer ...@@ -64,4 +65,4 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
{ {
return $this->generateApiUrl($typeName) . '.html'; return $this->generateApiUrl($typeName) . '.html';
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
use yii\apidoc\models\ClassDoc; use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc; use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc; use yii\apidoc\models\TraitDoc;
/** /**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types * @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this * @var yii\web\View $this
...@@ -22,7 +23,7 @@ use yii\apidoc\models\TraitDoc; ...@@ -22,7 +23,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>
......
...@@ -359,4 +359,4 @@ class AuthAction extends Action ...@@ -359,4 +359,4 @@ class AuthAction extends Action
return Yii::$app->getResponse()->redirect($url); return Yii::$app->getResponse()->redirect($url);
} }
} }
} }
\ No newline at end of file
...@@ -233,4 +233,4 @@ abstract class BaseClient extends Component implements ClientInterface ...@@ -233,4 +233,4 @@ abstract class BaseClient extends Component implements ClientInterface
} }
return $attributes; return $attributes;
} }
} }
\ No newline at end of file
...@@ -54,4 +54,4 @@ interface ClientInterface ...@@ -54,4 +54,4 @@ interface ClientInterface
* @return array view options in format: optionName => optionValue * @return array view options in format: optionName => optionValue
*/ */
public function getViewOptions(); public function getViewOptions();
} }
\ No newline at end of file
...@@ -104,4 +104,4 @@ class Collection extends Component ...@@ -104,4 +104,4 @@ class Collection extends Component
$config['id'] = $id; $config['id'] = $id;
return Yii::createObject($config); return Yii::createObject($config);
} }
} }
\ No newline at end of file
...@@ -175,7 +175,7 @@ class OAuth1 extends BaseOAuth ...@@ -175,7 +175,7 @@ class OAuth1 extends BaseOAuth
} }
case 'POST': { case 'POST': {
$curlOptions[CURLOPT_POST] = true; $curlOptions[CURLOPT_POST] = true;
if (!empty($params)){ if (!empty($params)) {
$curlOptions[CURLOPT_POSTFIELDS] = $params; $curlOptions[CURLOPT_POSTFIELDS] = $params;
} }
$authorizationHeader = $this->composeAuthorizationHeader($params); $authorizationHeader = $this->composeAuthorizationHeader($params);
...@@ -352,4 +352,4 @@ class OAuth1 extends BaseOAuth ...@@ -352,4 +352,4 @@ class OAuth1 extends BaseOAuth
} }
return $header; return $header;
} }
} }
\ No newline at end of file
...@@ -182,4 +182,4 @@ class OAuth2 extends BaseOAuth ...@@ -182,4 +182,4 @@ class OAuth2 extends BaseOAuth
$tokenConfig['tokenParamKey'] = 'access_token'; $tokenConfig['tokenParamKey'] = 'access_token';
return parent::createToken($tokenConfig); return parent::createToken($tokenConfig);
} }
} }
\ No newline at end of file
...@@ -58,14 +58,16 @@ class OAuthToken extends Object ...@@ -58,14 +58,16 @@ class OAuthToken extends Object
/** /**
* @param string $expireDurationParamKey expire duration param key. * @param string $expireDurationParamKey expire duration param key.
*/ */
public function setExpireDurationParamKey($expireDurationParamKey) { public function setExpireDurationParamKey($expireDurationParamKey)
{
$this->_expireDurationParamKey = $expireDurationParamKey; $this->_expireDurationParamKey = $expireDurationParamKey;
} }
/** /**
* @return string expire duration param key. * @return string expire duration param key.
*/ */
public function getExpireDurationParamKey() { public function getExpireDurationParamKey()
{
if ($this->_expireDurationParamKey === null) { if ($this->_expireDurationParamKey === null) {
$this->_expireDurationParamKey = $this->defaultExpireDurationParamKey(); $this->_expireDurationParamKey = $this->defaultExpireDurationParamKey();
} }
...@@ -75,14 +77,16 @@ class OAuthToken extends Object ...@@ -75,14 +77,16 @@ class OAuthToken extends Object
/** /**
* @return array * @return array
*/ */
public function getParams() { public function getParams()
{
return $this->_params; return $this->_params;
} }
/** /**
* @param array $params * @param array $params
*/ */
public function setParams(array $params) { public function setParams(array $params)
{
$this->_params = $params; $this->_params = $params;
} }
...@@ -91,7 +95,8 @@ class OAuthToken extends Object ...@@ -91,7 +95,8 @@ class OAuthToken extends Object
* @param string $name param name. * @param string $name param name.
* @param mixed $value param value, * @param mixed $value param value,
*/ */
public function setParam($name, $value) { public function setParam($name, $value)
{
$this->_params[$name] = $value; $this->_params[$name] = $value;
} }
...@@ -100,7 +105,8 @@ class OAuthToken extends Object ...@@ -100,7 +105,8 @@ class OAuthToken extends Object
* @param string $name param name. * @param string $name param name.
* @return mixed param value. * @return mixed param value.
*/ */
public function getParam($name) { public function getParam($name)
{
return isset($this->_params[$name]) ? $this->_params[$name] : null; return isset($this->_params[$name]) ? $this->_params[$name] : null;
} }
...@@ -109,7 +115,8 @@ class OAuthToken extends Object ...@@ -109,7 +115,8 @@ class OAuthToken extends Object
* @param string $token token value. * @param string $token token value.
* @return static self reference. * @return static self reference.
*/ */
public function setToken($token) { public function setToken($token)
{
$this->setParam($this->tokenParamKey, $token); $this->setParam($this->tokenParamKey, $token);
} }
...@@ -117,7 +124,8 @@ class OAuthToken extends Object ...@@ -117,7 +124,8 @@ class OAuthToken extends Object
* Returns token value. * Returns token value.
* @return string token value. * @return string token value.
*/ */
public function getToken() { public function getToken()
{
return $this->getParam($this->tokenParamKey); return $this->getParam($this->tokenParamKey);
} }
...@@ -125,7 +133,8 @@ class OAuthToken extends Object ...@@ -125,7 +133,8 @@ class OAuthToken extends Object
* Sets the token secret value. * Sets the token secret value.
* @param string $tokenSecret token secret. * @param string $tokenSecret token secret.
*/ */
public function setTokenSecret($tokenSecret) { public function setTokenSecret($tokenSecret)
{
$this->setParam($this->tokenSecretParamKey, $tokenSecret); $this->setParam($this->tokenSecretParamKey, $tokenSecret);
} }
...@@ -133,7 +142,8 @@ class OAuthToken extends Object ...@@ -133,7 +142,8 @@ class OAuthToken extends Object
* Returns the token secret value. * Returns the token secret value.
* @return string token secret value. * @return string token secret value.
*/ */
public function getTokenSecret() { public function getTokenSecret()
{
return $this->getParam($this->tokenSecretParamKey); return $this->getParam($this->tokenSecretParamKey);
} }
...@@ -141,7 +151,8 @@ class OAuthToken extends Object ...@@ -141,7 +151,8 @@ class OAuthToken extends Object
* Sets token expire duration. * Sets token expire duration.
* @param string $expireDuration token expiration duration. * @param string $expireDuration token expiration duration.
*/ */
public function setExpireDuration($expireDuration) { public function setExpireDuration($expireDuration)
{
$this->setParam($this->getExpireDurationParamKey(), $expireDuration); $this->setParam($this->getExpireDurationParamKey(), $expireDuration);
} }
...@@ -149,7 +160,8 @@ class OAuthToken extends Object ...@@ -149,7 +160,8 @@ class OAuthToken extends Object
* Returns the token expiration duration. * Returns the token expiration duration.
* @return integer token expiration duration. * @return integer token expiration duration.
*/ */
public function getExpireDuration() { public function getExpireDuration()
{
return $this->getParam($this->getExpireDurationParamKey()); return $this->getParam($this->getExpireDurationParamKey());
} }
...@@ -157,7 +169,8 @@ class OAuthToken extends Object ...@@ -157,7 +169,8 @@ class OAuthToken extends Object
* Fetches default expire duration param key. * Fetches default expire duration param key.
* @return string expire duration param key. * @return string expire duration param key.
*/ */
protected function defaultExpireDurationParamKey() { protected function defaultExpireDurationParamKey()
{
$expireDurationParamKey = 'expires_in'; $expireDurationParamKey = 'expires_in';
foreach ($this->getParams() as $name => $value) { foreach ($this->getParams() as $name => $value) {
if (strpos($name, 'expir') !== false) { if (strpos($name, 'expir') !== false) {
...@@ -172,7 +185,8 @@ class OAuthToken extends Object ...@@ -172,7 +185,8 @@ class OAuthToken extends Object
* Checks if token has expired. * Checks if token has expired.
* @return boolean is token expired. * @return boolean is token expired.
*/ */
public function getIsExpired() { public function getIsExpired()
{
$expirationDuration = $this->getExpireDuration(); $expirationDuration = $this->getExpireDuration();
if (empty($expirationDuration)) { if (empty($expirationDuration)) {
return false; return false;
...@@ -184,8 +198,9 @@ class OAuthToken extends Object ...@@ -184,8 +198,9 @@ class OAuthToken extends Object
* Checks if token is valid. * Checks if token is valid.
* @return boolean is token valid. * @return boolean is token valid.
*/ */
public function getIsValid() { public function getIsValid()
{
$token = $this->getToken(); $token = $this->getToken();
return (!empty($token) && !$this->getIsExpired()); return (!empty($token) && !$this->getIsExpired());
} }
} }
\ No newline at end of file
...@@ -243,10 +243,10 @@ class OpenId extends BaseClient implements ClientInterface ...@@ -243,10 +243,10 @@ class OpenId extends BaseClient implements ClientInterface
if ($this->verifyPeer !== null) { if ($this->verifyPeer !== null) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer);
if($this->capath) { if ($this->capath) {
curl_setopt($curl, CURLOPT_CAPATH, $this->capath); curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
} }
if($this->cainfo) { if ($this->cainfo) {
curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo); curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
} }
} }
...@@ -926,4 +926,4 @@ class OpenId extends BaseClient implements ClientInterface ...@@ -926,4 +926,4 @@ class OpenId extends BaseClient implements ClientInterface
{ {
return array_merge(['id' => $this->getClaimedId()], $this->fetchAttributes()); return array_merge(['id' => $this->getClaimedId()], $this->fetchAttributes());
} }
} }
\ No newline at end of file
...@@ -80,4 +80,4 @@ class Facebook extends OAuth2 ...@@ -80,4 +80,4 @@ class Facebook extends OAuth2
{ {
return 'Facebook'; return 'Facebook';
} }
} }
\ No newline at end of file
...@@ -90,4 +90,4 @@ class GitHub extends OAuth2 ...@@ -90,4 +90,4 @@ class GitHub extends OAuth2
{ {
return 'GitHub'; return 'GitHub';
} }
} }
\ No newline at end of file
...@@ -90,4 +90,4 @@ class GoogleOAuth extends OAuth2 ...@@ -90,4 +90,4 @@ class GoogleOAuth extends OAuth2
{ {
return 'Google'; return 'Google';
} }
} }
\ No newline at end of file
...@@ -87,4 +87,4 @@ class GoogleOpenId extends OpenId ...@@ -87,4 +87,4 @@ class GoogleOpenId extends OpenId
{ {
return 'Google'; return 'Google';
} }
} }
\ No newline at end of file
...@@ -147,7 +147,8 @@ class LinkedIn extends OAuth2 ...@@ -147,7 +147,8 @@ class LinkedIn extends OAuth2
* Generates the auth state value. * Generates the auth state value.
* @return string auth state value. * @return string auth state value.
*/ */
protected function generateAuthState() { protected function generateAuthState()
{
return sha1(uniqid(get_class($this), true)); return sha1(uniqid(get_class($this), true));
} }
...@@ -166,4 +167,4 @@ class LinkedIn extends OAuth2 ...@@ -166,4 +167,4 @@ class LinkedIn extends OAuth2
{ {
return 'LinkedIn'; return 'LinkedIn';
} }
} }
\ No newline at end of file
...@@ -88,4 +88,4 @@ class Twitter extends OAuth1 ...@@ -88,4 +88,4 @@ class Twitter extends OAuth1
{ {
return 'Twitter'; return 'Twitter';
} }
} }
\ No newline at end of file
...@@ -88,4 +88,4 @@ class YandexOAuth extends OAuth2 ...@@ -88,4 +88,4 @@ class YandexOAuth extends OAuth2
{ {
return 'Yandex'; return 'Yandex';
} }
} }
\ No newline at end of file
...@@ -83,4 +83,4 @@ class YandexOpenId extends OpenId ...@@ -83,4 +83,4 @@ class YandexOpenId extends OpenId
{ {
return 'Yandex'; return 'Yandex';
} }
} }
\ No newline at end of file
...@@ -46,4 +46,4 @@ abstract class BaseMethod extends Object ...@@ -46,4 +46,4 @@ abstract class BaseMethod extends Object
} }
return (strcmp($expectedSignature, $signature) === 0); return (strcmp($expectedSignature, $signature) === 0);
} }
} }
\ No newline at end of file
...@@ -44,4 +44,4 @@ class HmacSha1 extends BaseMethod ...@@ -44,4 +44,4 @@ class HmacSha1 extends BaseMethod
{ {
return base64_encode(hash_hmac('sha1', $baseString, $key, true)); return base64_encode(hash_hmac('sha1', $baseString, $key, true));
} }
} }
\ No newline at end of file
...@@ -30,4 +30,4 @@ class PlainText extends BaseMethod ...@@ -30,4 +30,4 @@ class PlainText extends BaseMethod
{ {
return $key; return $key;
} }
} }
\ No newline at end of file
...@@ -165,4 +165,4 @@ class RsaSha1 extends BaseMethod ...@@ -165,4 +165,4 @@ class RsaSha1 extends BaseMethod
openssl_free_key($publicKeyId); openssl_free_key($publicKeyId);
return ($verificationResult == 1); return ($verificationResult == 1);
} }
} }
\ No newline at end of file
...@@ -27,4 +27,4 @@ class ChoiceAsset extends AssetBundle ...@@ -27,4 +27,4 @@ class ChoiceAsset extends AssetBundle
public $depends = [ public $depends = [
'yii\web\YiiAsset', 'yii\web\YiiAsset',
]; ];
} }
\ No newline at end of file
...@@ -70,7 +70,7 @@ class NavBar extends Widget ...@@ -70,7 +70,7 @@ class NavBar extends Widget
*/ */
public $screenReaderToggleText = 'Toggle navigation'; public $screenReaderToggleText = 'Toggle navigation';
/** /**
* @var bool whether the navbar content should be included in an inner div container which by default * @var boolean whether the navbar content should be included in an inner div container which by default
* adds left and right padding. Set this to false for a 100% width navbar. * adds left and right padding. Set this to false for a 100% width navbar.
*/ */
public $renderInnerContainer = true; public $renderInnerContainer = true;
......
...@@ -133,7 +133,7 @@ class Progress extends Widget ...@@ -133,7 +133,7 @@ class Progress extends Widget
/** /**
* Generates a bar * Generates a bar
* @param int $percent the percentage of the bar * @param integer $percent the percentage of the bar
* @param string $label, optional, the label to display at the bar * @param string $label, optional, the label to display at the bar
* @param array $options the HTML attributes of the bar * @param array $options the HTML attributes of the bar
* @return string the rendering result. * @return string the rendering result.
......
...@@ -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);
} }
......
...@@ -168,5 +168,4 @@ class LogTarget extends Target ...@@ -168,5 +168,4 @@ class LogTarget extends Target
# / 2 because messages are in couple (begin/end) # / 2 because messages are in couple (begin/end)
return count($profileLogs) / 2; return count($profileLogs) / 2;
} }
} }
...@@ -37,5 +37,4 @@ abstract class Base extends Component implements MatcherInterface ...@@ -37,5 +37,4 @@ abstract class Base extends Component implements MatcherInterface
{ {
return !empty($this->baseValue) || ($this->baseValue === '0'); return !empty($this->baseValue) || ($this->baseValue === '0');
} }
} }
...@@ -175,5 +175,4 @@ class DbPanel extends Panel ...@@ -175,5 +175,4 @@ class DbPanel extends Panel
{ {
return (($this->criticalQueryThreshold !== null) && ($count > $this->criticalQueryThreshold)); return (($this->criticalQueryThreshold !== null) && ($count > $this->criticalQueryThreshold));
} }
} }
...@@ -102,5 +102,4 @@ class MailPanel extends Panel ...@@ -102,5 +102,4 @@ class MailPanel extends Panel
} }
return $attr; return $attr;
} }
} }
...@@ -35,4 +35,3 @@ echo $this->render('panels/config/table', [ ...@@ -35,4 +35,3 @@ echo $this->render('panels/config/table', [
]); ]);
echo $panel->getPhpInfo(); echo $panel->getPhpInfo();
?>
\ No newline at end of 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>
......
...@@ -67,4 +67,3 @@ echo GridView::widget([ ...@@ -67,4 +67,3 @@ echo GridView::widget([
] ]
], ],
]); ]);
?>
...@@ -70,4 +70,3 @@ echo GridView::widget([ ...@@ -70,4 +70,3 @@ echo GridView::widget([
], ],
], ],
]); ]);
?>
<?php <?php
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Html; use yii\helpers\Html;
?> ?>
<h1>Performance Profiling</h1> <h1>Performance Profiling</h1>
<p>Total processing time: <b><?= $time ?></b>; Peak memory: <b><?= $memory ?></b>.</p> <p>Total processing time: <b><?= $time ?></b>; Peak memory: <b><?= $memory ?></b>.</p>
...@@ -50,4 +51,3 @@ echo GridView::widget([ ...@@ -50,4 +51,3 @@ echo GridView::widget([
], ],
], ],
]); ]);
?>
...@@ -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,12 +489,12 @@ class ActiveRecord extends BaseActiveRecord ...@@ -489,12 +489,12 @@ 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([
"script" => $script, "script" => $script,
"params" => $counters "params" => $counters
]); ]);
$bulk .= $action . "\n" . $data . "\n"; $bulk .= $action . "\n" . $data . "\n";
} }
...@@ -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']) {
......
...@@ -364,7 +364,7 @@ class Command extends Component ...@@ -364,7 +364,7 @@ class Command extends Component
* @param $pattern * @param $pattern
* @param $settings * @param $settings
* @param $mappings * @param $mappings
* @param int $order * @param integer $order
* @return mixed * @return mixed
* @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html * @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-templates.html
*/ */
...@@ -400,4 +400,4 @@ class Command extends Component ...@@ -400,4 +400,4 @@ class Command extends Component
{ {
return $this->db->get(['_template', $name]); return $this->db->get(['_template', $name]);
} }
} }
\ No newline at end of file
...@@ -29,7 +29,7 @@ class Connection extends Component ...@@ -29,7 +29,7 @@ class Connection extends Component
const EVENT_AFTER_OPEN = 'afterOpen'; const EVENT_AFTER_OPEN = 'afterOpen';
/** /**
* @var bool whether to autodetect available cluster nodes on [[open()]] * @var boolean whether to autodetect available cluster nodes on [[open()]]
*/ */
public $autodetectCluster = true; public $autodetectCluster = true;
/** /**
...@@ -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.');
} }
...@@ -210,7 +210,7 @@ class Connection extends Component ...@@ -210,7 +210,7 @@ class Connection extends Component
private function createUrl($path, $options = []) private function createUrl($path, $options = [])
{ {
if (!is_string($path)) { if (!is_string($path)) {
$url = implode('/', array_map(function($a) { $url = implode('/', array_map(function ($a) {
return urlencode(is_array($a) ? implode(',', $a) : $a); return urlencode(is_array($a) ? implode(',', $a) : $a);
}, $path)); }, $path));
if (!empty($options)) { if (!empty($options)) {
...@@ -240,7 +240,7 @@ class Connection extends Component ...@@ -240,7 +240,7 @@ class Connection extends Component
// http://www.php.net/manual/en/function.curl-setopt.php#82418 // http://www.php.net/manual/en/function.curl-setopt.php#82418
CURLOPT_HTTPHEADER => ['Expect:'], CURLOPT_HTTPHEADER => ['Expect:'],
CURLOPT_WRITEFUNCTION => function($curl, $data) use (&$body) { CURLOPT_WRITEFUNCTION => function ($curl, $data) use (&$body) {
$body .= $data; $body .= $data;
return mb_strlen($data, '8bit'); return mb_strlen($data, '8bit');
}, },
...@@ -355,4 +355,4 @@ class Connection extends Component ...@@ -355,4 +355,4 @@ class Connection extends Component
{ {
return $this->get(['_cluster', 'state']); return $this->get(['_cluster', 'state']);
} }
} }
\ No newline at end of file
...@@ -22,4 +22,4 @@ class Exception extends \yii\db\Exception ...@@ -22,4 +22,4 @@ class Exception extends \yii\db\Exception
{ {
return 'Elasticsearch Database Exception'; return 'Elasticsearch Database Exception';
} }
} }
\ No newline at end of file
...@@ -501,4 +501,4 @@ class Query extends Component implements QueryInterface ...@@ -501,4 +501,4 @@ class Query extends Component implements QueryInterface
$this->timeout = $timeout; $this->timeout = $timeout;
return $this; return $this;
} }
} }
\ No newline at end of file
...@@ -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']];
......
...@@ -13,7 +13,6 @@ use yii\base\InvalidConfigException; ...@@ -13,7 +13,6 @@ use yii\base\InvalidConfigException;
use yii\base\Model; use yii\base\Model;
use yii\web\View; use yii\web\View;
/** /**
* This is the base class for all generator classes. * This is the base class for all generator classes.
* *
......
...@@ -73,7 +73,7 @@ HTML; ...@@ -73,7 +73,7 @@ HTML;
} }
} }
// Added lines only on the right side // Added lines only on the right side
else if ($change['tag'] === 'insert') { elseif ($change['tag'] === 'insert') {
foreach ($change['changed']['lines'] as $no => $line) { foreach ($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1; $toLine = $change['changed']['offset'] + $no + 1;
$html .= <<<HTML $html .= <<<HTML
...@@ -86,7 +86,7 @@ HTML; ...@@ -86,7 +86,7 @@ HTML;
} }
} }
// Show deleted lines only on the left side // Show deleted lines only on the left side
else if ($change['tag'] === 'delete') { elseif ($change['tag'] === 'delete') {
foreach ($change['base']['lines'] as $no => $line) { foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1; $fromLine = $change['base']['offset'] + $no + 1;
$html .= <<<HTML $html .= <<<HTML
...@@ -99,7 +99,7 @@ HTML; ...@@ -99,7 +99,7 @@ HTML;
} }
} }
// Show modified lines on both sides // Show modified lines on both sides
else if ($change['tag'] === 'replace') { elseif ($change['tag'] === 'replace') {
foreach ($change['base']['lines'] as $no => $line) { foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1; $fromLine = $change['base']['offset'] + $no + 1;
$html .= <<<HTML $html .= <<<HTML
...@@ -132,4 +132,4 @@ HTML; ...@@ -132,4 +132,4 @@ HTML;
HTML; HTML;
return $html; return $html;
} }
} }
\ No newline at end of file
...@@ -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 ?>');
......
...@@ -499,5 +499,4 @@ class Generator extends \yii\gii\Generator ...@@ -499,5 +499,4 @@ class Generator extends \yii\gii\Generator
return $model->attributes(); return $model->attributes();
} }
} }
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
namespace yii\jui; namespace yii\jui;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**
......
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