Commit 668dacba by Carsten Brandt

Merge pull request #2622 branch 'ext-codestyle-fix' of…

Merge pull request #2622 branch 'ext-codestyle-fix' of https://github.com/AlexGx/yii2 into code-style * 'ext-codestyle-fix' of https://github.com/AlexGx/yii2: fix php5.4 array syntax many phpcs fixes fix phpDoc LuaScriptBuilder build @throws Conflicts: extensions/apidoc/commands/RenderController.php extensions/apidoc/models/BaseDoc.php extensions/apidoc/templates/BaseRenderer.php extensions/apidoc/templates/bootstrap/Renderer.php extensions/apidoc/templates/bootstrap/layouts/guide.php extensions/apidoc/templates/bootstrap/layouts/main.php extensions/apidoc/templates/html/Renderer.php extensions/apidoc/templates/offline/Renderer.php extensions/apidoc/templates/offline/assets/AssetBundle.php extensions/apidoc/templates/offline/views/index.php
parents e2aacad8 c906d433
......@@ -15,7 +15,7 @@ $composerAutoload = [
__DIR__ . '/../../autoload.php', // script is installed as a composer binary
];
$vendorPath = null;
foreach($composerAutoload as $autoload) {
foreach ($composerAutoload as $autoload) {
if (file_exists($autoload)) {
require($autoload);
$vendorPath = dirname($autoload);
......@@ -27,7 +27,7 @@ $yiiDirs = [
__DIR__ . '/vendor/yiisoft/yii2', // standalone with "composer install" run
__DIR__ . '/../../yiisoft/yii2', // script is installed as a composer binary
];
foreach($yiiDirs as $dir) {
foreach ($yiiDirs as $dir) {
if (file_exists($dir . '/Yii.php')) {
require($dir . '/Yii.php');
break;
......
......@@ -70,7 +70,7 @@ class ApiMarkdown extends GithubMarkdown
if (!empty($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) {
$block['content'][] = $line;
} else {
......
......@@ -38,4 +38,4 @@ class PrettyPrinter extends \phpDocumentor\Reflection\PrettyPrinter
$printer = new static();
return $printer->prettyPrintExpr($value);
}
}
\ No newline at end of file
}
......@@ -76,7 +76,7 @@ class BaseDoc extends Object
$this->phpDocContext = $docblock->getContext();
$this->tags = $docblock->getTags();
foreach($this->tags as $i => $tag) {
foreach ($this->tags as $i => $tag) {
if ($tag instanceof SinceTag) {
$this->since = $tag->getVersion();
unset($this->tags[$i]);
......
......@@ -45,12 +45,12 @@ class ClassDoc extends TypeDoc
if (($subject = parent::findSubject($subjectName)) !== null) {
return $subject;
}
foreach($this->events as $name => $event) {
foreach ($this->events as $name => $event) {
if ($subjectName == $name) {
return $event;
}
}
foreach($this->constants as $name => $constant) {
foreach ($this->constants as $name => $constant) {
if ($subjectName == $name) {
return $constant;
}
......@@ -64,7 +64,7 @@ class ClassDoc extends TypeDoc
public function getNativeEvents()
{
$events = [];
foreach($this->events as $name => $event) {
foreach ($this->events as $name => $event) {
if ($event->definedBy != $this->name) {
continue;
}
......@@ -93,13 +93,13 @@ class ClassDoc extends TypeDoc
$this->isAbstract = $reflector->isAbstract();
$this->isFinal = $reflector->isFinal();
foreach($reflector->getInterfaces() as $interface) {
foreach ($reflector->getInterfaces() as $interface) {
$this->interfaces[] = ltrim($interface, '\\');
}
foreach($reflector->getTraits() as $trait) {
foreach ($reflector->getTraits() as $trait) {
$this->traits[] = ltrim($trait, '\\');
}
foreach($reflector->getConstants() as $constantReflector) {
foreach ($reflector->getConstants() as $constantReflector) {
$docblock = $constantReflector->getDocBlock();
if ($docblock !== null && count($docblock->getTagsByName('event')) > 0) {
$event = new EventDoc($constantReflector);
......@@ -112,4 +112,4 @@ class ClassDoc extends TypeDoc
}
}
}
}
\ No newline at end of file
}
......@@ -33,4 +33,4 @@ class ConstDoc extends BaseDoc
$this->value = $reflector->getValue();
}
}
\ No newline at end of file
}
......@@ -57,15 +57,15 @@ class Context extends Component
$reflection = new FileReflector($fileName, true);
$reflection->process();
foreach($reflection->getClasses() as $class) {
foreach ($reflection->getClasses() as $class) {
$class = new ClassDoc($class, $this, ['sourceFile' => $fileName]);
$this->classes[$class->name] = $class;
}
foreach($reflection->getInterfaces() as $interface) {
foreach ($reflection->getInterfaces() as $interface) {
$interface = new InterfaceDoc($interface, $this, ['sourceFile' => $fileName]);
$this->interfaces[$interface->name] = $interface;
}
foreach($reflection->getTraits() as $trait) {
foreach ($reflection->getTraits() as $trait) {
$trait = new TraitDoc($trait, $this, ['sourceFile' => $fileName]);
$this->traits[$trait->name] = $trait;
}
......@@ -74,7 +74,7 @@ class Context extends Component
public function updateReferences()
{
// update all subclass references
foreach($this->classes as $class) {
foreach ($this->classes as $class) {
$className = $class->name;
while (isset($this->classes[$class->parentClass])) {
$class = $this->classes[$class->parentClass];
......@@ -82,12 +82,12 @@ class Context extends Component
}
}
// update interfaces of subclasses
foreach($this->classes as $class) {
foreach ($this->classes as $class) {
$this->updateSubclassInferfacesTraits($class);
}
// update implementedBy and usedBy for interfaces and traits
foreach($this->classes as $class) {
foreach($class->traits as $trait) {
foreach ($this->classes as $class) {
foreach ($class->traits as $trait) {
if (isset($this->traits[$trait])) {
$trait = $this->traits[$trait];
$trait->usedBy[] = $class->name;
......@@ -95,12 +95,12 @@ class Context extends Component
$class->methods = array_merge($trait->methods, $class->methods);
}
}
foreach($class->interfaces as $interface) {
foreach ($class->interfaces as $interface) {
if (isset($this->interfaces[$interface])) {
$this->interfaces[$interface]->implementedBy[] = $class->name;
if ($class->isAbstract) {
// 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])) {
$class->methods[$method->name] = $method;
}
......@@ -114,11 +114,11 @@ class Context extends Component
$this->inheritDocs($class);
}
// inherit properties, methods, contants and events to subclasses
foreach($this->classes as $class) {
foreach ($this->classes as $class) {
$this->updateSubclassInheritance($class);
}
// add properties from getters and setters
foreach($this->classes as $class) {
foreach ($this->classes as $class) {
$this->handlePropertyFeature($class);
}
......@@ -131,7 +131,7 @@ class Context extends Component
*/
protected function updateSubclassInferfacesTraits($class)
{
foreach($class->subclasses as $subclass) {
foreach ($class->subclasses as $subclass) {
$subclass = $this->classes[$subclass];
$subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces));
$subclass->traits = array_unique(array_merge($subclass->traits, $class->traits));
......@@ -145,7 +145,7 @@ class Context extends Component
*/
protected function updateSubclassInheritance($class)
{
foreach($class->subclasses as $subclass) {
foreach ($class->subclasses as $subclass) {
$subclass = $this->classes[$subclass];
$subclass->events = array_merge($class->events, $subclass->events);
$subclass->constants = array_merge($class->constants, $subclass->constants);
......@@ -203,7 +203,7 @@ class Context extends Component
if (!$this->isSubclassOf($class, 'yii\base\Object')) {
return;
}
foreach($class->getPublicMethods() as $name => $method) {
foreach ($class->getPublicMethods() as $name => $method) {
if ($method->isStatic) {
continue;
}
......@@ -275,7 +275,7 @@ class Context extends Component
*/
private function paramsOptional($method, $number = 0)
{
foreach($method->params as $param) {
foreach ($method->params as $param) {
if (!$param->isOptional && $number-- <= 0) {
return false;
}
......@@ -289,7 +289,7 @@ class Context extends Component
*/
private function getFirstNotOptionalParameter($method)
{
foreach($method->params as $param) {
foreach ($method->params as $param) {
if (!$param->isOptional) {
return $param;
}
......@@ -309,7 +309,7 @@ class Context extends Component
if ($classA->name == $classB) {
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];
if ($classA->name == $classB) {
return true;
......@@ -317,4 +317,4 @@ class Context extends Component
}
return false;
}
}
\ No newline at end of file
}
......@@ -34,7 +34,7 @@ class EventDoc extends ConstDoc
return;
}
foreach($this->tags as $i => $tag) {
foreach ($this->tags as $i => $tag) {
if ($tag->getName() == 'event') {
$eventTag = new ReturnTag('event', $tag->getContent(), $tag->getDocBlock(), $tag->getLocation());
$this->type = $eventTag->getType();
......@@ -49,4 +49,4 @@ class EventDoc extends ConstDoc
}
}
}
}
\ No newline at end of file
}
......@@ -45,17 +45,17 @@ class FunctionDoc extends BaseDoc
$this->isReturnByReference = $reflector->isByRef();
foreach($reflector->getArguments() as $arg) {
foreach ($reflector->getArguments() as $arg) {
$arg = new ParamDoc($arg, $context, ['sourceFile' => $this->sourceFile]);
$this->params[$arg->name] = $arg;
}
foreach($this->tags as $i => $tag) {
foreach ($this->tags as $i => $tag) {
if ($tag instanceof ThrowsTag) {
$this->exceptions[$tag->getType()] = $tag->getDescription();
unset($this->tags[$i]);
} elseif ($tag instanceof PropertyTag) {
// ignore property tag
// ignore property tag
} elseif ($tag instanceof ParamTag) {
$paramName = $tag->getVariableName();
if (!isset($this->params[$paramName]) && $context !== null) {
......
......@@ -33,15 +33,15 @@ class InterfaceDoc extends TypeDoc
return;
}
foreach($reflector->getParentInterfaces() as $interface) {
foreach ($reflector->getParentInterfaces() as $interface) {
$this->parentInterfaces[] = ltrim($interface, '\\');
}
foreach($this->methods as $method) {
foreach ($this->methods as $method) {
$method->isAbstract = true;
}
// interface can not have properties
$this->properties = null;
}
}
\ No newline at end of file
}
......@@ -53,4 +53,4 @@ class ParamDoc extends Object
}
$this->isPassedByReference = $reflector->isByRef();
}
}
\ No newline at end of file
}
......@@ -63,7 +63,7 @@ class PropertyDoc extends BaseDoc
$this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
}
foreach($this->tags as $tag) {
foreach ($this->tags as $tag) {
if ($tag instanceof VarTag) {
$this->type = $tag->getType();
$this->types = $tag->getTypes();
......@@ -83,4 +83,4 @@ class PropertyDoc extends BaseDoc
];
}
}
}
\ No newline at end of file
}
......@@ -34,8 +34,8 @@ class TraitDoc extends TypeDoc
return;
}
foreach($reflector->getTraits() as $trait) {
foreach ($reflector->getTraits() as $trait) {
$this->traits[] = ltrim($trait, '\\');
}
}
}
\ No newline at end of file
}
......@@ -41,7 +41,7 @@ class TypeDoc extends BaseDoc
public function findSubject($subjectName)
{
if ($subjectName[0] != '$') {
foreach($this->methods as $name => $method) {
foreach ($this->methods as $name => $method) {
if (rtrim($subjectName, '()') == $name) {
return $method;
}
......@@ -53,7 +53,7 @@ class TypeDoc extends BaseDoc
if ($this->properties === null) {
return null;
}
foreach($this->properties as $name => $property) {
foreach ($this->properties as $name => $property) {
if (ltrim($subjectName, '$') == ltrim($name, '$')) {
return $property;
}
......@@ -93,7 +93,7 @@ class TypeDoc extends BaseDoc
private function getFilteredMethods($visibility = null, $definedBy = null)
{
$methods = [];
foreach($this->methods as $name => $method) {
foreach ($this->methods as $name => $method) {
if ($visibility !== null && $method->visibility != $visibility) {
continue;
}
......@@ -140,7 +140,7 @@ class TypeDoc extends BaseDoc
return [];
}
$properties = [];
foreach($this->properties as $name => $property) {
foreach ($this->properties as $name => $property) {
if ($visibility !== null && $property->visibility != $visibility) {
continue;
}
......@@ -167,14 +167,14 @@ class TypeDoc extends BaseDoc
return;
}
foreach($this->tags as $i => $tag) {
foreach ($this->tags as $i => $tag) {
if ($tag instanceof AuthorTag) {
$this->authors[$tag->getAuthorName()] = $tag->getAuthorEmail();
unset($this->tags[$i]);
}
}
foreach($reflector->getProperties() as $propertyReflector) {
foreach ($reflector->getProperties() as $propertyReflector) {
if ($propertyReflector->getVisibility() != 'private') {
$property = new PropertyDoc($propertyReflector, $context, ['sourceFile' => $this->sourceFile]);
$property->definedBy = $this->name;
......@@ -182,7 +182,7 @@ class TypeDoc extends BaseDoc
}
}
foreach($reflector->getMethods() as $methodReflector) {
foreach ($reflector->getMethods() as $methodReflector) {
if ($methodReflector->getVisibility() != 'private') {
$method = new MethodDoc($methodReflector, $context, ['sourceFile' => $this->sourceFile]);
$method->definedBy = $this->name;
......@@ -190,4 +190,4 @@ class TypeDoc extends BaseDoc
}
}
}
}
\ No newline at end of file
}
......@@ -153,7 +153,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
$label .= ' ' . Html::tag('b', '', ['class' => 'caret']);
if (is_array($items)) {
if ($active === false) {
foreach($items as $subItem) {
foreach ($items as $subItem) {
if (isset($subItem['active']) && $subItem['active']) {
$active = true;
}
......
......@@ -6,6 +6,7 @@
*/
namespace yii\apidoc\templates\bootstrap\assets;
use yii\web\View;
/**
......
......@@ -20,7 +20,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
$types = $renderer->getNavTypes(isset($type) ? $type : null, $types);
ksort($types);
$nav = [];
foreach($types as $i=>$class) {
foreach ($types as $i => $class) {
$namespace = $class->namespace;
if (empty($namespace)) {
$namespace = 'Not namespaced classes';
......
......@@ -19,7 +19,7 @@ $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php'); ?>
'url' => $this->context->generateGuideUrl('index.md'),
'active' => isset($currentFile) && (basename($currentFile) == 'index.md'),
];
foreach($headlines as $file => $headline) {
foreach ($headlines as $file => $headline) {
$nav[] = [
'label' => $headline,
'url' => $this->context->generateGuideUrl($file),
......
......@@ -54,7 +54,7 @@ $this->beginPage();
if (!empty($this->context->extensions))
{
$extItems = [];
foreach($this->context->extensions as $ext) {
foreach ($this->context->extensions as $ext) {
$extItems[] = [
'label' => $ext,
'url' => "./ext-{$ext}-index.html",
......
......@@ -3,6 +3,7 @@
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this
......@@ -29,7 +30,7 @@ if (isset($readme)) {
</tr>
<?php
ksort($types);
foreach($types as $i=>$class):
foreach($types as $i => $class):
?>
<tr>
<td><?= $renderer->createTypeLink($class, $class, $class->name) ?></td>
......
......@@ -6,7 +6,7 @@
*/
$see = [];
foreach($object->tags as $tag) {
foreach ($object->tags as $tag) {
/** @var $tag phpDocumentor\Reflection\DocBlock\Tag\SeeTag */
if (get_class($tag) == 'phpDocumentor\Reflection\DocBlock\Tag\SeeTag') {
$ref = $tag->getReference();
......
......@@ -4,6 +4,7 @@ use yii\apidoc\helpers\ApiMarkdown;
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc|InterfaceDoc|TraitDoc $type
* @var yii\web\View $this
......@@ -84,8 +85,8 @@ $renderer = $this->context;
</div>
<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' => true]) ?>
<?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => false]) ?>
<?= $this->render('@yii/apidoc/templates/html/views/propertySummary', ['type' => $type, 'protected' => true]) ?>
<a name="methods"></a>
<?= $this->render('@yii/apidoc/templates/html/views/methodSummary', ['type' => $type, 'protected' => false]) ?>
......
......@@ -6,6 +6,7 @@
*/
namespace yii\apidoc\templates\online;
use yii\apidoc\models\Context;
use yii\apidoc\models\TypeDoc;
use yii\console\Controller;
......@@ -36,7 +37,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
}
$packages = [];
$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 */
if (empty($type->namespace)) {
$notNamespaced[] = str_replace('\\', '-', $type->name);
......@@ -46,7 +47,7 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
}
ksort($packages);
$packages = array_merge(['Not namespaced' => $notNamespaced], $packages);
foreach($packages as $name => $classes) {
foreach ($packages as $name => $classes) {
sort($packages[$name]);
}
file_put_contents($targetDir . '/packages.txt', serialize($packages));
......@@ -64,4 +65,4 @@ class ApiRenderer extends \yii\apidoc\templates\html\ApiRenderer
{
return $this->generateApiUrl($typeName) . '.html';
}
}
\ No newline at end of file
}
......@@ -3,6 +3,7 @@
use yii\apidoc\models\ClassDoc;
use yii\apidoc\models\InterfaceDoc;
use yii\apidoc\models\TraitDoc;
/**
* @var ClassDoc[]|InterfaceDoc[]|TraitDoc[] $types
* @var yii\web\View $this
......@@ -22,7 +23,7 @@ use yii\apidoc\models\TraitDoc;
</tr>
<?php
ksort($types);
foreach($types as $i=>$class):
foreach($types as $i => $class):
?>
<tr>
<td><?= $this->context->typeLink($class, $class->name) ?></td>
......
......@@ -359,4 +359,4 @@ class AuthAction extends Action
return Yii::$app->getResponse()->redirect($url);
}
}
}
\ No newline at end of file
}
......@@ -233,4 +233,4 @@ abstract class BaseClient extends Component implements ClientInterface
}
return $attributes;
}
}
\ No newline at end of file
}
......@@ -54,4 +54,4 @@ interface ClientInterface
* @return array view options in format: optionName => optionValue
*/
public function getViewOptions();
}
\ No newline at end of file
}
......@@ -104,4 +104,4 @@ class Collection extends Component
$config['id'] = $id;
return Yii::createObject($config);
}
}
\ No newline at end of file
}
......@@ -175,7 +175,7 @@ class OAuth1 extends BaseOAuth
}
case 'POST': {
$curlOptions[CURLOPT_POST] = true;
if (!empty($params)){
if (!empty($params)) {
$curlOptions[CURLOPT_POSTFIELDS] = $params;
}
$authorizationHeader = $this->composeAuthorizationHeader($params);
......@@ -352,4 +352,4 @@ class OAuth1 extends BaseOAuth
}
return $header;
}
}
\ No newline at end of file
}
......@@ -182,4 +182,4 @@ class OAuth2 extends BaseOAuth
$tokenConfig['tokenParamKey'] = 'access_token';
return parent::createToken($tokenConfig);
}
}
\ No newline at end of file
}
......@@ -58,14 +58,16 @@ class OAuthToken extends Object
/**
* @param string $expireDurationParamKey expire duration param key.
*/
public function setExpireDurationParamKey($expireDurationParamKey) {
public function setExpireDurationParamKey($expireDurationParamKey)
{
$this->_expireDurationParamKey = $expireDurationParamKey;
}
/**
* @return string expire duration param key.
*/
public function getExpireDurationParamKey() {
public function getExpireDurationParamKey()
{
if ($this->_expireDurationParamKey === null) {
$this->_expireDurationParamKey = $this->defaultExpireDurationParamKey();
}
......@@ -75,14 +77,16 @@ class OAuthToken extends Object
/**
* @return array
*/
public function getParams() {
public function getParams()
{
return $this->_params;
}
/**
* @param array $params
*/
public function setParams(array $params) {
public function setParams(array $params)
{
$this->_params = $params;
}
......@@ -91,7 +95,8 @@ class OAuthToken extends Object
* @param string $name param name.
* @param mixed $value param value,
*/
public function setParam($name, $value) {
public function setParam($name, $value)
{
$this->_params[$name] = $value;
}
......@@ -100,7 +105,8 @@ class OAuthToken extends Object
* @param string $name param name.
* @return mixed param value.
*/
public function getParam($name) {
public function getParam($name)
{
return isset($this->_params[$name]) ? $this->_params[$name] : null;
}
......@@ -109,7 +115,8 @@ class OAuthToken extends Object
* @param string $token token value.
* @return static self reference.
*/
public function setToken($token) {
public function setToken($token)
{
$this->setParam($this->tokenParamKey, $token);
}
......@@ -117,7 +124,8 @@ class OAuthToken extends Object
* Returns token value.
* @return string token value.
*/
public function getToken() {
public function getToken()
{
return $this->getParam($this->tokenParamKey);
}
......@@ -125,7 +133,8 @@ class OAuthToken extends Object
* Sets the token secret value.
* @param string $tokenSecret token secret.
*/
public function setTokenSecret($tokenSecret) {
public function setTokenSecret($tokenSecret)
{
$this->setParam($this->tokenSecretParamKey, $tokenSecret);
}
......@@ -133,7 +142,8 @@ class OAuthToken extends Object
* Returns the token secret value.
* @return string token secret value.
*/
public function getTokenSecret() {
public function getTokenSecret()
{
return $this->getParam($this->tokenSecretParamKey);
}
......@@ -141,7 +151,8 @@ class OAuthToken extends Object
* Sets token expire duration.
* @param string $expireDuration token expiration duration.
*/
public function setExpireDuration($expireDuration) {
public function setExpireDuration($expireDuration)
{
$this->setParam($this->getExpireDurationParamKey(), $expireDuration);
}
......@@ -149,7 +160,8 @@ class OAuthToken extends Object
* Returns the token expiration duration.
* @return integer token expiration duration.
*/
public function getExpireDuration() {
public function getExpireDuration()
{
return $this->getParam($this->getExpireDurationParamKey());
}
......@@ -157,7 +169,8 @@ class OAuthToken extends Object
* Fetches default expire duration param key.
* @return string expire duration param key.
*/
protected function defaultExpireDurationParamKey() {
protected function defaultExpireDurationParamKey()
{
$expireDurationParamKey = 'expires_in';
foreach ($this->getParams() as $name => $value) {
if (strpos($name, 'expir') !== false) {
......@@ -172,7 +185,8 @@ class OAuthToken extends Object
* Checks if token has expired.
* @return boolean is token expired.
*/
public function getIsExpired() {
public function getIsExpired()
{
$expirationDuration = $this->getExpireDuration();
if (empty($expirationDuration)) {
return false;
......@@ -184,8 +198,9 @@ class OAuthToken extends Object
* Checks if token is valid.
* @return boolean is token valid.
*/
public function getIsValid() {
public function getIsValid()
{
$token = $this->getToken();
return (!empty($token) && !$this->getIsExpired());
}
}
\ No newline at end of file
}
......@@ -243,10 +243,10 @@ class OpenId extends BaseClient implements ClientInterface
if ($this->verifyPeer !== null) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer);
if($this->capath) {
if ($this->capath) {
curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
}
if($this->cainfo) {
if ($this->cainfo) {
curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
}
}
......@@ -926,4 +926,4 @@ class OpenId extends BaseClient implements ClientInterface
{
return array_merge(['id' => $this->getClaimedId()], $this->fetchAttributes());
}
}
\ No newline at end of file
}
......@@ -80,4 +80,4 @@ class Facebook extends OAuth2
{
return 'Facebook';
}
}
\ No newline at end of file
}
......@@ -90,4 +90,4 @@ class GitHub extends OAuth2
{
return 'GitHub';
}
}
\ No newline at end of file
}
......@@ -90,4 +90,4 @@ class GoogleOAuth extends OAuth2
{
return 'Google';
}
}
\ No newline at end of file
}
......@@ -87,4 +87,4 @@ class GoogleOpenId extends OpenId
{
return 'Google';
}
}
\ No newline at end of file
}
......@@ -147,7 +147,8 @@ class LinkedIn extends OAuth2
* Generates the auth state value.
* @return string auth state value.
*/
protected function generateAuthState() {
protected function generateAuthState()
{
return sha1(uniqid(get_class($this), true));
}
......@@ -166,4 +167,4 @@ class LinkedIn extends OAuth2
{
return 'LinkedIn';
}
}
\ No newline at end of file
}
......@@ -88,4 +88,4 @@ class Twitter extends OAuth1
{
return 'Twitter';
}
}
\ No newline at end of file
}
......@@ -88,4 +88,4 @@ class YandexOAuth extends OAuth2
{
return 'Yandex';
}
}
\ No newline at end of file
}
......@@ -83,4 +83,4 @@ class YandexOpenId extends OpenId
{
return 'Yandex';
}
}
\ No newline at end of file
}
......@@ -46,4 +46,4 @@ abstract class BaseMethod extends Object
}
return (strcmp($expectedSignature, $signature) === 0);
}
}
\ No newline at end of file
}
......@@ -44,4 +44,4 @@ class HmacSha1 extends BaseMethod
{
return base64_encode(hash_hmac('sha1', $baseString, $key, true));
}
}
\ No newline at end of file
}
......@@ -30,4 +30,4 @@ class PlainText extends BaseMethod
{
return $key;
}
}
\ No newline at end of file
}
......@@ -165,4 +165,4 @@ class RsaSha1 extends BaseMethod
openssl_free_key($publicKeyId);
return ($verificationResult == 1);
}
}
\ No newline at end of file
}
......@@ -27,4 +27,4 @@ class ChoiceAsset extends AssetBundle
public $depends = [
'yii\web\YiiAsset',
];
}
\ No newline at end of file
}
......@@ -192,7 +192,7 @@ class Installer extends LibraryInstaller
if (!file_exists($yiiDir)) {
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
<?php
/**
......@@ -213,7 +213,7 @@ EOF
protected function removeBaseYiiFiles()
{
$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)) {
unlink($yiiDir . '/' . $file);
}
......
......@@ -168,5 +168,4 @@ class LogTarget extends Target
# / 2 because messages are in couple (begin/end)
return count($profileLogs) / 2;
}
}
......@@ -37,5 +37,4 @@ abstract class Base extends Component implements MatcherInterface
{
return !empty($this->baseValue) || ($this->baseValue === '0');
}
}
......@@ -175,5 +175,4 @@ class DbPanel extends Panel
{
return (($this->criticalQueryThreshold !== null) && ($count > $this->criticalQueryThreshold));
}
}
......@@ -102,5 +102,4 @@ class MailPanel extends Panel
}
return $attr;
}
}
......@@ -35,4 +35,3 @@ echo $this->render('panels/config/table', [
]);
echo $panel->getPhpInfo();
?>
\ No newline at end of file
......@@ -67,4 +67,3 @@ echo GridView::widget([
]
],
]);
?>
......@@ -70,4 +70,3 @@ echo GridView::widget([
],
],
]);
?>
<?php
use yii\grid\GridView;
use yii\helpers\Html;
?>
<h1>Performance Profiling</h1>
<p>Total processing time: <b><?= $time ?></b>; Peak memory: <b><?= $memory ?></b>.</p>
......@@ -50,4 +51,3 @@ echo GridView::widget([
],
],
]);
?>
......@@ -156,7 +156,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
$models = $this->createModels($result['hits']['hits']);
if ($this->asArray && !$this->indexBy) {
foreach($models as $key => $model) {
foreach ($models as $key => $model) {
if ($pk === '_id') {
$model['_source']['_id'] = $model['_id'];
}
......@@ -168,7 +168,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach($models as $model) {
foreach ($models as $model) {
$model->afterFind();
}
}
......@@ -226,7 +226,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
/** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass;
$pk = $modelClass::primaryKey()[0];
foreach($models as $key => $model) {
foreach ($models as $key => $model) {
if ($pk === '_id') {
$model['_source']['_id'] = $model['_id'];
}
......@@ -238,7 +238,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach($models as $model) {
foreach ($models as $model) {
$model->afterFind();
}
}
......
......@@ -122,7 +122,7 @@ class ActiveRecord extends BaseActiveRecord
$command = static::getDb()->createCommand();
$result = $command->mget(static::index(), static::type(), $primaryKeys, $options);
$models = [];
foreach($result['docs'] as $doc) {
foreach ($result['docs'] as $doc) {
if ($doc['exists']) {
$model = static::instantiate($doc);
static::populateRecord($model, $doc);
......@@ -422,7 +422,7 @@ class ActiveRecord extends BaseActiveRecord
return 0;
}
$bulk = '';
foreach($primaryKeys as $pk) {
foreach ($primaryKeys as $pk) {
$action = Json::encode([
"update" => [
"_id" => $pk,
......@@ -441,7 +441,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$errors = [];
foreach($response['items'] as $item) {
foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) {
$errors[] = $item['update'];
} elseif ($item['update']['ok']) {
......@@ -480,7 +480,7 @@ class ActiveRecord extends BaseActiveRecord
return 0;
}
$bulk = '';
foreach($primaryKeys as $pk) {
foreach ($primaryKeys as $pk) {
$action = Json::encode([
"update" => [
"_id" => $pk,
......@@ -489,12 +489,12 @@ class ActiveRecord extends BaseActiveRecord
],
]);
$script = '';
foreach($counters as $counter => $value) {
foreach ($counters as $counter => $value) {
$script .= "ctx._source.$counter += $counter;\n";
}
$data = Json::encode([
"script" => $script,
"params" => $counters
"params" => $counters
]);
$bulk .= $action . "\n" . $data . "\n";
}
......@@ -504,7 +504,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$errors = [];
foreach($response['items'] as $item) {
foreach ($response['items'] as $item) {
if (isset($item['update']['error'])) {
$errors[] = $item['update'];
} elseif ($item['update']['ok']) {
......@@ -543,7 +543,7 @@ class ActiveRecord extends BaseActiveRecord
return 0;
}
$bulk = '';
foreach($primaryKeys as $pk) {
foreach ($primaryKeys as $pk) {
$bulk .= Json::encode([
"delete" => [
"_id" => $pk,
......@@ -558,7 +558,7 @@ class ActiveRecord extends BaseActiveRecord
$response = static::getDb()->post($url, [], $bulk);
$n=0;
$errors = [];
foreach($response['items'] as $item) {
foreach ($response['items'] as $item) {
if (isset($item['delete']['error'])) {
$errors[] = $item['delete'];
} elseif ($item['delete']['found'] && $item['delete']['ok']) {
......
......@@ -400,4 +400,4 @@ class Command extends Component
{
return $this->db->get(['_template', $name]);
}
}
\ No newline at end of file
}
......@@ -63,7 +63,7 @@ class Connection extends Component
public function init()
{
foreach($this->nodes as $node) {
foreach ($this->nodes as $node) {
if (!isset($node['http_address'])) {
throw new InvalidConfigException('Elasticsearch node needs at least a http_address configured.');
}
......@@ -210,7 +210,7 @@ class Connection extends Component
private function createUrl($path, $options = [])
{
if (!is_string($path)) {
$url = implode('/', array_map(function($a) {
$url = implode('/', array_map(function ($a) {
return urlencode(is_array($a) ? implode(',', $a) : $a);
}, $path));
if (!empty($options)) {
......@@ -240,12 +240,12 @@ class Connection extends Component
// http://www.php.net/manual/en/function.curl-setopt.php#82418
CURLOPT_HTTPHEADER => ['Expect:'],
CURLOPT_WRITEFUNCTION => function($curl, $data) use (&$body) {
CURLOPT_WRITEFUNCTION => function ($curl, $data) use (&$body) {
$body .= $data;
return mb_strlen($data, '8bit');
},
CURLOPT_HEADERFUNCTION => function($curl, $data) use (&$headers) {
foreach(explode("\r\n", $data) as $row) {
CURLOPT_HEADERFUNCTION => function ($curl, $data) use (&$headers) {
foreach (explode("\r\n", $data) as $row) {
if (($pos = strpos($row, ':')) !== false) {
$headers[strtolower(substr($row, 0, $pos))] = trim(substr($row, $pos + 1));
}
......@@ -355,4 +355,4 @@ class Connection extends Component
{
return $this->get(['_cluster', 'state']);
}
}
\ No newline at end of file
}
......@@ -22,4 +22,4 @@ class Exception extends \yii\db\Exception
{
return 'Elasticsearch Database Exception';
}
}
\ No newline at end of file
}
......@@ -501,4 +501,4 @@ class Query extends Component implements QueryInterface
$this->timeout = $timeout;
return $this;
}
}
\ No newline at end of file
}
......@@ -177,7 +177,7 @@ class QueryBuilder extends \yii\base\Object
private function buildHashCondition($condition)
{
$parts = [];
foreach($condition as $attribute => $value) {
foreach ($condition as $attribute => $value) {
if ($attribute == '_id') {
if ($value == null) { // there is no null pk
$parts[] = ['script' => ['script' => '0==1']];
......
......@@ -13,7 +13,6 @@ use yii\base\InvalidConfigException;
use yii\base\Model;
use yii\web\View;
/**
* This is the base class for all generator classes.
*
......
......@@ -73,7 +73,7 @@ HTML;
}
}
// Added lines only on the right side
else if ($change['tag'] === 'insert') {
elseif ($change['tag'] === 'insert') {
foreach ($change['changed']['lines'] as $no => $line) {
$toLine = $change['changed']['offset'] + $no + 1;
$html .= <<<HTML
......@@ -86,7 +86,7 @@ HTML;
}
}
// Show deleted lines only on the left side
else if ($change['tag'] === 'delete') {
elseif ($change['tag'] === 'delete') {
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= <<<HTML
......@@ -99,7 +99,7 @@ HTML;
}
}
// Show modified lines on both sides
else if ($change['tag'] === 'replace') {
elseif ($change['tag'] === 'replace') {
foreach ($change['base']['lines'] as $no => $line) {
$fromLine = $change['base']['offset'] + $no + 1;
$html .= <<<HTML
......@@ -132,4 +132,4 @@ HTML;
HTML;
return $html;
}
}
\ No newline at end of file
}
......@@ -499,5 +499,4 @@ class Generator extends \yii\gii\Generator
return $model->attributes();
}
}
}
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -6,6 +6,7 @@
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
......
......@@ -111,7 +111,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach($models as $model) {
foreach ($models as $model) {
$model->afterFind();
}
}
......@@ -172,4 +172,4 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
return $db->getCollection($this->from);
}
}
\ No newline at end of file
}
......@@ -348,4 +348,4 @@ abstract class ActiveRecord extends BaseActiveRecord
}
return $this->collectionName() === $record->collectionName() && (string)$this->getPrimaryKey() === (string)$record->getPrimaryKey();
}
}
\ No newline at end of file
}
......@@ -199,4 +199,4 @@ class Cache extends \yii\caching\Cache
]);
}
}
}
\ No newline at end of file
}
......@@ -626,7 +626,8 @@ class Collection extends Object
* @return array the highest scoring documents, in descending order by score.
* @throws Exception on failure.
*/
public function fullTextSearch($search, $condition = [], $fields = [], $options = []) {
public function fullTextSearch($search, $condition = [], $fields = [], $options = [])
{
$command = [
'search' => $search
];
......@@ -931,4 +932,4 @@ class Collection extends Object
}
return [$column => $value];
}
}
\ No newline at end of file
}
......@@ -269,4 +269,4 @@ class Connection extends Component
{
$this->trigger(self::EVENT_AFTER_OPEN);
}
}
\ No newline at end of file
}
......@@ -170,4 +170,4 @@ class Database extends Object
throw new Exception('Unknown error, use "w=1" option to enable error tracking');
}
}
}
\ No newline at end of file
}
......@@ -22,4 +22,4 @@ class Exception extends \yii\base\Exception
{
return 'MongoDB Exception';
}
}
\ No newline at end of file
}
......@@ -343,4 +343,4 @@ class Query extends Component implements QueryInterface
return $result;
}
}
}
\ No newline at end of file
}
......@@ -187,4 +187,4 @@ class Session extends \yii\web\Session
->remove(['expire' => ['$lt' => time()]]);
return true;
}
}
\ No newline at end of file
}
......@@ -56,7 +56,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach($models as $model) {
foreach ($models as $model) {
$model->afterFind();
}
}
......@@ -117,4 +117,4 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
return $db->getFileCollection($this->from);
}
}
\ No newline at end of file
}
......@@ -182,4 +182,4 @@ class Collection extends \yii\mongodb\Collection
throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
}
\ No newline at end of file
}
......@@ -72,4 +72,4 @@ class Query extends \yii\mongodb\Query
}
return $result;
}
}
\ No newline at end of file
}
......@@ -87,10 +87,10 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
// TODO add support for orderBy
$data = $this->executeScript($db, 'All');
$rows = [];
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$row = [];
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
$row[$dataRow[$i++]] = $dataRow[$i++];
}
$rows[] = $row;
......@@ -101,7 +101,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
$this->findWith($this->with, $models);
}
if (!$this->asArray) {
foreach($models as $model) {
foreach ($models as $model) {
$model->afterFind();
}
}
......@@ -128,7 +128,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
}
$row = [];
$c = count($data);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
$row[$data[$i++]] = $data[$i++];
}
if ($this->asArray) {
......@@ -336,7 +336,7 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
if (count($this->where) == 1) {
$pks = (array) reset($this->where);
} else {
foreach($this->where as $values) {
foreach ($this->where as $values) {
if (is_array($values)) {
// TODO support composite IN for composite PK
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
}
$i = 0;
$data = [];
foreach($pks as $pk) {
foreach ($pks as $pk) {
if (++$i > $start && ($limit === null || $i <= $start + $limit)) {
$key = $modelClass::keyPrefix() . ':a:' . $modelClass::buildKey($pk);
$result = $db->executeCommand('HGETALL', [$key]);
......@@ -380,10 +380,10 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return count($data);
case 'Column':
$column = [];
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$row = [];
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
$row[$dataRow[$i++]] = $dataRow[$i++];
}
$column[] = $row[$columnName];
......@@ -391,9 +391,9 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $column;
case 'Sum':
$sum = 0;
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
if ($dataRow[$i++] == $columnName) {
$sum += $dataRow[$i];
break;
......@@ -404,10 +404,10 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
case 'Average':
$sum = 0;
$count = 0;
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$count++;
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
if ($dataRow[$i++] == $columnName) {
$sum += $dataRow[$i];
break;
......@@ -417,9 +417,9 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $sum / $count;
case 'Min':
$min = null;
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
if ($dataRow[$i++] == $columnName && ($min == null || $dataRow[$i] < $min)) {
$min = $dataRow[$i];
break;
......@@ -429,9 +429,9 @@ class ActiveQuery extends \yii\base\Component implements ActiveQueryInterface
return $min;
case 'Max':
$max = null;
foreach($data as $dataRow) {
foreach ($data as $dataRow) {
$c = count($dataRow);
for($i = 0; $i < $c; ) {
for ($i = 0; $i < $c;) {
if ($dataRow[$i++] == $columnName && ($max == null || $dataRow[$i] > $max)) {
$max = $dataRow[$i];
break;
......
......@@ -139,7 +139,7 @@ class ActiveRecord extends BaseActiveRecord
$key = static::keyPrefix() . ':a:' . static::buildKey($pk);
// save attributes
$args = [$key];
foreach($values as $attribute => $value) {
foreach ($values as $attribute => $value) {
$args[] = $attribute;
$args[] = $value;
}
......@@ -172,13 +172,13 @@ class ActiveRecord extends BaseActiveRecord
}
$db = static::getDb();
$n=0;
foreach(static::fetchPks($condition) as $pk) {
foreach (static::fetchPks($condition) as $pk) {
$newPk = $pk;
$pk = static::buildKey($pk);
$key = static::keyPrefix() . ':a:' . $pk;
// save attributes
$args = [$key];
foreach($attributes as $attribute => $value) {
foreach ($attributes as $attribute => $value) {
if (isset($newPk[$attribute])) {
$newPk[$attribute] = $value;
}
......@@ -224,9 +224,9 @@ class ActiveRecord extends BaseActiveRecord
}
$db = static::getDb();
$n=0;
foreach(static::fetchPks($condition) as $pk) {
foreach (static::fetchPks($condition) as $pk) {
$key = static::keyPrefix() . ':a:' . static::buildKey($pk);
foreach($counters as $attribute => $value) {
foreach ($counters as $attribute => $value) {
$db->executeCommand('HINCRBY', [$key, $attribute, $value]);
}
$n++;
......@@ -254,7 +254,7 @@ class ActiveRecord extends BaseActiveRecord
$attributeKeys = [];
$pks = static::fetchPks($condition);
$db->executeCommand('MULTI');
foreach($pks as $pk) {
foreach ($pks as $pk) {
$pk = static::buildKey($pk);
$db->executeCommand('LREM', [static::keyPrefix(), 0, $pk]);
$attributeKeys[] = static::keyPrefix() . ':a:' . $pk;
......@@ -276,9 +276,9 @@ class ActiveRecord extends BaseActiveRecord
$primaryKey = static::primaryKey();
$pks = [];
foreach($records as $record) {
foreach ($records as $record) {
$pk = [];
foreach($primaryKey as $key) {
foreach ($primaryKey as $key) {
$pk[$key] = $record[$key];
}
$pks[] = $pk;
......@@ -304,7 +304,7 @@ class ActiveRecord extends BaseActiveRecord
}
ksort($key); // ensure order is always the same
$isNumeric = true;
foreach($key as $value) {
foreach ($key as $value) {
if (!is_numeric($value)) {
$isNumeric = false;
}
......
......@@ -78,7 +78,7 @@ class Cache extends \yii\caching\Cache
parent::init();
if (is_string($this->redis)) {
$this->redis = Yii::$app->getComponent($this->redis);
} else if (is_array($this->redis)) {
} elseif (is_array($this->redis)) {
if (!isset($this->redis['class'])) {
$this->redis['class'] = Connection::className();
}
......@@ -145,7 +145,7 @@ class Cache extends \yii\caching\Cache
protected function setValues($data, $expire)
{
$args = [];
foreach($data as $key => $value) {
foreach ($data as $key => $value) {
$args[] = $key;
$args[] = $value;
}
......@@ -164,7 +164,7 @@ class Cache extends \yii\caching\Cache
}
$result = $this->redis->executeCommand('EXEC');
array_shift($result);
foreach($result as $i => $r) {
foreach ($result as $i => $r) {
if ($r != 1) {
$failedKeys[] = $index[$i];
}
......
......@@ -254,7 +254,7 @@ class Connection extends Component
);
if ($this->_socket) {
if ($this->dataTimeout !== null) {
stream_set_timeout($this->_socket, $timeout=(int)$this->dataTimeout, (int) (($this->dataTimeout - $timeout) * 1000000));
stream_set_timeout($this->_socket, $timeout = (int)$this->dataTimeout, (int) (($this->dataTimeout - $timeout) * 1000000));
}
if ($this->password !== null) {
$this->executeCommand('AUTH', [$this->password]);
......@@ -345,13 +345,13 @@ class Connection extends Component
* for details on the mentioned reply types.
* @trows Exception for commands that return [error reply](http://redis.io/topics/protocol#error-reply).
*/
public function executeCommand($name, $params=[])
public function executeCommand($name, $params = [])
{
$this->open();
array_unshift($params, $name);
$command = '*' . count($params) . "\r\n";
foreach($params as $arg) {
foreach ($params as $arg) {
$command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
}
......
......@@ -133,6 +133,7 @@ class LuaScriptBuilder extends \yii\base\Object
* @param ActiveQuery $query the query used to build the script
* @param string $buildResult the lua script for building the result
* @param string $return the lua variable that should be returned
* @throws yii\base\NotSupportedException when query contains unsupported order by condition
* @return string
*/
private function build($query, $buildResult, $return)
......@@ -155,7 +156,7 @@ class LuaScriptBuilder extends \yii\base\Object
$modelClass = $query->modelClass;
$key = $this->quoteValue($modelClass::keyPrefix());
$loadColumnValues = '';
foreach($columns as $column => $alias) {
foreach ($columns as $column => $alias) {
$loadColumnValues .= "local $alias=redis.call('HGET',$key .. ':a:' .. pk, '$column')\n";
}
......
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