Merge pull request #3197 from danielkesselberg/master

Code Style #2
This commit is contained in:
Lucas Bartholemy 2018-07-05 10:38:20 +02:00 committed by GitHub
commit bea8d5a785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
72 changed files with 38 additions and 126 deletions

View File

@ -111,7 +111,6 @@ class CronController extends Controller
$lastRun = (int)Yii::$app->settings->getUncached('cronLastDailyRun');
if (!empty($lastRun) && $force !== true) {
$lastTime = new DateTime('@' . $lastRun);
$todayTime = DateTime::createFromFormat(
'Y-m-d H:i',

View File

@ -36,11 +36,11 @@ class IntegrityController extends Controller
{
$this->stdout("\n*** Performing database integrity checks\n\n", Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_RUN);
$this->trigger(self::EVENT_ON_RUN);
$this->stdout("\n*** All integrity checks done\n\n", Console::FG_YELLOW);
return self::EXIT_CODE_NORMAL;
return self::EXIT_CODE_NORMAL;
}
/**
@ -82,5 +82,4 @@ class IntegrityController extends Controller
$this->stdout("\tWarning: ", Console::FG_RED);
$this->stdout($message . "\n", Console::FG_GREY);
}
}

View File

@ -188,5 +188,4 @@ class MessageController extends \yii\console\controllers\MessageController
print "Saved!\n";
}
}
}

View File

@ -149,7 +149,6 @@ class MigrateController extends \yii\console\controllers\MigrateController
{
$migrationPaths = ['base' => $this->migrationPath];
foreach (Yii::$app->getModules() as $id => $config) {
$class = null;
if (is_array($config) && isset($config['class'])) {
$class = $config['class'];
@ -229,5 +228,4 @@ class MigrateController extends \yii\console\controllers\MigrateController
return parent::stderr($string);
}
}
}

View File

@ -35,5 +35,4 @@ class TestController extends \yii\console\Controller
Console::output("Message successfully sent!");
}
}

View File

@ -15,7 +15,6 @@ namespace humhub\compat;
*/
class CActiveForm extends \yii\widgets\ActiveForm
{
public function label($model, $attribute, $htmlOptions = array())
{
return CHtml::activeLabel($model, $attribute, $htmlOptions);
@ -92,5 +91,4 @@ class CActiveForm extends \yii\widgets\ActiveForm
return CHtml::activeHiddenInput($model, $attribute, $htmlOptions);
}
}

View File

@ -19,7 +19,6 @@ use Yii;
*/
class HForm extends \yii\base\Component
{
const EVENT_BEFORE_VALIDATE = 'beforeValidate';
const EVENT_AFTER_VALIDATE = 'afterValidate';
@ -56,7 +55,6 @@ class HForm extends \yii\base\Component
public function submitted($buttonName = "")
{
if (Yii::$app->request->method == 'POST') {
if ($buttonName == "" || isset($_POST[$buttonName])) {
foreach ($this->models as $model) {
$model->load(Yii::$app->request->post());
@ -323,5 +321,4 @@ class HForm extends \yii\base\Component
return $output;
}
}

View File

@ -151,5 +151,4 @@ class ActiveRecord extends \yii\db\ActiveRecord implements \Serializable
$this->setAttributes($unserializedArr['attributes'],false);
$this->setOldAttributes($unserializedArr['oldAttributes'],false);
}
}

View File

@ -101,5 +101,4 @@ class Application extends \yii\web\Application
parent::preInit($config);
}
}

View File

@ -74,7 +74,7 @@ class Controller extends \yii\web\Controller
*/
public function getAccess()
{
if(!$this->access) {
if (!$this->access) {
return null;
}
@ -283,5 +283,4 @@ class Controller extends \yii\web\Controller
\humhub\widgets\TopMenu::setViewState();
}
}
}

View File

@ -22,5 +22,4 @@ class Event extends \yii\base\Event
* Note that this varies according to which event is currently executing.
*/
public $result;
}

