Code quality clean up (#4449)

Credit to @bennothommo
This commit is contained in:
Ben Thomson 2019-07-18 22:50:37 +08:00 committed by Luke Towers
parent cc7d595fff
commit a59d3b83eb
134 changed files with 307 additions and 306 deletions

View File

@ -69,6 +69,8 @@ Please ensure that your Pull Request satisfies the following coding standards:
- [PSR 1 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md)
- [PSR 0 Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)
To validate your changes against our coding standards, you may run `./vendor/bin/phpcs -nq --extensions="php"` in your development folder.
#### Team rules
The October team follows the [developer guidelines](https://octobercms.com/docs/help/developer-guide) as much as possible.

View File

@ -159,7 +159,9 @@ class FormController extends ControllerBehavior
$this->formWidget->bindEvent('form.beforeRefresh', function ($holder) {
$result = $this->controller->formExtendRefreshData($this->formWidget, $holder->data);
if (is_array($result)) $holder->data = $result;
if (is_array($result)) {
$holder->data = $result;
}
});
$this->formWidget->bindEvent('form.refreshFields', function ($fields) {

View File

@ -886,7 +886,6 @@ class RelationController extends ControllerBehavior
* Form
*/
elseif ($this->manageMode == 'form') {
if (!$config = $this->makeConfigForMode('manage', 'form', false)) {
return null;
}
@ -1205,7 +1204,6 @@ class RelationController extends ControllerBehavior
* Add
*/
if ($this->viewMode == 'multi') {
$checkedIds = $recordId ? [$recordId] : post('checked');
if (is_array($checkedIds)) {
@ -1221,14 +1219,12 @@ class RelationController extends ControllerBehavior
$this->relationObject->add($model, $sessionKey);
}
}
}
/*
* Link
*/
elseif ($this->viewMode == 'single') {
if ($recordId && ($model = $this->relationModel->find($recordId))) {
$this->relationObject->add($model, $sessionKey);
$this->viewWidget->setFormValues($model->attributes);
@ -1242,7 +1238,6 @@ class RelationController extends ControllerBehavior
$parentModel->save();
}
}
}
}
@ -1264,7 +1259,6 @@ class RelationController extends ControllerBehavior
* Remove
*/
if ($this->viewMode == 'multi') {
$checkedIds = $recordId ? [$recordId] : post('checked');
if (is_array($checkedIds)) {
@ -1707,7 +1701,8 @@ class RelationController extends ControllerBehavior
*
* @return \Backend\Classes\WidgetBase
*/
public function relationGetManageWidget() {
public function relationGetManageWidget()
{
return $this->manageWidget;
}
@ -1716,7 +1711,8 @@ class RelationController extends ControllerBehavior
*
* @return \Backend\Classes\WidgetBase
*/
public function relationGetViewWidget() {
public function relationGetViewWidget()
{
return $this->viewWidget;
}
}

View File

@ -231,7 +231,6 @@ class Controller extends ControllerBase
* Check that user is logged in and has permission to view this page
*/
if (!$isPublicAction) {
/*
* Not logged in, redirect to login screen or show ajax error.
*/

View File

@ -688,7 +688,6 @@ class FormField
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
@ -709,7 +708,6 @@ class FormField
}
$result = $result->{$key};
}
}
return $result;

View File

@ -222,7 +222,8 @@ class FormTabs implements IteratorAggregate, ArrayAccess
*/
public function getIterator()
{
return new ArrayIterator($this->suppressTabs
return new ArrayIterator(
$this->suppressTabs
? $this->getAllFields()
: $this->getFields()
);

View File

@ -149,5 +149,4 @@ abstract class FormWidgetBase extends WidgetBase
return $this->formField->getValueFromData($this->data ?: $this->model, $defaultValue);
}
}

View File

@ -124,7 +124,9 @@ class NavigationManager
*/
$orderCount = 0;
foreach ($item->sideMenu as $sideMenuItem) {
if ($sideMenuItem->order !== -1) continue;
if ($sideMenuItem->order !== -1) {
continue;
}
$sideMenuItem->order = ($orderCount += 100);
}

View File

@ -30,7 +30,8 @@ class Files extends Controller
try {
return $this->findFileObject($code)->output('inline', true);
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
return Response::make(View::make('backend::404'), 404);
}
@ -48,7 +49,8 @@ class Files extends Controller
true
);
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
return Response::make(View::make('backend::404'), 404);
}

View File

@ -51,7 +51,7 @@ class UserRoles extends Controller
/*
* Only super users can access
*/
$this->bindEvent('page.beforeDisplay', function() {
$this->bindEvent('page.beforeDisplay', function () {
if (!$this->user->isSuperUser()) {
return Response::make(View::make('backend::access_denied'), 403);
}

View File

@ -88,7 +88,8 @@ class DbBackendUserRoles extends Migration
'permissions' => $group->permissions ?? null
]);
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
$permissions[$group->id] = $group->permissions ?? null;
}
@ -130,7 +131,8 @@ class DbBackendUserRoles extends Migration
$perms = json_decode($permString, true);
$userPerms = array_merge($userPerms, $perms);
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
}
if (count($userPerms) > 0) {
@ -157,6 +159,7 @@ class DbBackendUserRoles extends Migration
'permissions' => json_encode($newPerms)
]);
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
}
}

View File

@ -215,5 +215,4 @@ class CodeEditor extends FormWidgetBase
$this->displayIndentGuides = $preferences->editor_display_indent_guides;
$this->showPrintMargin = $preferences->editor_show_print_margin;
}
}

