Code formatting changes (#3363)
Code formatting improvements submitted by @arthurkushman.
This commit is contained in:
parent
13dadaa667
commit
c78b3ef786
|
|
@ -3,14 +3,12 @@
|
|||
use App;
|
||||
use Lang;
|
||||
use Event;
|
||||
use Backend;
|
||||
use BackendMenu;
|
||||
use BackendAuth;
|
||||
use Backend\Models\UserRole;
|
||||
use Backend\Classes\WidgetManager;
|
||||
use October\Rain\Support\ModuleServiceProvider;
|
||||
use System\Classes\SettingsManager;
|
||||
use System\Classes\CombineAssets;
|
||||
use Cms\Classes\ComponentManager;
|
||||
use Cms\Classes\Page as CmsPage;
|
||||
use Cms\Classes\CmsObject;
|
||||
|
|
@ -242,7 +240,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
protected function registerBackendWidgets()
|
||||
{
|
||||
WidgetManager::instance()->registerFormWidgets(function ($manager) {
|
||||
$manager->registerFormWidget('Cms\FormWidgets\Components');
|
||||
$manager->registerFormWidget(FormWidgets\Components::class);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +265,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
'description' => 'cms::lang.maintenance.settings_menu_description',
|
||||
'category' => SettingsManager::CATEGORY_CMS,
|
||||
'icon' => 'icon-plug',
|
||||
'class' => 'Cms\Models\MaintenanceSetting',
|
||||
'class' => Models\MaintenanceSetting::class,
|
||||
'permissions' => ['cms.manage_themes'],
|
||||
'order' => 300
|
||||
],
|
||||
|
|
@ -297,13 +295,13 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
});
|
||||
|
||||
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
|
||||
if ($type == 'cms-page') {
|
||||
if ($type === 'cms-page') {
|
||||
return CmsPage::getMenuTypeInfo($type);
|
||||
}
|
||||
});
|
||||
|
||||
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
|
||||
if ($type == 'cms-page') {
|
||||
if ($type === 'cms-page') {
|
||||
return CmsPage::resolveMenuItem($item, $url, $theme);
|
||||
}
|
||||
});
|
||||
|
|
@ -321,7 +319,7 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
});
|
||||
|
||||
Event::listen('backend.richeditor.getTypeInfo', function ($type) {
|
||||
if ($type == 'cms-page') {
|
||||
if ($type === 'cms-page') {
|
||||
return CmsPage::getRichEditorTypeInfo($type);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class Controller
|
|||
$url = Request::path();
|
||||
}
|
||||
|
||||
if (!strlen($url)) {
|
||||
if (empty($url)) {
|
||||
$url = '/';
|
||||
}
|
||||
|
||||
|
|
@ -156,11 +156,9 @@ class Controller
|
|||
* Hidden page
|
||||
*/
|
||||
$page = $this->router->findByUrl($url);
|
||||
if ($page && $page->is_hidden) {
|
||||
if (!BackendAuth::getUser()) {
|
||||
if ($page && $page->is_hidden && !BackendAuth::getUser()) {
|
||||
$page = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Maintenance mode
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Layout extends CmsCompoundObject
|
|||
*/
|
||||
public function isFallBack()
|
||||
{
|
||||
return $this->fileName == self::FALLBACK_FILE_NAME;
|
||||
return $this->fileName === self::FALLBACK_FILE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -50,6 +50,6 @@ class Layout extends CmsCompoundObject
|
|||
*/
|
||||
public function getCodeClassParent()
|
||||
{
|
||||
return '\Cms\Classes\LayoutCode';
|
||||
return LayoutCode::class;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class MediaLibrary extends SystemMediaLibrary
|
|||
*/
|
||||
protected function init()
|
||||
{
|
||||
traceLog('Class Cms\Classes\MediaLibrary has been deprecated, use ' . SystemMediaLibrary::class . ' instead.');
|
||||
traceLog('Class ' . __CLASS__ . ' has been deprecated, use ' . SystemMediaLibrary::class . ' instead.');
|
||||
parent::init();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Page extends CmsCompoundObject
|
|||
*/
|
||||
public function getCodeClassParent() : string
|
||||
{
|
||||
return '\Cms\Classes\PageCode';
|
||||
return PageCode::class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -185,8 +185,7 @@ class Resources extends ComponentBase
|
|||
if (File::isDirectory($baseTheme.'/assets')) {
|
||||
return $baseTheme.'/assets';
|
||||
}
|
||||
else {
|
||||
|
||||
return $baseTheme.'/resources';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ViewBag extends ComponentBase
|
|||
/**
|
||||
* Determine if an attribute exists on the object.
|
||||
* @param string $key
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use Backend\Classes\Controller;
|
|||
use Backend\Classes\WidgetManager;
|
||||
use October\Rain\Router\Router as RainRouter;
|
||||
use ApplicationException;
|
||||
use Cms\Classes\Asset;
|
||||
|
||||
/**
|
||||
* CMS index
|
||||
|
|
@ -126,7 +127,7 @@ class Index extends Controller
|
|||
|
||||
$this->vars['templatePath'] = Request::input('path');
|
||||
|
||||
if ($type == 'page') {
|
||||
if ($type === 'page') {
|
||||
$router = new RainRouter;
|
||||
$this->vars['pageUrl'] = $router->urlFromPattern($template->url);
|
||||
}
|
||||
|
|
@ -203,7 +204,7 @@ class Index extends Controller
|
|||
'tabTitle' => $this->getTabTitle($type, $template)
|
||||
];
|
||||
|
||||
if ($type == 'page') {
|
||||
if ($type === 'page') {
|
||||
$result['pageUrl'] = Url::to($template->url);
|
||||
$router = new Router($this->theme);
|
||||
$router->clearCache();
|
||||
|
|
@ -223,7 +224,7 @@ class Index extends Controller
|
|||
$type = Request::input('type');
|
||||
$template = $this->createTemplate($type);
|
||||
|
||||
if ($type == 'asset') {
|
||||
if ($type === 'asset') {
|
||||
$template->fileName = $this->widget->assetList->getCurrentRelativePath();
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +307,7 @@ class Index extends Controller
|
|||
}
|
||||
|
||||
// Can only expand components at this stage
|
||||
if ((!$type = post('tokenType')) && $type != 'component') {
|
||||
if ((!$type = post('tokenType')) && $type !== 'component') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -345,11 +346,11 @@ class Index extends Controller
|
|||
protected function resolveTypeClassName($type)
|
||||
{
|
||||
$types = [
|
||||
'page' => '\Cms\Classes\Page',
|
||||
'partial' => '\Cms\Classes\Partial',
|
||||
'layout' => '\Cms\Classes\Layout',
|
||||
'content' => '\Cms\Classes\Content',
|
||||
'asset' => '\Cms\Classes\Asset'
|
||||
'page' => Page::class,
|
||||
'partial' => Partial::class,
|
||||
'layout' => Layout::class,
|
||||
'content' => Content::class,
|
||||
'asset' => Asset::class
|
||||
];
|
||||
|
||||
if (!array_key_exists($type, $types)) {
|
||||
|
|
@ -388,7 +389,7 @@ class Index extends Controller
|
|||
|
||||
protected function getTabTitle($type, $template)
|
||||
{
|
||||
if ($type == 'page') {
|
||||
if ($type === 'page') {
|
||||
$result = $template->title ?: $template->getFileName();
|
||||
if (!$result) {
|
||||
$result = trans('cms::lang.page.new');
|
||||
|
|
@ -397,7 +398,7 @@ class Index extends Controller
|
|||
return $result;
|
||||
}
|
||||
|
||||
if ($type == 'partial' || $type == 'layout' || $type == 'content' || $type == 'asset') {
|
||||
if ($type === 'partial' || $type === 'layout' || $type === 'content' || $type === 'asset') {
|
||||
$result = in_array($type, ['asset', 'content']) ? $template->getFileName() : $template->getBaseFileName();
|
||||
if (!$result) {
|
||||
$result = trans('cms::lang.'.$type.'.new');
|
||||
|
|
@ -504,8 +505,7 @@ class Index extends Controller
|
|||
*/
|
||||
protected function convertLineEndings($markup)
|
||||
{
|
||||
$markup = str_replace("\r\n", "\n", $markup);
|
||||
$markup = str_replace("\r", "\n", $markup);
|
||||
$markup = str_replace(["\r\n", "\r"], "\n", $markup);
|
||||
|
||||
return $markup;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use Cms\Classes\ThemeManager;
|
|||
use System\Classes\SettingsManager;
|
||||
use Backend\Classes\Controller;
|
||||
use Exception;
|
||||
use Backend\Widgets\Form;
|
||||
|
||||
/**
|
||||
* Theme selector controller
|
||||
|
|
@ -57,7 +58,7 @@ class Themes extends Controller
|
|||
/*
|
||||
* Enable AJAX for Form widgets
|
||||
*/
|
||||
if (post('mode') == 'import') {
|
||||
if (post('mode') === 'import') {
|
||||
$this->makeImportFormWidget($this->findThemeObject())->bindToController();
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +117,7 @@ class Themes extends Controller
|
|||
$widgetConfig->arrayName = 'Theme';
|
||||
$widgetConfig->context = 'update';
|
||||
|
||||
$widget = $this->makeWidget('Backend\Widgets\Form', $widgetConfig);
|
||||
$widget = $this->makeWidget(Form::class, $widgetConfig);
|
||||
return $widget;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ class Cms
|
|||
if (self::$actionExists) {
|
||||
return Url::action($routeAction, ['slug' => $path]);
|
||||
}
|
||||
else {
|
||||
|
||||
return Url::to($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class File
|
|||
public static function validateExtension($fileName, $allowedExtensions, $allowEmpty = true)
|
||||
{
|
||||
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
if (!strlen($extension)) {
|
||||
if (empty($extension)) {
|
||||
return $allowEmpty;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use Model;
|
|||
use Cms\Classes\Theme as CmsTheme;
|
||||
use System\Classes\CombineAssets;
|
||||
use Exception;
|
||||
use System\Models\File;
|
||||
|
||||
/**
|
||||
* Customization data used by a theme
|
||||
|
|
@ -106,11 +107,11 @@ class ThemeData extends Model
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($field['type'] == 'repeater') {
|
||||
if ($field['type'] === 'repeater') {
|
||||
$this->jsonable[] = $id;
|
||||
}
|
||||
elseif ($field['type'] == 'fileupload') {
|
||||
$this->attachOne[$id] = 'System\Models\File';
|
||||
elseif ($field['type'] === 'fileupload') {
|
||||
$this->attachOne[$id] = File::class;
|
||||
unset($data[$id]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class Loader extends LoaderBase implements Twig_LoaderInterface
|
|||
*/
|
||||
protected function validateCmsObject($name)
|
||||
{
|
||||
if ($name == $this->obj->getFilePath()) {
|
||||
if ($name === $this->obj->getFilePath()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Loader implements Twig_LoaderInterface
|
|||
}
|
||||
|
||||
$view = $name;
|
||||
if (File::extension($view) == $this->extension) {
|
||||
if (File::extension($view) === $this->extension) {
|
||||
$view = substr($view, 0, -strlen($this->extension));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
use Cms\Classes\Theme as MyTheme;
|
||||
use Cms\Classes\Router as MyRouter;
|
||||
class {className} extends \Cms\Classes\PageCode
|
||||
class {className} extends Cms\Classes\PageCode
|
||||
{
|
||||
public function onStart() {
|
||||
$this['pageStartVar'] = 3;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
use Cms\Classes\Theme;
|
||||
use Cms\Classes\Router;
|
||||
class {className} extends \Cms\Classes\PageCode
|
||||
class {className} extends Cms\Classes\PageCode
|
||||
{
|
||||
public function onStart() {
|
||||
$this['pageStartVar'] = 3;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Cms\Classes\PageCode;
|
||||
use Cms\Classes\LayoutCode;
|
||||
use Cms\Classes\Page;
|
||||
use Cms\Classes\Theme;
|
||||
use Cms\Classes\Layout;
|
||||
|
|
@ -22,7 +24,7 @@ class CodeParserTest extends TestCase
|
|||
|
||||
public static function getProperty($name)
|
||||
{
|
||||
$class = new ReflectionClass('\Cms\Classes\CodeParser');
|
||||
$class = new ReflectionClass(CodeParser::class);
|
||||
$property = $class->getProperty($name);
|
||||
$property->setAccessible(true);
|
||||
|
||||
|
|
@ -48,7 +50,7 @@ class CodeParserTest extends TestCase
|
|||
|
||||
$controller = new Controller($theme);
|
||||
$obj = $parser->source(null, $layout, $controller);
|
||||
$this->assertInstanceOf('\Cms\Classes\LayoutCode', $obj);
|
||||
$this->assertInstanceOf(LayoutCode::class, $obj);
|
||||
|
||||
/*
|
||||
* Test the file contents
|
||||
|
|
@ -57,7 +59,7 @@ class CodeParserTest extends TestCase
|
|||
$body = preg_replace('/^\s*function/m', 'public function', $layout->code);
|
||||
$expectedContent = '<?php ' . PHP_EOL;
|
||||
|
||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\LayoutCode'.PHP_EOL;
|
||||
$expectedContent .= 'class ' . $info['className'] . ' extends ' . LayoutCode::class . PHP_EOL;
|
||||
$expectedContent .= '{' . PHP_EOL;
|
||||
$expectedContent .= $body . PHP_EOL;
|
||||
$expectedContent .= '}' . PHP_EOL;
|
||||
|
|
@ -137,7 +139,7 @@ class CodeParserTest extends TestCase
|
|||
$this->assertFileExists($info['filePath']);
|
||||
|
||||
$expectedContent = '<?php ' . PHP_EOL;
|
||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\LayoutCode'.PHP_EOL;
|
||||
$expectedContent .= 'class ' . $info['className'] . ' extends ' . LayoutCode::class . PHP_EOL;
|
||||
$expectedContent .= '{' . PHP_EOL;
|
||||
$expectedContent .= PHP_EOL;
|
||||
$expectedContent .= '}' . PHP_EOL;
|
||||
|
|
@ -163,11 +165,11 @@ class CodeParserTest extends TestCase
|
|||
$this->assertFileExists($info['filePath']);
|
||||
$controller = new Controller($theme);
|
||||
$obj = $parser->source($page, null, $controller);
|
||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
||||
$this->assertInstanceOf(PageCode::class, $obj);
|
||||
|
||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||
$expectedContent = '<?php ' . PHP_EOL;
|
||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
||||
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||
$expectedContent .= '{' . PHP_EOL;
|
||||
$expectedContent .= $body . PHP_EOL;
|
||||
$expectedContent .= '}' . PHP_EOL;
|
||||
|
|
@ -201,7 +203,7 @@ class CodeParserTest extends TestCase
|
|||
|
||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||
$expectedContent = '<?php ' . PHP_EOL;
|
||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
||||
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||
$expectedContent .= '{' . PHP_EOL;
|
||||
$expectedContent .= $body . PHP_EOL;
|
||||
$expectedContent .= '}' . PHP_EOL;
|
||||
|
|
@ -226,11 +228,11 @@ class CodeParserTest extends TestCase
|
|||
$this->assertFileExists($info['filePath']);
|
||||
$controller = new Controller($theme);
|
||||
$obj = $parser->source($page, null, $controller);
|
||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
||||
$this->assertInstanceOf(PageCode::class, $obj);
|
||||
|
||||
$body = preg_replace('/^\s*function/m', 'public function', $page->code);
|
||||
$expectedContent = '<?php ' . PHP_EOL;
|
||||
$expectedContent .= 'class '.$info['className'].' extends \Cms\Classes\PageCode'.PHP_EOL;
|
||||
$expectedContent .= 'class ' . $info['className'] . ' extends ' . PageCode::class . PHP_EOL;
|
||||
$expectedContent .= '{' . PHP_EOL;
|
||||
$expectedContent .= $body . PHP_EOL;
|
||||
$expectedContent .= '}' . PHP_EOL;
|
||||
|
|
@ -261,7 +263,7 @@ class CodeParserTest extends TestCase
|
|||
$this->assertFileExists($info['filePath']);
|
||||
$controller = new Controller($theme);
|
||||
$obj = $parser->source($page, null, $controller);
|
||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
||||
$this->assertInstanceOf(PageCode::class, $obj);
|
||||
|
||||
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces.php.stub';
|
||||
$this->assertFileExists($referenceFilePath);
|
||||
|
|
@ -290,7 +292,7 @@ class CodeParserTest extends TestCase
|
|||
$this->assertFileExists($info['filePath']);
|
||||
$controller = new Controller($theme);
|
||||
$obj = $parser->source($page, null, $controller);
|
||||
$this->assertInstanceOf('\Cms\Classes\PageCode', $obj);
|
||||
$this->assertInstanceOf(PageCode::class, $obj);
|
||||
|
||||
$referenceFilePath = base_path() . '/tests/fixtures/cms/reference/namespaces-aliases.php.stub';
|
||||
$this->assertFileExists($referenceFilePath);
|
||||
|
|
|
|||
Loading…
Reference in New Issue