View File

@ -88,5 +88,4 @@ class Migration extends \yii\db\Migration
{
$this->db->createCommand()->insert($table, $columns)->execute();
}
}

View File

@ -175,7 +175,7 @@ class Module extends \yii\base\Module
/** @var $assetBundle AssetBundle */
/** @var $manager AssetManager */
if($all) {
if ($all) {
foreach ($this->getAssetClasses() as $assetClass) {
$assetBundle = new $assetClass();
$manager = Yii::$app->getAssetManager();
@ -392,7 +392,7 @@ class Module extends \yii\base\Module
if (is_dir($activityDirectory)) {
foreach (FileHelper::findFiles($activityDirectory, ['recursive' => false,]) as $file) {
$activityClass = $activityNamespace . '\\' . basename($file, '.php');
if(is_subclass_of($activityClass, BaseActivity::class)) {
if (is_subclass_of($activityClass, BaseActivity::class)) {
$activities[] = $activityClass;
}
}
@ -421,7 +421,7 @@ class Module extends \yii\base\Module
if (is_dir($assetDirectory)) {
foreach (FileHelper::findFiles($assetDirectory, ['recursive' => false,]) as $file) {
$assetClass = $assetNamespace . '\\' . basename($file, '.php');
if(is_subclass_of($assetClass, AssetBundle::class)) {
if (is_subclass_of($assetClass, AssetBundle::class)) {
$assets[] = $assetClass;
}
}
@ -429,5 +429,4 @@ class Module extends \yii\base\Module
return $assets;
}
}

View File

@ -21,7 +21,7 @@ class ModuleEvent extends \yii\base\Event
public function init()
{
parent::init();
if($this->module) {
if ($this->module) {
$this->moduleId = $this->module->id;
}
}
@ -31,11 +31,10 @@ class ModuleEvent extends \yii\base\Event
*/
public function getModule()
{
if(!$this->module && $this->moduleId) {
if (!$this->module && $this->moduleId) {
$this->module = Yii::$app->moduleManager->getModule($this->moduleId);
}
return $this->module;
}
}

View File

@ -400,5 +400,4 @@ class ModuleManager extends Component
}
}
}
}

View File

@ -35,5 +35,4 @@ class Request extends \yii\web\Request
$this->cookieValidationKey = 'installer';
}
}
}

View File

@ -33,5 +33,4 @@ class Response extends \yii\web\Response
return parent::xSendFile($filePath, $attachmentName, $options);
}
}

View File

@ -113,6 +113,4 @@ class SettingsManager extends BaseSettingsManager
return parent::get($name, $default);
}
}

View File