View File

@ -192,5 +192,4 @@ class DataTable extends FormWidgetBase
return $result;
}
}

View File

@ -122,7 +122,7 @@ class DatePicker extends FormWidgetBase
if ($this->mode === 'date' && !$this->ignoreTimezone) {
$backendTimeZone = \Backend\Models\Preference::get('timezone');
$value->setTimezone($backendTimeZone);
$value->setTime(0,0,0);
$value->setTime(0, 0, 0);
$value->setTimezone(Config::get('app.timezone'));
}
$value = $value->toDateTimeString();

View File

@ -35,7 +35,8 @@ class NestedForm extends FormWidgetBase
/**
* @inheritDoc
*/
public function init() {
public function init()
{
$this->fillFromConfig([
'form',
'usePanelStyles',
@ -62,13 +63,14 @@ class NestedForm extends FormWidgetBase
/**
* @inheritdoc
*/
function render()
public function render()
{
$this->prepareVars();
return $this->makePartial('nestedform');
}
function prepareVars() {
public function prepareVars()
{
$this->formWidget->previewMode = $this->previewMode;
}
}

View File

@ -217,8 +217,8 @@ class RichEditor extends FormWidgetBase
$iterator = function ($links, $level = 0) use (&$iterator) {
$result = [];
foreach ($links as $linkUrl => $link) {
foreach ($links as $linkUrl => $link) {
/*
* Remove scheme and host from URL
*/

View File

@ -198,9 +198,10 @@ class TagList extends FormWidgetBase
protected function getSeparatorCharacter()
{
switch (strtolower($this->separator)) {
case 'comma': return ',';
case 'space': return ' ';
case 'comma':
return ',';
case 'space':
return ' ';
}
}
}

View File

@ -119,7 +119,7 @@ class Backend
'ignoreTimezone' => false,
], $options));
if(!$dateTime) {
if (!$dateTime) {
return '';
}
@ -156,5 +156,4 @@ class Backend
return '<time'.Html::attributes($attributes).'>'.e($defaultValue).'</time>'.PHP_EOL;
}
}

View File

@ -181,5 +181,4 @@ class BrandSetting extends Model
return null;
}
}

View File

@ -174,7 +174,9 @@ abstract class ImportModel extends Model
*/
protected function decodeArrayValue($value, $delimeter = '|')
{
if (strpos($value, $delimeter) === false) return [$value];
if (strpos($value, $delimeter) === false) {
return [$value];
}
$data = preg_split('~(?<!\\\)' . preg_quote($delimeter, '~') . '~', $value);
$newData = [];

View File

@ -275,7 +275,6 @@ class Preference extends Model
// Iterate through the themes
foreach ($themeDir as $node) {
// If this file is a theme (starting by "theme-")
if (!$node->isDir() && substr($node->getFileName(), 0, 6) == 'theme-') {
// Remove the theme- prefix and the .js suffix, create an user friendly and capitalized name
@ -287,7 +286,6 @@ class Preference extends Model
$themes[$themeId] = $themeName;
}
}
}
// Sort the theme alphabetically, and push the default theme

View File

@ -98,5 +98,4 @@ trait FormModelWidget
list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom);
return $model->getRelationType($attribute);
}
}

View File

@ -408,7 +408,6 @@ class Form extends WidgetBase
* If an array of fields is supplied, update specified fields individually.
*/
if (($updateFields = post('fields')) && is_array($updateFields)) {
foreach ($updateFields as $field) {
if (!isset($this->allFields[$field])) {
continue;
@ -686,7 +685,6 @@ class Form extends WidgetBase
public function addFields(array $fields, $addToArea = null)
{
foreach ($fields as $name => $config) {
$fieldObj = $this->makeFormField($name, $config);
$fieldTab = is_array($config) ? array_get($config, 'tab') : null;
@ -875,8 +873,8 @@ class Form extends WidgetBase
* Get field options from model
*/
$optionModelTypes = ['dropdown', 'radio', 'checkboxlist', 'balloon-selector'];
if (in_array($field->type, $optionModelTypes, false)) {
if (in_array($field->type, $optionModelTypes, false)) {
/*
* Defer the execution of option data collection
*/
@ -961,7 +959,9 @@ class Form extends WidgetBase
if (isset($field->config['options'])) {
$field->options(function () use ($field) {
$fieldOptions = $field->config['options'];
if ($fieldOptions === true) $fieldOptions = null;
if ($fieldOptions === true) {
$fieldOptions = null;
}
$fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
return $fieldOptions;
});
@ -1092,7 +1092,8 @@ class Form extends WidgetBase
* Checks if default values should be taken from data.
* This should be done when model exists or when explicitly configured
*/
protected function shouldFetchDefaultValues() {
protected function shouldFetchDefaultValues()
{
$enableDefaults = object_get($this->config, 'enableDefaults');
if ($enableDefaults === false) {
return false;
@ -1171,7 +1172,6 @@ class Form extends WidgetBase
*/
$parts = HtmlHelper::nameToArray($field->fieldName);
if (($value = $this->dataArrayGet($data, $parts)) !== null) {
/*
* Number fields should be converted to integers
*/
@ -1261,7 +1261,6 @@ class Form extends WidgetBase
* Refer to the model method or any of its behaviors
*/
if (!is_array($fieldOptions) && !$fieldOptions) {
try {
list($model, $attribute) = $field->resolveModelAttribute($this->model, $field->fieldName);
}

View File

@ -1091,10 +1091,14 @@ class MediaManager extends WidgetBase
}
switch ($itemType) {
case MediaLibraryItem::FILE_TYPE_IMAGE: return "icon-picture-o";
case MediaLibraryItem::FILE_TYPE_VIDEO: return "icon-video-camera";
case MediaLibraryItem::FILE_TYPE_AUDIO: return "icon-volume-up";
default: return "icon-file";
case MediaLibraryItem::FILE_TYPE_IMAGE:
return "icon-picture-o";
case MediaLibraryItem::FILE_TYPE_VIDEO:
return "icon-video-camera";
case MediaLibraryItem::FILE_TYPE_AUDIO:
return "icon-volume-up";
default:
return "icon-file";
}
}

View File

@ -423,7 +423,6 @@ class ReportContainer extends WidgetBase
$result[] = $property;
foreach ($properties as $name => $params) {
$property = [
'property' => $name,
'title' => isset($params['title']) ? Lang::get($params['title']) : $name,

View File

@ -138,9 +138,8 @@ class Table extends WidgetBase
$isClientDataSource = $this->isClientDataSource();
$this->vars['clientDataSourceClass'] = $isClientDataSource ? 'client' : 'server';
$this->vars['data'] = json_encode($isClientDataSource
? $this->dataSource->getAllRecords()
: []
$this->vars['data'] = json_encode(
$isClientDataSource ? $this->dataSource->getAllRecords() : []
);
}
@ -168,16 +167,18 @@ class Table extends WidgetBase
{
$result = [];
foreach ($this->columns as $key=>$data) {
foreach ($this->columns as $key => $data) {
$data['key'] = $key;
if (isset($data['title']))
if (isset($data['title'])) {
$data['title'] = trans($data['title']);
}
if (isset($data['options'])) {
foreach ($data['options'] as &$option)
foreach ($data['options'] as &$option) {
$option = trans($option);
}
}
if (isset($data['validation'])) {
foreach ($data['validation'] as &$validation) {

View File

@ -58,7 +58,6 @@ class Toolbar extends WidgetBase
* Prepare the search widget (optional)
*/
if (isset($this->search)) {
if (is_string($this->search)) {
$searchConfig = $this->makeConfig(['partial' => $this->search]);
}

View File

@ -255,7 +255,9 @@ class AutoDatasource extends Datasource implements DatasourceInterface
}
// Filter out 'deleted' paths:
$paths = array_filter($paths, function ($value) { return (bool) $value; });
$paths = array_filter($paths, function ($value) {
return (bool) $value;
});
// Return just an array of paths
return array_keys($paths);

View File

@ -237,7 +237,6 @@ class CmsCompoundObject extends CmsObject
$componentName = $componentManager->resolve($componentName);
foreach ($this->settings['components'] as $sectionName => $values) {
$result = $sectionName;
if ($sectionName == $componentName) {
@ -257,7 +256,6 @@ class CmsCompoundObject extends CmsObject
if ($sectionName == $componentName) {
return $result;
}
}
return false;

View File

@ -19,11 +19,9 @@ class CmsObjectCollection extends CollectionBase
public function withComponent($components, $callback = null)
{
return $this->filter(function ($object) use ($components, $callback) {
$hasComponent = false;
foreach ((array) $components as $componentName) {
if (!$callback && $object->hasComponent($componentName)) {
$hasComponent = true;
}
@ -73,7 +71,6 @@ class CmsObjectCollection extends CollectionBase
$hasComponent = false;
foreach ((array) $components as $componentName) {
if (!$componentAlias = $object->hasComponent($componentName)) {
continue;
}
@ -101,5 +98,4 @@ class CmsObjectCollection extends CollectionBase
return $hasComponent;
});
}
}

View File

@ -306,7 +306,8 @@ abstract class ComponentBase extends Extendable
try {
return parent::__call($method, $parameters);
}
catch (BadMethodCallException $ex) {}
catch (BadMethodCallException $ex) {
}
if (method_exists($this->controller, $method)) {
return call_user_func_array([$this->controller, $method], $parameters);

View File

@ -75,8 +75,9 @@ class ComponentHelpers
}
}
if ($returnArray)
if ($returnArray) {
return $result;
}
return json_encode($result);
}

View File

@ -70,5 +70,4 @@ class Content extends CmsCompoundObject
return $result;
}
}

View File

@ -841,7 +841,6 @@ class Controller
* Process Component handler
*/
if (strpos($handler, '::')) {
list($componentName, $handlerName) = explode('::', $handler);
$componentObj = $this->findComponentByName($componentName);
@ -965,7 +964,6 @@ class Controller
* Process Component partial
*/
elseif (strpos($name, '::') !== false) {
list($componentAlias, $partialName) = explode('::', $name);
/*

View File

@ -102,5 +102,4 @@ class MediaViewHelper
break;
}
}
}

View File

@ -344,7 +344,7 @@ class Theme
$config = Yaml::parseFile($path);
} else {
$cacheKey = self::CONFIG_KEY.'::'.$this->getDirName();
$config = Cache::rememberForever($cacheKey, function() use ($path) {
$config = Cache::rememberForever($cacheKey, function () use ($path) {
return Yaml::parseFile($path);
});
}

View File

@ -2,7 +2,6 @@
interface CmsObject
{
/**
* Loads the template.
*
@ -59,5 +58,4 @@ interface CmsObject
* @return string
*/
public function getTwigCacheKey();
}

View File

@ -64,9 +64,10 @@ class ThemeLogs extends Controller
public function index_onDelete()
{
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
foreach ($checkedIds as $recordId) {
if (!$record = ThemeLog::find($recordId)) continue;
if (!$record = ThemeLog::find($recordId)) {
continue;
}
$record->delete();
}

View File

@ -49,7 +49,7 @@ class Themes extends Controller
/*
* Custom redirect for unauthorized request
*/
$this->bindEvent('page.beforeDisplay', function() {
$this->bindEvent('page.beforeDisplay', function () {
if (!$this->user->hasAccess('cms.manage_themes')) {
return Backend::redirect('cms/themeoptions/update');
}

View File

@ -77,7 +77,8 @@ class ThemeData extends Model
try {
CombineAssets::resetCache();
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
}
/**
@ -151,7 +152,6 @@ class ThemeData extends Model
*/
public function initFormFields()
{
}
/**
@ -227,7 +227,7 @@ class ThemeData extends Model
{
$theme = CmsTheme::getActiveTheme();
if (!$theme){
if (!$theme) {
return;
}

View File

@ -110,7 +110,6 @@ class ThemeExport extends Model
File::deleteDirectory($tempPath);
}
catch (Exception $ex) {
if (strlen($tempPath) && File::isDirectory($tempPath)) {
File::deleteDirectory($tempPath);
}

View File

@ -88,8 +88,7 @@ class ThemeImport extends Model
$this->theme = $theme;
$this->fill($data);
try
{
try {
$file = $this->uploaded_file()->withDeferred($sessionKey)->first();
if (!$file) {
throw new ApplicationException('There is no file attached to import!');
@ -125,7 +124,6 @@ class ThemeImport extends Model
$file->delete();
}
catch (Exception $ex) {
if (!empty($tempPath) && File::isDirectory($tempPath)) {
File::deleteDirectory($tempPath);
}

View File

@ -94,7 +94,8 @@ class ThemeLog extends Model
try {
$record->save();
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
return $record;
}

View File

@ -193,8 +193,9 @@ class Extension extends TwigExtension
return $default;
}
if ($event = Event::fire('cms.block.render', [$name, $result], true))
if ($event = Event::fire('cms.block.render', [$name, $result], true)) {
$result = $event;
}
$result = str_replace('<!-- X_OCTOBER_DEFAULT_BLOCK_CONTENT -->', trim($default), $result);
return $result;

View File

@ -39,6 +39,7 @@ class FrameworkNode extends TwigNode
.'/modules/system/assets/js/framework.combined-min.js\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
.'/modules/system/assets/js/framework.combined-min.js\" as=\"script\" importance=\"low\">'.PHP_EOL;" . PHP_EOL)
->outdent()
->write("}" . PHP_EOL)
->write("else {" . PHP_EOL)
@ -51,6 +52,7 @@ class FrameworkNode extends TwigNode
.'/modules/system/assets/js/framework.js\" as=\"script\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
->write("echo '<link rel=\"preload\" href=\"'. Request::getBasePath()
.'/modules/system/assets/js/framework.extras.js\" as=\"script\" importance=\"low\"></script>'.PHP_EOL;" . PHP_EOL)
->outdent()
->write("}" . PHP_EOL)
->write("echo '<link rel=\"stylesheet\" property=\"stylesheet\" href=\"'. Request::getBasePath()

View File

@ -1,7 +1,7 @@
<?php namespace Cms\Twig;
use Event;
use Twig\Source as TwigSource;;
use Twig\Source as TwigSource;
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
use Cms\Contracts\CmsObject;
use System\Twig\Loader as LoaderBase;

View File

@ -205,9 +205,11 @@ class ComponentList extends WidgetBase
protected function updateList()
{
return ['#'.$this->getId('component-list') => $this->makePartial('items', [
'items' => $this->getData()]
)];
return [
'#' . $this->getId('component-list') => $this->makePartial('items', [
'items' => $this->getData()
])
];
}
protected function itemMatchesSearch(&$words, $item)

View File

@ -536,7 +536,7 @@ class ServiceProvider extends ModuleServiceProvider
*/
protected function registerValidator()
{
$this->app->resolving('validator', function($validator) {
$this->app->resolving('validator', function ($validator) {
/*
* Allowed file extensions, as opposed to mime types.
* - extensions: png,jpg,txt

View File

@ -202,7 +202,7 @@ class CombineAssets
* @param string $localPath Prefix all assets with this path (optional)
* @return void
*/
public function combineToFile($assets = [], $destination, $localPath = null)
public function combineToFile($assets, $destination, $localPath = null)
{
// Disable cache always
$this->storagePath = null;
@ -212,8 +212,10 @@ class CombineAssets
if (substr($localPath, -1) !== '/') {
$localPath = $localPath.'/';
}
$assets = array_map(function($asset) use ($localPath) {
if (substr($asset, 0, 1) === '@') return $asset;
$assets = array_map(function ($asset) use ($localPath) {
if (substr($asset, 0, 1) === '@') {
return $asset;
}
return $localPath.$asset;
}, $assets);
}

View File

@ -70,7 +70,9 @@ class ComposerManager
if (file_exists($file = $dir . '/autoload_namespaces.php')) {
$map = require $file;
foreach ($map as $namespace => $path) {
if (isset($this->namespacePool[$namespace])) continue;
if (isset($this->namespacePool[$namespace])) {
continue;
}
$this->loader->set($namespace, $path);
$this->namespacePool[$namespace] = true;
}
@ -79,7 +81,9 @@ class ComposerManager
if (file_exists($file = $dir . '/autoload_psr4.php')) {
$map = require $file;
foreach ($map as $namespace => $path) {
if (isset($this->psr4Pool[$namespace])) continue;
if (isset($this->psr4Pool[$namespace])) {
continue;
}
$this->loader->setPsr4($namespace, $path);
$this->psr4Pool[$namespace] = true;
}
@ -98,7 +102,9 @@ class ComposerManager
$includeFiles = require $file;
foreach ($includeFiles as $includeFile) {
$relativeFile = $this->stripVendorDir($includeFile, $vendorPath);
if (isset($this->includeFilesPool[$relativeFile])) continue;
if (isset($this->includeFilesPool[$relativeFile])) {
continue;
}
require $includeFile;
$this->includeFilesPool[$relativeFile] = true;
}

View File

@ -192,7 +192,6 @@ class MailManager
$disableAutoInlineCss = false;
if ($template->layout) {
$disableAutoInlineCss = array_get($template->layout->options, 'disable_auto_inline_css', $disableAutoInlineCss);
$html = $this->renderTwig($template->layout->content_html, [

View File

@ -124,7 +124,6 @@ class MarkupManager
}
foreach ($definitions as $name => $definition) {
switch ($type) {
case self::EXTENSION_TOKEN_PARSER:
$this->$items[$type][] = $definition;
@ -227,7 +226,6 @@ class MarkupManager
}
foreach ($this->listFunctions() as $name => $callable) {
/*
* Handle a wildcard function
*/
@ -261,7 +259,6 @@ class MarkupManager
}
foreach ($this->listFilters() as $name => $callable) {
/*
* Handle a wildcard function
*/

View File

@ -735,8 +735,9 @@ class MediaLibrary
*/
protected function filterItemList(&$itemList, $filter)
{
if (!$filter)
if (!$filter) {
return;
}
$result = [];
foreach ($itemList as $item) {

View File

@ -50,8 +50,9 @@ class PluginBase extends ServiceProviderBase
if (!array_key_exists('plugin', $configuration)) {
throw new SystemException(sprintf(
'The plugin configuration file plugin.yaml should contain the "plugin" section: %s.', $thisClass)
);
'The plugin configuration file plugin.yaml should contain the "plugin" section: %s.',
$thisClass
));
}
return $configuration['plugin'];

View File

@ -171,7 +171,6 @@ class SettingsManager
{
$filteredItems = [];
foreach ($items as $categoryName => $category) {
$filteredCategory = [];
foreach ($category as $item) {
$itemContext = is_array($item->context) ? $item->context : [$item->context];

View File

@ -523,7 +523,6 @@ class UpdateManager
$this->versionManager->resetNotes()->setNotesOutput($this->notesOutput);
if ($this->versionManager->updatePlugin($plugin) !== false) {
foreach ($this->versionManager->getNotes() as $note) {
$this->note($note);
}
@ -680,7 +679,9 @@ class UpdateManager
$requestedDetails = array_intersect_key($this->productCache[$type], array_flip($codes));
foreach ($requestedDetails as $detail) {
if ($detail === -1) continue;
if ($detail === -1) {
continue;
}
$result[] = $detail;
}

View File

@ -130,7 +130,8 @@ class OctoberInstall extends Command
$this->writeToConfig('app', ['debug' => $debug]);
}
protected function askToInstallPlugins() {
protected function askToInstallPlugins()
{
$chosenToInstall = [];
if ($this->confirm('Install the October.Drivers plugin?', false)) {
$chosenToInstall[] = 'October.Drivers';

View File

@ -160,7 +160,7 @@ class OctoberUtil extends Command
$combiner = CombineAssets::instance();
$bundles = $combiner->getBundles($type);
if (!$bundles){
if (!$bundles) {
$this->comment('Nothing to compile!');
return;
}
@ -198,7 +198,6 @@ class OctoberUtil extends Command
$stub = base_path() . '/modules/system/assets/js/lang/lang.stub';
foreach ($locales as $locale) {
/*
* Generate messages
*/
@ -314,7 +313,10 @@ class OctoberUtil extends Command
{
foreach (File::directories(plugins_path()) as $authorDir) {
foreach (File::directories($authorDir) as $pluginDir) {
if (!File::isDirectory($pluginDir.'/.git')) continue;
if (!File::isDirectory($pluginDir.'/.git')) {
continue;
}
$exec = 'cd ' . $pluginDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating plugin: '. basename(dirname($pluginDir)) .'.'. basename($pluginDir) . PHP_EOL;
@ -323,7 +325,10 @@ class OctoberUtil extends Command
}
foreach (File::directories(themes_path()) as $themeDir) {
if (!File::isDirectory($themeDir.'/.git')) continue;
if (!File::isDirectory($themeDir.'/.git')) {
continue;
}
$exec = 'cd ' . $themeDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating theme: '. basename($themeDir) . PHP_EOL;
@ -335,7 +340,7 @@ class OctoberUtil extends Command
{
$projectId = $this->option('projectId');
if (empty($projectId)){
if (empty($projectId)) {
$this->error("No projectId defined, use --projectId=<id> to set a projectId");
return;
}
@ -348,7 +353,5 @@ class OctoberUtil extends Command
'system::project.name' => $result['name'],
'system::project.owner' => $result['owner'],
]);
}
}

View File

@ -34,7 +34,7 @@ class PluginList extends Command
$allPlugins = PluginVersion::all();
$pluginsCount = count($allPlugins);
if ($pluginsCount <= 0 ) {
if ($pluginsCount <= 0) {
$this->info('No plugin found');
return;
}

View File

@ -42,7 +42,6 @@ class ThemeList extends Command
}
if ($this->option('include-marketplace')) {
// @todo List everything in the marketplace - not just popular.
$popularThemes = $updateManager->requestPopularProducts('theme');

View File

@ -181,7 +181,7 @@ class ThemeSync extends Command
}
// Confirm with the user
if (!$this->confirmToProceed(sprintf('This will OVERWRITE the %s provided paths in "themes/%s" on the %s with content from the %s', count($validPaths), $themeName, $target, $source), function () { return true; })) {
if (!$this->confirmToProceed(sprintf('This will OVERWRITE the %s provided paths in "themes/%s" on the %s with content from the %s', count($validPaths), $themeName, $target, $source), true)) {
return;
}

View File

@ -65,9 +65,10 @@ class EventLogs extends Controller
public function index_onDelete()
{
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
foreach ($checkedIds as $recordId) {
if (!$record = EventLog::find($recordId)) continue;
if (!$record = EventLog::find($recordId)) {
continue;
}
$record->delete();
}

View File

@ -63,9 +63,10 @@ class RequestLogs extends Controller
public function index_onDelete()
{
if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
foreach ($checkedIds as $recordId) {
if (!$record = RequestLog::find($recordId)) continue;
if (!$record = RequestLog::find($recordId)) {
continue;
}
$record->delete();
}

View File

@ -189,14 +189,15 @@ class Updates extends Controller
}
//Filter out update scripts
$details = array_filter($details, function($string) use ($path) {
$details = array_filter($details, function ($string) use ($path) {
return !preg_match('/^[a-z_\-0-9]*\.php$/i', $string) || !File::exists($path . '/updates/' . $string);
});
$contents[$version] = $details;
}
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
uksort($contents, function ($a, $b) {
return version_compare($b, $a);
@ -209,7 +210,9 @@ class Updates extends Controller
{
$contents = null;
foreach ($filenames as $file) {
if (!File::exists($path . '/'.$file)) continue;
if (!File::exists($path . '/'.$file)) {
continue;
}
$contents = File::get($path . '/'.$file);
@ -369,7 +372,9 @@ class Updates extends Controller
$coreImportant = false;
foreach (array_get($result, 'core.updates', []) as $build => $description) {
if (strpos($description, '!!!') === false) continue;
if (strpos($description, '!!!') === false) {
continue;
}
$detailsUrl = '//octobercms.com/support/articles/release-notes';
$description = str_replace('!!!', '', $description);
@ -387,7 +392,9 @@ class Updates extends Controller
$isImportant = false;
foreach (array_get($plugin, 'updates', []) as $version => $description) {
if (strpos($description, '!!!') === false) continue;
if (strpos($description, '!!!') === false) {
continue;
}
$isImportant = $hasImportantUpdates = true;
$detailsUrl = Backend::url('system/updates/details/'.PluginVersion::makeSlug($code).'/upgrades').'?fetch=1';
@ -910,7 +917,6 @@ class Updates extends Controller
public function onRemoveTheme()
{
if ($themeCode = post('code')) {
ThemeManager::instance()->deleteTheme($themeCode);
Flash::success(trans('cms::lang.theme.delete_theme_success'));

View File

@ -13,7 +13,8 @@ class DbSystemMailLayoutRename extends Migration
$layout->content_text = preg_replace("/({{\s*message\s*[|]raw\s*}})/i", "{{ content|raw }}", $layout->content_text);
$layout->forceSave();
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
}
}

View File

@ -68,7 +68,8 @@ class DateTime
else {
try {
$value = Carbon::parse($value);
} catch (Exception $ex) {}
} catch (Exception $ex) {
}
}
if (!$value instanceof Carbon && $throwException) {
@ -131,5 +132,4 @@ class DateTime
return strtr($format, $replacements);
}
}

View File

@ -49,7 +49,7 @@ return [
'cancel_button_text' => 'انصراف',
'widget_remove_confirm' => 'این ابزارک حذف شود؟'
],
'datepicker' => [
'datepicker' => [
'previousMonth' => 'ماه قبل',
'nextMonth' => 'ماه بعد',
'months' => ['فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'],

View File

@ -58,7 +58,8 @@ class EventLog extends Model
try {
$record->save();
}
catch (Exception $ex) {}
catch (Exception $ex) {
}
return $record;
}

View File

@ -141,5 +141,4 @@ class MailLayout extends Model
{
return MailParser::parse(FileHelper::get(View::make($code)->getPath()));
}
}

View File

@ -88,7 +88,6 @@ class MailSetting extends Model
$config->set('mail.from.address', $settings->sender_email);
switch ($settings->send_mode) {
case self::MODE_SMTP:
$config->set('mail.host', $settings->smtp_address);
$config->set('mail.port', $settings->smtp_port);
@ -127,10 +126,8 @@ class MailSetting extends Model
$config->set('services.ses.region', $settings->ses_region);
break;
}
}
/**
* @return array smtp_encryption options values
*/

View File

@ -55,7 +55,6 @@ trait AssetMaker
if ($type == null || $type == 'css') {
foreach ($this->assets['css'] as $asset) {
/*
* Prevent duplicates
*/
@ -314,10 +313,8 @@ trait AssetMaker
protected function removeDuplicates()
{
foreach ($this->assets as $type => &$collection) {
$pathCache = [];
foreach ($collection as $key => $asset) {
if (!$path = array_get($asset, 'path')) {
continue;
}
@ -329,7 +326,6 @@ trait AssetMaker
$pathCache[$path] = true;
}
}
}

View File

@ -51,7 +51,6 @@ trait ConfigMaker
* Process config from file contents
*/
else {
if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) {
$configFile = $this->controller->getConfigPath($configFile);
}

View File

@ -2,7 +2,7 @@
use App;
use File;
use Twig\Source as TwigSource;;
use Twig\Source as TwigSource;
use Twig\Loader\LoaderInterface as TwigLoaderInterface;
use Exception;

View File

@ -19,11 +19,24 @@
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<!--
Test fixtures and cases can have multiple classes defined, only if they are directly related to the test, or are
extended classes
-->
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<file>bootstrap/</file>
<file>config/</file>
<file>modules/</file>
<file>plugins/october/demo/</file>
<file>tests/</file>
<!-- Ignore vendor files -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Ignore this view file as fixing the issues in here will break the template -->
<exclude-pattern>modules/system/views/exception.php</exclude-pattern>
<!-- Ignore this test case completely as it's testing a parse error -->
<exclude-pattern>tests/fixtures/plugins/testvendor/goto/Plugin.php</exclude-pattern>
</ruleset>

View File

@ -2,24 +2,31 @@
class UiTestCase extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
/*
* Look for selenium configuration
*/
if (file_exists($seleniumEnv = __DIR__.'/../selenium.php'))
if (file_exists($seleniumEnv = __DIR__.'/../selenium.php')) {
require_once $seleniumEnv;
}
/*
* Configure selenium
*/
if (!defined('TEST_SELENIUM_URL'))
if (!defined('TEST_SELENIUM_URL')) {
return $this->markTestSkipped('Selenium skipped');
}
if (defined('TEST_SELENIUM_HOST')) $this->setHost(TEST_SELENIUM_HOST);
if (defined('TEST_SELENIUM_PORT')) $this->setPort(TEST_SELENIUM_PORT);
if (defined('TEST_SELENIUM_BROWSER')) $this->setBrowser(TEST_SELENIUM_BROWSER);
if (defined('TEST_SELENIUM_HOST')) {
$this->setHost(TEST_SELENIUM_HOST);
}
if (defined('TEST_SELENIUM_PORT')) {
$this->setPort(TEST_SELENIUM_PORT);
}
if (defined('TEST_SELENIUM_BROWSER')) {
$this->setBrowser(TEST_SELENIUM_BROWSER);
}
$this->setBrowserUrl(TEST_SELENIUM_URL);
}
@ -60,32 +67,45 @@ class UiTestCase extends PHPUnit_Extensions_SeleniumTestCase
protected function waitForElementPresent($target, $timeout = 60)
{
for ($second = 0; ; $second++) {
if ($second >= $timeout)
$second = 0;
while (true) {
if ($second >= $timeout) {
$this->fail('timeout');
}
try {
if ($this->isElementPresent($target)) break;
if ($this->isElementPresent($target)) {
break;
}
}
catch (Exception $e) {
}
catch (Exception $e) {}
sleep(1);
++$second;
}
}
protected function waitForElementNotPresent($target, $timeout = 60)
{
for ($second = 0; ; $second++) {
if ($second >= $timeout)
$second = 0;
while (true) {
if ($second >= $timeout) {
$this->fail('timeout');
}
try {
if (!$this->isElementPresent($target)) break;
if (!$this->isElementPresent($target)) {
break;
}
}
catch (Exception $e) {
}
catch (Exception $e) {}
sleep(1);
++$second;
}
}
}

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
@ -13,5 +12,4 @@ class Plugin extends PluginBase
'author' => 'Alexey Bobkov, Samuel Georges'
];
}
}

View File

@ -27,5 +27,4 @@ class EventLog extends Model
public $morphTo = [
'related' => []
];
}

View File

@ -26,5 +26,4 @@ class Phone extends Model
public $belongsTo = [
'author' => 'Database\Tester\Models\Author',
];
}

View File

@ -68,7 +68,6 @@ class SluggablePost extends Post
'slug' => 'title',
'long_slug' => ['title', 'description']
];
}
class RevisionablePost extends Post
@ -117,7 +116,6 @@ class RevisionablePost extends Post
{
return 7;
}
}
class ValidationPost extends Post

View File

@ -7,7 +7,6 @@ use Model;
*/
class Role extends Model
{
/**
* @var string The database table used by the model.
*/
@ -32,5 +31,4 @@ class Role extends Model
'table' => 'database_tester_authors_roles'
],
];
}

View File

@ -24,7 +24,6 @@ class User extends Model
public $attachMany = [
'photos' => 'System\Models\File'
];
}
class SoftDeleteUser extends User

View File

@ -5,11 +5,9 @@ use October\Rain\Database\Updates\Migration;
class CreateAuthorsTable extends Migration
{
public function up()
{
Schema::create('database_tester_authors', function ($table)
{
Schema::create('database_tester_authors', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('user_id')->unsigned()->index()->nullable();
@ -24,5 +22,4 @@ class CreateAuthorsTable extends Migration
{
Schema::dropIfExists('database_tester_authors');
}
}

View File

@ -8,8 +8,7 @@ class CreateCategoriesTable extends Migration
public function up()
{
Schema::create('database_tester_categories', function ($table)
{
Schema::create('database_tester_categories', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('parent_id')->nullable();
@ -22,8 +21,7 @@ class CreateCategoriesTable extends Migration
$table->softDeletes();
});
Schema::create('database_tester_categories_nested', function ($table)
{
Schema::create('database_tester_categories_nested', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->integer('parent_id')->nullable();
@ -45,5 +43,4 @@ class CreateCategoriesTable extends Migration
Schema::dropIfExists('database_tester_categories');
Schema::dropIfExists('database_tester_categories_nested');
}
}

View File

@ -8,8 +8,7 @@ class CreateEventLogTable extends Migration
public function up()
{
Schema::create('database_tester_event_log', function ($table)
{
Schema::create('database_tester_event_log', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('action', 30)->nullable();
@ -24,5 +23,4 @@ class CreateEventLogTable extends Migration
{
Schema::dropIfExists('database_tester_event_log');
}
}

View File

@ -8,8 +8,7 @@ class CreateMetaTable extends Migration
public function up()
{
Schema::create('database_tester_meta', function ($table)
{
Schema::create('database_tester_meta', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id')->unsigned();
$table->integer('taggable_id')->unsigned()->index()->nullable();
@ -28,5 +27,4 @@ class CreateMetaTable extends Migration
{
Schema::dropIfExists('database_tester_meta');
}
}

View File

@ -8,8 +8,7 @@ class CreatePhonesTable extends Migration
public function up()
{
Schema::create('database_tester_phones', function ($table)
{
Schema::create('database_tester_phones', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('number')->nullable();
@ -22,5 +21,4 @@ class CreatePhonesTable extends Migration
{
Schema::dropIfExists('database_tester_phones');
}
}

View File

@ -8,8 +8,7 @@ class CreatePostsTable extends Migration
public function up()
{
Schema::create('database_tester_posts', function ($table)
{
Schema::create('database_tester_posts', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('title')->nullable();
@ -29,5 +28,4 @@ class CreatePostsTable extends Migration
{
Schema::dropIfExists('database_tester_posts');
}
}

View File

@ -8,8 +8,7 @@ class CreateRolesTable extends Migration
public function up()
{
Schema::create('database_tester_roles', function ($table)
{
Schema::create('database_tester_roles', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->nullable();
@ -17,8 +16,7 @@ class CreateRolesTable extends Migration
$table->timestamps();
});
Schema::create('database_tester_authors_roles', function ($table)
{
Schema::create('database_tester_authors_roles', function ($table) {
$table->engine = 'InnoDB';
$table->integer('author_id')->unsigned();
$table->integer('role_id')->unsigned();
@ -33,5 +31,4 @@ class CreateRolesTable extends Migration
Schema::dropIfExists('database_tester_roles');
Schema::dropIfExists('database_tester_authors_roles');
}
}

View File

@ -8,8 +8,7 @@ class CreateUsersTable extends Migration
public function up()
{
Schema::create('database_tester_users', function ($table)
{
Schema::create('database_tester_users', function ($table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->nullable();
@ -23,5 +22,4 @@ class CreateUsersTable extends Migration
{
Schema::dropIfExists('database_tester_users');
}
}

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
@ -13,5 +12,4 @@ class Plugin extends PluginBase
'author' => 'Alexey Bobkov, Samuel Georges'
];
}
}

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
@ -13,5 +12,4 @@ class Plugin extends PluginBase
'author' => 'Alexey Bobkov, Samuel Georges'
];
}
}

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
@ -62,5 +61,4 @@ class Plugin extends PluginBase
]
];
}
}

View File

@ -4,7 +4,6 @@ use Cms\Classes\ComponentBase;
class Archive extends ComponentBase
{
public function componentDetails()
{
return [
@ -39,5 +38,4 @@ class Archive extends ComponentBase
{
$this->page['var'] = 'page';
}
}

View File

@ -30,5 +30,4 @@ class Categories extends ComponentBase
{
$this->page['var'] = 'page';
}
}

View File

@ -8,7 +8,7 @@ class Comments extends ComponentBase
{
private $users;
public function __construct(CodeBase $cmsObject = null, $properties = [], Users $users)
public function __construct(CodeBase $cmsObject = null, $properties = [], Users $users = null)
{
parent::__construct($cmsObject, $properties);
$this->users = $users;
@ -39,5 +39,4 @@ class Comments extends ComponentBase
{
return $this->users;
}
}

View File

@ -4,7 +4,6 @@ use Cms\Classes\ComponentBase;
class ContentBlock extends ComponentBase
{
public function componentDetails()
{
return [
@ -21,5 +20,4 @@ class ContentBlock extends ComponentBase
return 'Pass';
}
}

View File

@ -4,7 +4,6 @@ use Cms\Classes\ComponentBase;
class MainMenu extends ComponentBase
{
public function componentDetails()
{
return [
@ -17,5 +16,4 @@ class MainMenu extends ComponentBase
{
return ['Home', 'Blog', 'About', 'Contact'];
}
}

View File

@ -4,7 +4,6 @@ use Cms\Classes\ComponentBase;
class Post extends ComponentBase
{
public function componentDetails()
{
return [
@ -22,5 +21,4 @@ class Post extends ComponentBase
]
];
}
}

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [

View File

@ -4,7 +4,6 @@ use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
@ -23,5 +22,4 @@ class Plugin extends PluginBase
]
];
}
}

Some files were not shown because too many files have changed in this diff Show More