@ -315,14 +315,13 @@ abstract class SocialActivity extends \yii\base\BaseObject implements rendering\
$truncatedDescription = $this->getContentPreview($content, 60);
if(empty($truncatedDescription)) {
if (empty($truncatedDescription)) {
return null;
}
$trimmed = Helpers::trimText($truncatedDescription, 60);
return ($withContentName) ? Html::encode($content->getContentName()). ' "' . $trimmed . '"' : $trimmed;
}
/**
@ -393,5 +392,4 @@ abstract class SocialActivity extends \yii\base\BaseObject implements rendering\
$this->from($unserializedArr['originator']);
$this->about($unserializedArr['source']);
}
}

View File

@ -38,5 +38,4 @@ class UrlManager extends \yii\web\UrlManager
return parent::createUrl($params);
}
}

View File

@ -41,8 +41,8 @@ class Widget extends \yii\base\Widget
$config['class'] = get_called_class();
}
if(isset($config['render']) && $config['render'] === false) {
return '';
if (isset($config['render']) && $config['render'] === false) {
return '';
}
\yii\base\Event::trigger(self::className(), self::EVENT_CREATE, new WidgetCreateEvent($config));

View File

@ -39,7 +39,7 @@ abstract class ActionAccessValidator extends AccessValidator
{
$rules = $this->filterRelatedRules();
if(empty($rules)) {
if (empty($rules)) {
return true;
}

View File

@ -11,7 +11,6 @@ use Yii;
class GuestAccessValidator extends AccessValidator
{
public $name = 'guestAccess';
public $code = 403;

View File

@ -29,5 +29,4 @@ class StrictAccess extends ControllerAccess
$fixed[] = [self::RULE_STRICT];
return $fixed;
}
}

View File

@ -139,7 +139,7 @@ class AccessControl extends ActionFilter
if (empty(Yii::$app->params['installed']) &&
Yii::$app->controller->module != null &&
Yii::$app->controller->module->id == 'installer') {
return true;
return true;
}
$this->handleDeprecatedSettings();

View File

@ -20,7 +20,6 @@ use yii\base\Behavior;
*/
class GUID extends Behavior
{
public function events()
{
return [
@ -30,12 +29,12 @@ class GUID extends Behavior
];
}
public function setGuid($event) {
public function setGuid($event)
{
if ($this->owner->isNewRecord) {
if ($this->owner->guid == "") {
$this->owner->guid = \humhub\libs\UUID::v4();
}
}
}
}

View File

@ -47,7 +47,6 @@ class PolymorphicRelation extends Behavior
*/
public function getPolymorphicRelation()
{
if ($this->_cached !== null) {
return $this->_cached;
}
@ -64,7 +63,7 @@ class PolymorphicRelation extends Behavior
return null;
}
if(!method_exists($className, 'tableName')) {
if (!method_exists($className, 'tableName')) {
// Avoids failures when running integrity checks etc.
return null;
}
@ -77,7 +76,7 @@ class PolymorphicRelation extends Behavior
$this->_cached = $object;
return $object;
}
} catch(\Exception $e) {
} catch (\Exception $e) {
// Avoid failures when running integrity checks etc.
Yii::error($e);
}
@ -99,8 +98,6 @@ class PolymorphicRelation extends Behavior
$this->owner->setAttribute($this->pkAttribute, $object->getPrimaryKey());
}
}
}
/**
@ -133,5 +130,4 @@ class PolymorphicRelation extends Behavior
return false;
}
}

View File

@ -28,5 +28,4 @@ class LanguageSelector implements BootstrapInterface
$app->i18n->autosetLocale();
}
}

View File

@ -18,7 +18,6 @@ use yii\base\BootstrapInterface;
*/
class ModuleAutoLoader implements BootstrapInterface
{
const CACHE_ID = 'module_configs';
public function bootstrap($app)
@ -30,8 +29,9 @@ class ModuleAutoLoader implements BootstrapInterface
foreach (Yii::$app->params['moduleAutoloadPaths'] as $modulePath) {
$modulePath = Yii::getAlias($modulePath);
foreach (scandir($modulePath) as $moduleId) {
if ($moduleId == '.' || $moduleId == '..')
if ($moduleId == '.' || $moduleId == '..') {
continue;
}
$moduleDir = $modulePath . DIRECTORY_SEPARATOR . $moduleId;
if (is_dir($moduleDir) && is_file($moduleDir . DIRECTORY_SEPARATOR . 'config.php')) {
@ -50,5 +50,4 @@ class ModuleAutoLoader implements BootstrapInterface
Yii::$app->moduleManager->registerBulk($modules);
}
}

View File

@ -37,7 +37,6 @@ class Application extends \yii\console\Application
if (BaseSettingsManager::isDatabaseInstalled()) {
$baseUrl = Yii::$app->settings->get('baseUrl');
if (!empty($baseUrl)) {
if (Yii::getAlias('@web', false) === false) {
Yii::setAlias('@web', $baseUrl);
}

View File

@ -142,5 +142,4 @@ class ExportResult extends BaseObject
return $response->sendFile($this->getTempFileName(), $this->getResultFileName(), $options);
}
}

View File

@ -50,8 +50,9 @@ class Formatter extends \yii\i18n\Formatter
* @param null $locale
* @return null|string
*/
public function getDateTimePattern($dateType = IntlDateFormatter::SHORT, $timeType = IntlDateFormatter::SHORT, $locale = null) {
if(extension_loaded('intl')) {
public function getDateTimePattern($dateType = IntlDateFormatter::SHORT, $timeType = IntlDateFormatter::SHORT, $locale = null)
{
if (extension_loaded('intl')) {
$locale = empty($locale) ? $this->locale : $locale;
$formatter = new IntlDateFormatter($locale, $dateType, $timeType, $this->timeZone, $this->calendar);
return $formatter->getPattern();
@ -68,12 +69,12 @@ class Formatter extends \yii\i18n\Formatter
* @param null $locale
* @return bool if the locale uses a 12 hour (AM/PM) otherwise a 24 hour time format is used.
*/
public function isShowMeridiem($locale = null) {
if(extension_loaded('intl')) {
public function isShowMeridiem($locale = null)
{
if (extension_loaded('intl')) {
$pattern = $this->getDateTimePattern(IntlDateFormatter::NONE, IntlDateFormatter::SHORT);
return strpos($pattern, 'a') !== false;
}
return false;
}
}

View File

@ -110,7 +110,7 @@ class I18N extends \yii\i18n\I18N
*/
protected function setLocale($locale)
{
if(!empty($locale)) {
if (!empty($locale)) {
Yii::$app->language = $locale;
Yii::$app->formatter->locale = $locale;
}
@ -252,5 +252,4 @@ class I18N extends \yii\i18n\I18N
$this->setLocale('en-US');
}
}
}

View File

@ -15,7 +15,6 @@ use Yii;
*/
class MessageSource extends \yii\i18n\PhpMessageSource
{
public $sourceCategory = '';
protected function getMessageFilePath($category, $language)
@ -63,7 +62,6 @@ class MessageSource extends \yii\i18n\PhpMessageSource
$fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile);
if ($messages === null && $fallbackMessages === null && $fallbackLanguage != $this->sourceLanguage) {
} elseif (empty($messages)) {
return $fallbackMessages;
} elseif (!empty($fallbackMessages)) {
@ -77,5 +75,4 @@ class MessageSource extends \yii\i18n\PhpMessageSource
return (array) $messages;
}
}

View File

@ -106,6 +106,4 @@ class Mailer extends \yii\swiftmailer\Mailer
return false;
}
}

View File

@ -16,5 +16,4 @@ namespace humhub\components\mail;
*/
class Message extends \yii\swiftmailer\Message
{
}

View File

@ -18,5 +18,4 @@ namespace humhub\components\queue;
*/
abstract class ActiveJob extends \humhub\modules\queue\ActiveJob
{
}

View File

@ -49,7 +49,7 @@ class LayoutRenderer extends ViewPathRenderer
$viewParams = $viewable->getViewParams($params);
// Render the viewFile
if(!isset($viewParams['content'])) {
if (!isset($viewParams['content'])) {
$viewParams['content'] = parent::renderView($viewable, $viewParams);
}
@ -74,5 +74,4 @@ class LayoutRenderer extends ViewPathRenderer
{
return $this->layout;
}
}

View File

@ -16,7 +16,6 @@ namespace humhub\components\rendering;
*/
class MailLayoutRenderer extends LayoutRenderer
{
public $subPath = 'mails';
/**
@ -55,5 +54,4 @@ class MailLayoutRenderer extends LayoutRenderer
{
return $this->textLayout;
}
}

View File

@ -35,5 +35,4 @@ interface Renderer
* @param type $params
*/
public function render(Viewable $viewable, $params = []);
}

View File

@ -145,5 +145,4 @@ class ViewPathRenderer extends \yii\base\BaseObject implements Renderer
return $dir;
}
}

View File

@ -44,5 +44,4 @@ interface Viewable
* @return string text content representation of this viewable.
*/
public function text();
}

View File

@ -18,7 +18,6 @@ use yii\validators\Validator;
*/
abstract class AbstractDateValidator extends Validator
{
public $message;
abstract public function dateValidation($timestamp);
@ -36,5 +35,4 @@ abstract class AbstractDateValidator extends Validator
$this->addError($model, $attribute, $this->message);
}
}
}

View File

@ -39,5 +39,4 @@ class PastDateValidator extends \yii\validators\DbDateValidator
$this->addError($model, $attribute, $this->message);
}
}
}

View File

@ -56,5 +56,4 @@ class ErrorController extends Controller
'message' => $message
]);
}
}

View File

@ -29,5 +29,4 @@ class HomeController extends Controller
{
return $this->redirect(Url::home());
}
}

View File

@ -40,5 +40,4 @@ class MarkdownController extends Controller
return MarkdownView::widget(['markdown' => Yii::$app->request->post('markdown')]);
}
}

View File

@ -37,12 +37,11 @@ class OembedController extends Controller
$result = [];
foreach ($urls as $url) {
$oembed = UrlOembed::GetOEmbed($url);
if($oembed) {
if ($oembed) {
$result[$url] = $oembed;
}
}
return $this->asJson($result);
}
}

View File

@ -24,5 +24,4 @@ class ActiveQueryEvent extends Event
* @var ActiveQuery the active query
*/
public $query;
}

View File

@ -44,7 +44,6 @@ class ActionColumn extends Column
*/
protected function renderDataCellContent($model, $key, $index)
{
$actions = $this->getActions($model, $key, $index);
if (empty($actions)) {
@ -102,5 +101,4 @@ class ActionColumn extends Column
return \yii\helpers\Url::to($url);
}
}

View File

@ -165,7 +165,7 @@ class BasePermission extends BaseObject
{
if (isset(Yii::$app->params['defaultPermissions'][self::className()]) &&
isset(Yii::$app->params['defaultPermissions'][self::className()][$groupId])) {
return Yii::$app->params['defaultPermissions'][self::className()][$groupId];
return Yii::$app->params['defaultPermissions'][self::className()][$groupId];
}
return null;
@ -208,5 +208,4 @@ class BasePermission extends BaseObject
throw new Exception('Invalid permission state');
}
}

View File

@ -259,5 +259,4 @@ abstract class BaseSettingsManager extends Component
return false;
}
}

View File

@ -49,5 +49,4 @@ class CURLHelper
return $options;
}
}

View File

@ -81,5 +81,4 @@ class DateTimeHelper
{
return $interval->days * 86400 + $interval->h * 3600 + $interval->i * 60 + $interval->s;
}
}

View File

@ -198,5 +198,4 @@ class DbDateValidator extends \yii\validators\DateValidator
{
return (preg_match(self::REGEX_DBFORMAT_DATE, $value) || preg_match(self::REGEX_DBFORMAT_DATETIME, $value));
}
}

View File

@ -109,5 +109,4 @@ class DropDownGridColumn extends DataColumn
return Html::dropDownList($inputName, $model[$this->attribute], $options, $this->htmlOptions);
}
}

View File

@ -181,5 +181,4 @@ class DynamicConfig extends BaseObject
{
return Yii::getAlias(Yii::$app->params['dynamicConfigFile']);
}
}

View File

@ -107,5 +107,4 @@ class Html extends \yii\bootstrap\Html
throw new InvalidParamException('Content container type not supported!');
}
}
}

View File

@ -19,7 +19,6 @@ use Yii;
*/
class Iso3166Codes
{
public static $countries = array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',

View File

@ -18,7 +18,6 @@ use Yii;
*/
class JSONResponse
{
const STATE_CONFIRM = 0;
const STATE_ERROR_APPLICATION = 1;
const STATE_ERROR_VALIDATOIN = 2;
@ -50,7 +49,7 @@ class JSONResponse
public function confirm($content)
{
if($content != null) {
if ($content != null) {
$this->content($content);
}
$this->result['status'] = self::STATE_CONFIRM;
@ -60,7 +59,7 @@ class JSONResponse
public function data($key, $value)
{
if(!is_array($this->result['data'])) {
if (!is_array($this->result['data'])) {
$this->result['data'] = [];
}
$this->result['data'][$key] = $value;
@ -73,7 +72,5 @@ class JSONResponse
Yii::$app->response->format = 'json';
return $this->result;
}
}

View File

@ -102,9 +102,8 @@ class LogoImage
public function delete()
{
$path = $this->getPath();
if(file_exists($path)) {
if (file_exists($path)) {
FileHelper::unlink($this->getPath());
}
}
}

View File

@ -14,7 +14,6 @@ use humhub\modules\file\models\File;
class Markdown extends \cebe\markdown\GithubMarkdown
{
protected function handleInternalUrls($url)
{
// Handle urls to file
@ -133,5 +132,4 @@ REGEXP;
return false;
}
}

View File

@ -16,7 +16,6 @@ namespace humhub\libs;
*/
class MarkdownPreview extends \cebe\markdown\Parser
{
protected function renderParagraph($block)
{
return $this->renderAbsy($block['content']) . "\n";
@ -131,14 +130,11 @@ REGEXP;
protected function renderLink($block)
{
return "[" . $block['url'] . "]";
}
protected function renderImage($block)
{
return "[" . $block['text'] . "]";
}
}

View File

@ -30,5 +30,4 @@ class ParameterEvent extends \yii\base\Event
$this->parameters = $parameters;
$this->init();
}
}

View File

@ -167,14 +167,13 @@ class ProfileImage
public function delete()
{
$path = $this->getPath();
if(file_exists($path)) {
if (file_exists($path)) {
FileHelper::unlink($path);
}
$prefixPath = $this->getPath('_org');
if(file_exists($prefixPath)) {
if (file_exists($prefixPath)) {
FileHelper::unlink($prefixPath);
}
}
}

View File

@ -371,5 +371,4 @@ class SelfTest
return $checks;
}
}

View File

@ -13,7 +13,7 @@ class Sort
{
public static function sort(&$arr, $field = 'sortOrder')
{
usort($arr, function($a, $b) use($field) {
usort($arr, function($a, $b) use ($field) {
$sortA = (isset($a[$field])) ? $a[$field] : PHP_INT_MAX;
$sortB = (isset($b[$field])) ? $b[$field] : PHP_INT_MAX;
@ -28,5 +28,4 @@ class Sort
return $arr;
}
}

View File

@ -27,8 +27,9 @@ class StringHelper extends \yii\helpers\StringHelper
{
$hex_guid = bin2hex($object_guid);
if ($hex_guid == "")
if ($hex_guid == "") {
return "";
}
$hex_guid_to_guid_str = '';
for ($k = 1; $k <= 4; ++$k) {
@ -47,5 +48,4 @@ class StringHelper extends \yii\helpers\StringHelper
return strtolower($hex_guid_to_guid_str);
}
}

View File

@ -19,6 +19,4 @@ namespace humhub\libs;
*/
class ThemeHelper extends \humhub\modules\ui\view\helpers\ThemeHelper
{
}

View File

@ -42,7 +42,7 @@ class TimezoneHelper
DateTimeZone::PACIFIC,
];
if($includeUTC) {
if ($includeUTC) {
$regions[] = DateTimeZone::UTC;
}
@ -80,5 +80,4 @@ class TimezoneHelper
return $timezone_list;
}
}

View File

@ -53,5 +53,4 @@ class UUID
{
return preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?' . '[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/i', $uuid) === 1;
}
}

View File

@ -32,5 +32,4 @@ class WidgetCreateEvent extends Event
$this->config = &$attributes;
$this->init();
}
}