diff --git a/code/AdminRootController.php b/code/AdminRootController.php index e3c95a81c..5231f21bf 100644 --- a/code/AdminRootController.php +++ b/code/AdminRootController.php @@ -69,11 +69,11 @@ public static function admin_url() public static function rules() { if (self::$adminRules === null) { - self::$adminRules = array(); + self::$adminRules = []; // Map over the array calling add_rule_for_controller on each $classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY); - array_map(array(__CLASS__, 'add_rule_for_controller'), $classes ?? []); + array_map([__CLASS__, 'add_rule_for_controller'], $classes ?? []); } return self::$adminRules; } @@ -135,8 +135,8 @@ public function handleRequest(HTTPRequest $request) */ public static function get_template_global_variables() { - return array( + return [ 'adminURL' => 'admin_url' - ); + ]; } } diff --git a/code/CMSBatchAction.php b/code/CMSBatchAction.php index 40f725e9d..e5479af3c 100644 --- a/code/CMSBatchAction.php +++ b/code/CMSBatchAction.php @@ -99,14 +99,14 @@ public function response($successMessage, $status) * } * } */ - public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = array()) + public function batchaction(SS_List $objs, $helperMethod, $successMessage, $arguments = []) { - $status = array('modified' => array(), 'error' => array(), 'deleted' => array(), 'success' => array()); + $status = ['modified' => [], 'error' => [], 'deleted' => [], 'success' => []]; foreach ($objs as $obj) { // Perform the action $id = $obj->ID; - if (!call_user_func_array(array($obj, $helperMethod), $arguments ?? [])) { + if (!call_user_func_array([$obj, $helperMethod], $arguments ?? [])) { $status['error'][$id] = $id; } else { $status['success'][$id] = $id; @@ -115,9 +115,9 @@ public function batchaction(SS_List $objs, $helperMethod, $successMessage, $argu // Now make sure the tree title is appropriately updated $publishedRecord = DataObject::get_by_id($this->managedClass, $id); if ($publishedRecord) { - $status['modified'][$id] = array( + $status['modified'][$id] = [ 'TreeTitle' => $publishedRecord->TreeTitle, - ); + ]; } else { $status['deleted'][$id] = $id; } @@ -148,7 +148,7 @@ public function applicablePagesHelper($ids, $methodName, $checkStagePages = true user_error("Bad \$methodName passed to applicablePagesHelper()", E_USER_WARNING); } - $applicableIDs = array(); + $applicableIDs = []; $managedClass = $this->managedClass; $draftPages = DataObject::get($managedClass)->byIDs($ids); diff --git a/code/CMSBatchActionHandler.php b/code/CMSBatchActionHandler.php index 51e54afed..4c664f536 100644 --- a/code/CMSBatchActionHandler.php +++ b/code/CMSBatchActionHandler.php @@ -25,7 +25,7 @@ class CMSBatchActionHandler extends RequestHandler { /** @config */ - private static $batch_actions = array(); + private static $batch_actions = []; /** * List of registered actions @@ -34,17 +34,17 @@ class CMSBatchActionHandler extends RequestHandler */ private static $registered_actions = null; - private static $url_handlers = array( + private static $url_handlers = [ '$BatchAction/applicablepages' => 'handleApplicablePages', '$BatchAction/confirmation' => 'handleConfirmation', '$BatchAction' => 'handleBatchAction', - ); + ]; - private static $allowed_actions = array( + private static $allowed_actions = [ 'handleBatchAction', 'handleApplicablePages', 'handleConfirmation', - ); + ]; /** * @var Controller @@ -178,7 +178,7 @@ public function handleApplicablePages($request) if ($ids) { $applicableIDs = $actionHandler->applicablePages($ids); } else { - $applicableIDs = array(); + $applicableIDs = []; } $response = new HTTPResponse(json_encode($applicableIDs)); @@ -206,7 +206,7 @@ public function handleConfirmation($request) if ($actionHandler->hasMethod('confirmationDialog')) { $response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids))); } else { - $response = new HTTPResponse(json_encode(array('alert' => false))); + $response = new HTTPResponse(json_encode(['alert' => false])); } $response->addHeader("Content-type", "application/json"); @@ -246,10 +246,10 @@ public function batchActionList() foreach ($actions as $urlSegment => $action) { $actionObj = $this->buildAction($action['class']); if ($actionObj->canView()) { - $actionDef = new ArrayData(array( + $actionDef = new ArrayData([ "Link" => Controller::join_links($this->Link(), $urlSegment), "Title" => $actionObj->getActionTitle(), - )); + ]); $actionList->push($actionDef); } } diff --git a/code/CMSMenu.php b/code/CMSMenu.php index bbe212019..40a97e233 100644 --- a/code/CMSMenu.php +++ b/code/CMSMenu.php @@ -48,7 +48,7 @@ class CMSMenu implements IteratorAggregate, i18nEntityProvider * - array('type' => 'add', 'item' => CMSMenuItem::create(...) ) * - array('type' => 'remove', 'code' => 'codename' ) */ - protected static $menu_item_changes = array(); + protected static $menu_item_changes = []; /** * Set to true if clear_menu() is called, to indicate that the default menu shouldn't be @@ -200,7 +200,7 @@ public static function get_menu_code($cmsClass) */ public static function get_menu_items() { - $menuItems = array(); + $menuItems = []; // Set up default menu items if (!self::$menu_is_cleared) { @@ -231,8 +231,8 @@ public static function get_menu_items() } // Sort menu items according to priority, then title asc - $menuPriority = array(); - $menuTitle = array(); + $menuPriority = []; + $menuTitle = []; foreach ($menuItems as $key => $menuItem) { $menuPriority[$key] = is_numeric($menuItem->priority) ? $menuItem->priority : 0; $menuTitle[$key] = $menuItem->title; @@ -255,7 +255,7 @@ public static function get_viewable_menu_items($member = null) $member = Security::getCurrentUser(); } - $viewableMenuItems = array(); + $viewableMenuItems = []; $allMenuItems = self::get_menu_items(); if ($allMenuItems) { foreach ($allMenuItems as $code => $menuItem) { @@ -287,7 +287,7 @@ public static function get_viewable_menu_items($member = null) */ public static function remove_menu_item($code) { - self::$menu_item_changes[] = array('type' => 'remove', 'code' => $code); + self::$menu_item_changes[] = ['type' => 'remove', 'code' => $code]; } /** @@ -306,7 +306,7 @@ public static function remove_menu_class($className) */ public static function clear_menu() { - self::$menu_item_changes = array(); + self::$menu_item_changes = []; self::$menu_is_cleared = true; } @@ -342,11 +342,11 @@ public static function replace_menu_item( $item->setAttributes($attributes); } - self::$menu_item_changes[] = array( + self::$menu_item_changes[] = [ 'type' => 'add', 'code' => $code, 'item' => $item, - ); + ]; } /** @@ -357,11 +357,11 @@ public static function replace_menu_item( */ protected static function add_menu_item_obj($code, $cmsMenuItem) { - self::$menu_item_changes[] = array( + self::$menu_item_changes[] = [ 'type' => 'add', 'code' => $code, 'item' => $cmsMenuItem, - ); + ]; } /** @@ -428,7 +428,7 @@ public function getIterator() public function provideI18nEntities() { $cmsClasses = self::get_cms_classes(); - $entities = array(); + $entities = []; foreach ($cmsClasses as $cmsClass) { $defaultTitle = LeftAndMain::menu_title($cmsClass, false); $ownerModule = ClassLoader::inst()->getManifest()->getOwnerModule($cmsClass); diff --git a/code/CMSMenuItem.php b/code/CMSMenuItem.php index d3324cd0c..89b945719 100644 --- a/code/CMSMenuItem.php +++ b/code/CMSMenuItem.php @@ -49,7 +49,7 @@ class CMSMenuItem * * @var string */ - protected $attributes = array(); + protected $attributes = []; /** * @var string @@ -105,7 +105,7 @@ public function getAttributesHTML($attrs = null) } // Create markkup - $parts = array(); + $parts = []; foreach ($attrs as $name => $value) { if ($value === true) { diff --git a/code/CMSProfileController.php b/code/CMSProfileController.php index 45cfb065c..8c6d6747f 100644 --- a/code/CMSProfileController.php +++ b/code/CMSProfileController.php @@ -111,6 +111,6 @@ public function save($data, $form) public function Breadcrumbs($unlinked = false) { $items = parent::Breadcrumbs($unlinked); - return new ArrayList(array($items[0])); + return new ArrayList([$items[0]]); } } diff --git a/code/Forms/UsedOnTable.php b/code/Forms/UsedOnTable.php index 2777065d9..a8ef9a5db 100644 --- a/code/Forms/UsedOnTable.php +++ b/code/Forms/UsedOnTable.php @@ -186,12 +186,12 @@ public function setRecord($record) */ public function getAttributes() { - $attributes = array( + $attributes = [ 'class' => $this->extraClass(), 'id' => $this->ID(), 'data-schema' => json_encode($this->getSchemaData()), 'data-state' => json_encode($this->getSchemaState()), - ); + ]; $attributes = array_merge($attributes, $this->attributes); diff --git a/code/GroupImportForm.php b/code/GroupImportForm.php index af1613114..939aa9044 100644 --- a/code/GroupImportForm.php +++ b/code/GroupImportForm.php @@ -50,7 +50,7 @@ public function __construct($controller, $name, $fields = null, $actions = null, . 'cleared.</li>' . '</ul>' . '</div>', - array('columns' => $columns) + ['columns' => $columns] ); $fields = new FieldList( @@ -63,7 +63,7 @@ public function __construct($controller, $name, $fields = null, $actions = null, )) ) ); - $fileField->getValidator()->setAllowedExtensions(array('csv')); + $fileField->getValidator()->setAllowedExtensions(['csv']); } if (!$actions) { @@ -90,26 +90,26 @@ public function doImport($data, $form) $result = $loader->load($data['CsvFile']['tmp_name']); // result message - $msgArr = array(); + $msgArr = []; if ($result->CreatedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultCreated', 'Created {count} groups', - array('count' => $result->CreatedCount()) + ['count' => $result->CreatedCount()] ); } if ($result->UpdatedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultUpdated', 'Updated {count} groups', - array('count' => $result->UpdatedCount()) + ['count' => $result->UpdatedCount()] ); } if ($result->DeletedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultDeleted', 'Deleted {count} groups', - array('count' => $result->DeletedCount()) + ['count' => $result->DeletedCount()] ); } $msg = ($msgArr) ? implode(',', $msgArr) : _t('SilverStripe\\Admin\\MemberImportForm.ResultNone', 'No changes'); diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index a2a1a8c2d..ddd5e6495 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -231,7 +231,7 @@ class LeftAndMain extends Controller implements PermissionProvider * @config * @var array */ - private static $extra_requirements_javascript = array(); + private static $extra_requirements_javascript = []; /** * YAML configuration example: @@ -245,13 +245,13 @@ class LeftAndMain extends Controller implements PermissionProvider * @config * @var array See {@link extra_requirements_javascript} */ - private static $extra_requirements_css = array(); + private static $extra_requirements_css = []; /** * @config * @var array See {@link extra_requirements_javascript} */ - private static $extra_requirements_themedCss = array(); + private static $extra_requirements_themedCss = []; /** * If true, call a keepalive ping every 5 minutes from the CMS interface, @@ -642,7 +642,7 @@ protected function init() } // if no alternate menu items have matched, return a permission error - $messageSet = array( + $messageSet = [ 'default' => _t( __CLASS__ . '.PERMDEFAULT', "You must be logged in to access the administration area; please enter your credentials below." @@ -657,7 +657,7 @@ protected function init() "You have been logged out of the CMS. If you would like to log in again, enter a username and" . " password below." ), - ); + ]; Security::permissionFailure($this, $messageSet); return; @@ -716,7 +716,7 @@ protected function init() foreach ($extraJs as $file => $config) { if (is_numeric($file)) { $file = $config; - $config = array(); + $config = []; } Requirements::javascript($file, $config); @@ -729,7 +729,7 @@ protected function init() foreach ($extraCss as $file => $config) { if (is_numeric($file)) { $file = $config; - $config = array(); + $config = []; } $media = null; if (isset($config['media'])) { @@ -747,7 +747,7 @@ protected function init() foreach ($extraThemedCss as $file => $config) { if (is_numeric($file)) { $file = $config; - $config = array(); + $config = []; } $media = null; if (isset($config['media'])) { @@ -1024,7 +1024,7 @@ public function getResponseNegotiator() { if (!$this->responseNegotiator) { $this->responseNegotiator = new PjaxResponseNegotiator( - array( + [ 'CurrentForm' => function () { return $this->getEditForm()->forTemplate(); }, @@ -1040,7 +1040,7 @@ public function getResponseNegotiator() 'default' => function () { return $this->renderWith($this->getViewer('show')); } - ), + ], $this->getResponse() ); } @@ -1129,7 +1129,7 @@ public function MainMenu($cached = true) $iconClass = $menuItem->iconClass; } - $menu->push(new ArrayData(array( + $menu->push(new ArrayData([ "MenuItem" => $menuItem, "AttributesHTML" => $menuItem->getAttributesHTML(), "Title" => $title, @@ -1139,7 +1139,7 @@ public function MainMenu($cached = true) "HasCSSIcon" => $hasCSSIcon, "Link" => $menuItem->url, "LinkingMode" => $linkingmode - ))); + ])); } } if ($menuIconStyling) { @@ -1230,12 +1230,12 @@ public function getRecord($id) */ public function Breadcrumbs($unlinked = false) { - $items = new ArrayList(array( - new ArrayData(array( + $items = new ArrayList([ + new ArrayData([ 'Title' => $this->menu_title(), 'Link' => ($unlinked) ? false : $this->Link() - )) - )); + ]) + ]); return $items; } @@ -1272,7 +1272,7 @@ protected function getSearchFilter() throw new InvalidArgumentException(sprintf('Invalid filter class passed: %s', $filterClass)); } - return $this->searchFilterCache = Injector::inst()->createWithArgs($filterClass, array($params)); + return $this->searchFilterCache = Injector::inst()->createWithArgs($filterClass, [$params]); } /** @@ -1363,7 +1363,7 @@ public function delete($data, $form) ); return $this->getResponseNegotiator()->respond( $this->getRequest(), - array('currentform' => array($this, 'EmptyForm')) + ['currentform' => [$this, 'EmptyForm']] ); } @@ -1482,11 +1482,11 @@ public function getEditForm($id = null, $fields = null) if ($request->isAjax() && $negotiator) { $result = $form->forTemplate(); - return $negotiator->respond($request, array( + return $negotiator->respond($request, [ 'CurrentForm' => function () use ($result) { return $result; } - )); + ]); } return null; }); @@ -1658,9 +1658,9 @@ public function printable() Requirements::clear(); Requirements::css('silverstripe/admin: dist/css/LeftAndMain_printable.css'); - return array( + return [ "PrintForm" => $form - ); + ]; } /** @@ -1965,14 +1965,14 @@ public function Locale() public function providePermissions() { - $perms = array( - "CMS_ACCESS_LeftAndMain" => array( + $perms = [ + "CMS_ACCESS_LeftAndMain" => [ 'name' => _t(__CLASS__ . '.ACCESSALLINTERFACES', 'Access to all CMS sections'), 'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access'), 'help' => _t(__CLASS__ . '.ACCESSALLINTERFACESHELP', 'Overrules more specific access settings.'), 'sort' => -100 - ) - ); + ] + ]; // Add any custom ModelAdmin subclasses. Can't put this on ModelAdmin itself // since its marked abstract, and needs to be singleton instanciated. @@ -1997,15 +1997,15 @@ public function providePermissions() $code = reset($code); } $title = LeftAndMain::menu_title($class); - $perms[$code] = array( + $perms[$code] = [ 'name' => _t( 'SilverStripe\\CMS\\Controllers\\CMSMain.ACCESS', "Access to '{title}' section", "Item in permission selection identifying the admin section. Example: Access to 'Files & Images'", - array('title' => $title) + ['title' => $title] ), 'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access') - ); + ]; } return $perms; diff --git a/code/MemberImportForm.php b/code/MemberImportForm.php index 4dc9b5243..991d74a7a 100644 --- a/code/MemberImportForm.php +++ b/code/MemberImportForm.php @@ -50,7 +50,7 @@ public function __construct($controller, $name, $fields = null, $actions = null, . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>', - array('columns' => $columns) + ['columns' => $columns] ); $fields = new FieldList( @@ -63,7 +63,7 @@ public function __construct($controller, $name, $fields = null, $actions = null, )) ) ); - $fileField->getValidator()->setAllowedExtensions(array('csv')); + $fileField->getValidator()->setAllowedExtensions(['csv']); } if (!$actions) { @@ -92,33 +92,33 @@ public function doImport($data, $form) // optionally set group relation if ($this->group) { - $loader->setGroups(array($this->group)); + $loader->setGroups([$this->group]); } // load file $result = $loader->load($data['CsvFile']['tmp_name']); // result message - $msgArr = array(); + $msgArr = []; if ($result->CreatedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultCreated', 'Created {count} members', - array('count' => $result->CreatedCount()) + ['count' => $result->CreatedCount()] ); } if ($result->UpdatedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultUpdated', 'Updated {count} members', - array('count' => $result->UpdatedCount()) + ['count' => $result->UpdatedCount()] ); } if ($result->DeletedCount()) { $msgArr[] = _t( __CLASS__ . '.ResultDeleted', 'Deleted {count} members', - array('count' => $result->DeletedCount()) + ['count' => $result->DeletedCount()] ); } $msg = ($msgArr) ? implode(',', $msgArr) : _t(__CLASS__ . '.ResultNone', 'No changes'); diff --git a/code/ModalController.php b/code/ModalController.php index 49943abc4..ac6ff3277 100644 --- a/code/ModalController.php +++ b/code/ModalController.php @@ -13,10 +13,10 @@ */ class ModalController extends RequestHandler { - private static $allowed_actions = array( + private static $allowed_actions = [ 'EditorExternalLink', 'EditorEmailLink', - ); + ]; public function Link($action = null) { diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 6dbe67628..6ac69a5e3 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -82,14 +82,14 @@ abstract class ModelAdmin extends LeftAndMain */ private static $menu_icon_class = 'font-icon-database'; - private static $allowed_actions = array( + private static $allowed_actions = [ 'ImportForm', 'SearchForm' - ); + ]; - private static $url_handlers = array( + private static $url_handlers = [ '$ModelClass/$Action' => 'handleAction' - ); + ]; /** * @var string The {@link \SilverStripe\ORM\DataObject} sub-class being managed during this object's lifetime. @@ -421,7 +421,7 @@ protected function getManagedModelTabs() $forms = new ArrayList(); foreach ($models as $tab => $options) { - $forms->push(new ArrayData(array( + $forms->push(new ArrayData([ 'Title' => $options['title'], 'Tab' => $tab, // `getManagedModels` did not always return a `dataClass` attribute @@ -429,7 +429,7 @@ protected function getManagedModelTabs() 'ClassName' => isset($options['dataClass']) ? $options['dataClass'] : $tab, 'Link' => $this->Link($this->sanitiseClassName($tab)), 'LinkOrCurrent' => ($tab == $this->modelTab) ? 'current' : 'link' - ))); + ])); } return $forms; @@ -464,7 +464,7 @@ public function getManagedModels() { $models = $this->config()->get('managed_models'); if (is_string($models)) { - $models = array($models); + $models = [$models]; } if (!count($models ?? [])) { throw new \RuntimeException( @@ -507,7 +507,7 @@ public function getModelImporters() } } - $importers = array(); + $importers = []; foreach ($importerClasses as $modelClass => $importerClass) { $importers[$modelClass] = new $importerClass($modelClass); } @@ -552,18 +552,18 @@ public function ImportForm() $spec = $importer->getImportSpec(); $specFields = new ArrayList(); foreach ($spec['fields'] as $name => $desc) { - $specFields->push(new ArrayData(array('Name' => $name, 'Description' => $desc))); + $specFields->push(new ArrayData(['Name' => $name, 'Description' => $desc])); } $specRelations = new ArrayList(); foreach ($spec['relations'] as $name => $desc) { - $specRelations->push(new ArrayData(array('Name' => $name, 'Description' => $desc))); + $specRelations->push(new ArrayData(['Name' => $name, 'Description' => $desc])); } - $specHTML = $this->customise(array( + $specHTML = $this->customise([ 'ClassName' => $this->sanitiseClassName($this->modelClass), 'ModelName' => Convert::raw2att($modelName), 'Fields' => $specFields, 'Relations' => $specRelations, - ))->renderWith($this->getTemplatesWithSuffix('_ImportSpec')); + ])->renderWith($this->getTemplatesWithSuffix('_ImportSpec')); $fields->push(new LiteralField("SpecFor{$modelName}", $specHTML)); $fields->push( @@ -642,21 +642,21 @@ public function import($data, $form, $request) $message .= _t( 'SilverStripe\\Admin\\ModelAdmin.IMPORTEDRECORDS', "Imported {count} records.", - array('count' => $results->CreatedCount()) + ['count' => $results->CreatedCount()] ); } if ($results && $results->UpdatedCount()) { $message .= _t( 'SilverStripe\\Admin\\ModelAdmin.UPDATEDRECORDS', "Updated {count} records.", - array('count' => $results->UpdatedCount()) + ['count' => $results->UpdatedCount()] ); } if ($results->DeletedCount()) { $message .= _t( 'SilverStripe\\Admin\\ModelAdmin.DELETEDRECORDS', "Deleted {count} records.", - array('count' => $results->DeletedCount()) + ['count' => $results->DeletedCount()] ); } if (!$results->CreatedCount() && !$results->UpdatedCount()) { diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 26f1b3b6e..ab3c60cbb 100755 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -47,7 +47,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider private static $menu_icon_class = 'font-icon-torsos-all'; - private static $allowed_actions = array( + private static $allowed_actions = [ 'EditForm', 'MemberImportForm', 'memberimport', @@ -56,7 +56,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider 'groups', 'users', 'roles' - ); + ]; /** * Shortcut action for setting the correct active tab. @@ -140,15 +140,15 @@ public function getEditForm($id = null, $fields = null) ); /** @var GridFieldDataColumns $columns */ $columns = $groupList->getConfig()->getComponentByType(GridFieldDataColumns::class); - $columns->setDisplayFields(array( + $columns->setDisplayFields([ 'Breadcrumbs' => Group::singleton()->fieldLabel('Title') - )); - $columns->setFieldFormatting(array( + ]); + $columns->setFieldFormatting([ 'Breadcrumbs' => function ($val, $item) { /** @var Group $item */ return Convert::raw2xml($item->getBreadcrumbs(' > ')); } - )); + ]); $fields = FieldList::create( TabSet::create( @@ -216,10 +216,10 @@ public function memberimport() Requirements::javascript('silverstripe/admin: client/dist/js/MemberImportForm.js'); Requirements::css('silverstripe/admin: client/dist/styles/bundle.css'); - return $this->renderWith('BlankPage', array( + return $this->renderWith('BlankPage', [ 'Form' => $this->MemberImportForm()->forTemplate(), 'Content' => ' ' - )); + ]); } /** @@ -248,10 +248,10 @@ public function groupimport() Requirements::javascript('silverstripe/admin: client/dist/js/MemberImportForm.js'); Requirements::css('silverstripe/admin: client/dist/styles/bundle.css'); - return $this->renderWith('BlankPage', array( + return $this->renderWith('BlankPage', [ 'Content' => ' ', 'Form' => $this->GroupImportForm()->forTemplate() - )); + ]); } /** @@ -291,20 +291,20 @@ public function Breadcrumbs($unlinked = false) // admin/security/EditForm/field/Groups/item/2/ItemEditForm/field/Members/item/1/edit $firstCrumb = $crumbs->shift(); if ($params['FieldName'] == 'Groups') { - $crumbs->unshift(new ArrayData(array( + $crumbs->unshift(new ArrayData([ 'Title' => Group::singleton()->i18n_plural_name(), 'Link' => $this->Link('groups') - ))); + ])); } elseif ($params['FieldName'] == 'Users') { - $crumbs->unshift(new ArrayData(array( + $crumbs->unshift(new ArrayData([ 'Title' => _t(__CLASS__ . '.Users', 'Users'), 'Link' => $this->Link('users') - ))); + ])); } elseif ($params['FieldName'] == 'Roles') { - $crumbs->unshift(new ArrayData(array( + $crumbs->unshift(new ArrayData([ 'Title' => _t(__CLASS__ . '.TABROLES', 'Roles'), 'Link' => $this->Link('roles') - ))); + ])); } $crumbs->unshift($firstCrumb); } @@ -315,7 +315,7 @@ public function Breadcrumbs($unlinked = false) public function providePermissions() { $title = $this->menu_title(); - return array( + return [ "CMS_ACCESS_SecurityAdmin" => [ 'name' => _t( 'SilverStripe\\CMS\\Controllers\\CMSMain.ACCESS', @@ -326,9 +326,9 @@ public function providePermissions() 'help' => _t( __CLASS__ . '.ACCESS_HELP', 'Allow viewing, adding and editing users, as well as assigning permissions and roles to them.' - ) + ), ], - 'EDIT_PERMISSIONS' => array( + 'EDIT_PERMISSIONS' => [ 'name' => _t(__CLASS__ . '.EDITPERMISSIONS', 'Manage permissions for groups'), 'category' => _t( 'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY', @@ -339,9 +339,9 @@ public function providePermissions() 'Ability to edit Permissions and IP Addresses for a group.' . ' Requires the "Access to \'Security\' section" permission.' ), - 'sort' => 0 - ), - 'APPLY_ROLES' => array( + 'sort' => 0, + ], + 'APPLY_ROLES' => [ 'name' => _t(__CLASS__ . '.APPLY_ROLES', 'Apply roles to groups'), 'category' => _t( 'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY', @@ -352,8 +352,8 @@ public function providePermissions() 'Ability to edit the roles assigned to a group.' . ' Requires the "Access to \'Users\' section" permission.' ), - 'sort' => 0 - ) - ); + 'sort' => 0, + ], + ]; } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9dfedc1ad..d06362a11 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -13,4 +13,7 @@ <exclude name="Generic.Files.LineLength.TooLong" /> <exclude name="PSR1.Files.SideEffects.FoundWithSymbols" /> </rule> + + <!-- use short array syntax --> + <rule ref="Generic.Arrays.DisallowLongArraySyntax" /> </ruleset> diff --git a/tests/behat/features/gridfield-navigation.feature b/tests/behat/features/gridfield-navigation.feature new file mode 100644 index 000000000..7404c3c4f --- /dev/null +++ b/tests/behat/features/gridfield-navigation.feature @@ -0,0 +1,254 @@ +Feature: Search in GridField + As an author + I want to navigate through the filtered and sorted GridField list + So that I see the filtered and sorted GridField when I navigate to an item and back to the GridFIeld list + + Background: + Given the "Company" "Walmart" with "Category"="Retail" + And the "Employee" "Alen" with "Company"="1" + And the "Employee" "Bill" with "Company"="1" + And the "Employee" "Ford" with "Company"="1" + And the "Company" "ExxonMobil" with "Category"="Oil" + And the "Company" "Vitol" with "Category"="Other" + And the "Company" "Safeway" with "Category"="Other" + And the "Company" "SuperValue" with "Category"="Other" + And the "Company" "UBS" with "Category"="Other" + And the "Company" "Kraft Foods" with "Category"="Other" + And the "Company" "Ahold" with "Category"="Other" + And the "Company" "Cisco" with "Category"="Other" + And the "Company" "Bouygues" with "Category"="Other" + And the "Company" "Insurance" with "Category"="Other" + And I am logged in with "ADMIN" permissions + + Scenario: I can navigate back through the GridField items by using the "previous record" button + When I go to "/admin/gridfield-test-navigation" + And I should see "Walmart" in the "#Form_EditForm" element + And I should see "ExxonMobil" in the "#Form_EditForm" element + And I should see "Vitol" in the "#Form_EditForm" element + And I should see "Safeway" in the "#Form_EditForm" element + And I should see "SuperValue" in the "#Form_EditForm" element + But I should not see "UBS" in the ".col-Name" element + And I should see "3" in the ".pagination-page-number" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + Then I click on the "#action_pagination_next" element + And I should see "View 6–10 of 11" in the ".pagination-records-number" element + And I should see "UBS" in the "#Form_EditForm" element + And I should see "Kraft Foods" in the "#Form_EditForm" element + And I should see "Ahold" in the "#Form_EditForm" element + And I should see "Cisco" in the "#Form_EditForm" element + And I should see "Bouygues" in the "#Form_EditForm" element + But I should not see "Insurance" in the ".col-Name" element + Then I click "Cisco" in the "#Form_EditForm" element + And I should see "Cisco" in the ".breadcrumbs-wrapper" element + And I should see an "#Form_ItemEditForm_PreviousAndNextGroup_Holder" element + Then I click on the ".action--previous" element + And I should see "Ahold" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Kraft Foods" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "UBS" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "SuperValue" in the ".breadcrumbs-wrapper" element + Then I click on the ".toolbar__back-button" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + Then I click "SuperValue" in the "#Form_EditForm" element + And I click on the ".action--previous" element + And I should see "Safeway" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Vitol" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "ExxonMobil" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Walmart" in the ".breadcrumbs-wrapper" element + And I should see an ".action--previous.disabled" element + And I click on the ".action--next" element + And I should see "ExxonMobil" in the ".breadcrumbs-wrapper" element + + Scenario: I can navigate forward through the GridField items by using the "next record" button + When I go to "/admin/gridfield-test-navigation" + And I should see "Walmart" in the "#Form_EditForm" element + And I should see "ExxonMobil" in the "#Form_EditForm" element + And I should see "Vitol" in the "#Form_EditForm" element + And I should see "Safeway" in the "#Form_EditForm" element + And I should see "SuperValue" in the "#Form_EditForm" element + But I should not see "UBS" in the ".col-Name" element + And I should see "3" in the ".pagination-page-number" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + Then I click "Walmart" in the "#Form_EditForm" element + And I should see "Walmart" in the ".breadcrumbs-wrapper" element + And I should see an "#Form_ItemEditForm_PreviousAndNextGroup_Holder" element + Then I click on the ".action--next" element + And I should see "ExxonMobil" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Vitol" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Safeway" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "SuperValue" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "UBS" in the ".breadcrumbs-wrapper" element + Then I click on the ".toolbar__back-button" element + And I should see "View 6–10 of 11" in the ".pagination-records-number" element + Then I click "UBS" in the "#Form_EditForm" element + And I click on the ".action--next" element + And I should see "Kraft Foods" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Ahold" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Cisco" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Bouygues" in the ".breadcrumbs-wrapper" element + And I click on the ".action--next" element + And I should see "Insurance" in the ".breadcrumbs-wrapper" element + And I should see an ".action--next.disabled" element + And I click on the ".action--previous" element + And I should see "Bouygues" in the ".breadcrumbs-wrapper" element + Then I click on the ".toolbar__back-button" element + Then I click on the "#action_SetOrderName" element + Then I click on the "#action_pagination_prev" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + And I should see "Ahold" in the "#Form_EditForm" element + And I should see "Bouygues" in the "#Form_EditForm" element + And I should see "Cisco" in the "#Form_EditForm" element + And I should see "ExxonMobil" in the "#Form_EditForm" element + And I should see "Insurance" in the "#Form_EditForm" element + Then I click on the "#action_pagination_next" element + And I should see "View 6–10 of 11" in the ".pagination-records-number" element + And I should see "Kraft Foods" in the "#Form_EditForm" element + And I should see "Safeway" in the "#Form_EditForm" element + And I should see "SuperValue" in the "#Form_EditForm" element + And I should see "UBS" in the "#Form_EditForm" element + And I should see "Vitol" in the "#Form_EditForm" element + Then I click "Vitol" in the "#Form_EditForm" element + And I should see "Vitol" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "UBS" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "SuperValue" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Safeway" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Kraft Foods" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "Insurance" in the ".breadcrumbs-wrapper" element + And I click on the ".action--previous" element + And I should see "ExxonMobil" in the ".breadcrumbs-wrapper" element + Then I click on the ".toolbar__back-button" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + + Scenario: I can navigate back and forward through the GridField items and keep filtered order + When I go to "/admin/gridfield-test-navigation" + And I should see "Walmart" in the "#Form_EditForm" element + And I should see "ExxonMobil" in the "#Form_EditForm" element + And I should see "Vitol" in the "#Form_EditForm" element + And I should see "Safeway" in the "#Form_EditForm" element + And I should see "SuperValue" in the "#Form_EditForm" element + But I should not see "UBS" in the ".col-Name" element + And I should see "3" in the ".pagination-page-number" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + Then I click "Walmart" in the "#Form_EditForm" element + And I should see "Walmart" + And I should see an "#Form_ItemEditForm_PreviousAndNextGroup_Holder" element + Then I click on the ".action--next" element + And I should see "ExxonMobil" + And I click on the ".action--next" element + And I should see "Vitol" + And I click on the ".action--next" element + And I should see "Safeway" + And I click on the ".action--next" element + And I should see "SuperValue" + And I click on the ".action--next" element + And I should see "UBS" + Then I click on the ".toolbar__back-button" element + And I should see "View 6–10 of 11" in the ".pagination-records-number" element + Then I click "UBS" in the "#Form_EditForm" element + And I click on the ".action--next" element + And I should see "Kraft Foods" + Then I click on the ".toolbar__back-button" element + Then I click on the "#action_SetOrderName" element + Then I click on the "#action_pagination_prev" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + And I should see "Ahold" in the "#Form_EditForm" element + And I should see "Bouygues" in the "#Form_EditForm" element + And I should see "Cisco" in the "#Form_EditForm" element + And I should see "ExxonMobil" in the "#Form_EditForm" element + And I should see "Insurance" in the "#Form_EditForm" element + Then I click on the "#action_pagination_next" element + And I should see "View 6–10 of 11" in the ".pagination-records-number" element + And I should see "Kraft Foods" in the "#Form_EditForm" element + And I should see "Safeway" in the "#Form_EditForm" element + And I should see "SuperValue" in the "#Form_EditForm" element + And I should see "UBS" in the "#Form_EditForm" element + And I should see "Vitol" in the "#Form_EditForm" element + Then I click "Vitol" in the "#Form_EditForm" element + And I should see "Vitol" + And I click on the ".action--previous" element + And I should see "UBS" + And I click on the ".action--previous" element + And I should see "SuperValue" + And I click on the ".action--previous" element + And I should see "Safeway" + And I click on the ".action--previous" element + And I should see "Kraft Foods" + And I click on the ".action--previous" element + And I should see "Insurance" + And I click on the ".action--previous" element + And I should see "ExxonMobil" + Then I click on the ".toolbar__back-button" element + And I should see "View 1–5 of 11" in the ".pagination-records-number" element + + Scenario: I can navigate back and forward through the GridField + When I am on "/admin/pages" + Then I go to "/admin/gridfield-test-navigation" + When I press the "Open search and filter" button + And I press the "Advanced" button + And I fill in "Search__Category" with "Retail" + And I press the "Enter" key in the "Search__Category" field + Then I should see "Walmart" in the "#Form_EditForm" element + But I should not see "ExxonMobil" in the ".col-Name" element + And I should not see "Vitol" in the ".col-Name" element + And I should not see "Safeway" in the ".col-Name" element + And I should not see "SuperValue" in the ".col-Name" element + When I move backward one page + And I should see "Pages" + When I move forward one page + Then I should see "Walmart" in the "#Form_EditForm" element + But I should not see "ExxonMobil" in the ".col-Name" element + And I should not see "Vitol" in the ".col-Name" element + And I should not see "Safeway" in the ".col-Name" element + And I should not see "SuperValue" in the ".col-Name" element + When I click "Walmart" in the "#Form_EditForm" element + Then I should see "Walmart" + Then I click "Employees" in the ".ui-tabs-nav" element + And I press the "Open search and filter" button + And I press the "Advanced" button + And I fill in "Search__Name" with "Alen" + And I press the "Enter" key in the "Search__Category" field + Then I should see "Alen" in the "#Form_ItemEditForm_Employees" element + And I click "Alen" in the "#Form_ItemEditForm_Employees" element + And I click "Walmart" in the ".breadcrumbs-wrapper" element + And I click "Employees" in the ".ui-tabs-nav" element + Then I should see "Alen" in the "#Form_ItemEditForm_Employees" element + But I should not see "Bill" in the ".col-Name" element + And I should not see "Ford" in the ".col-Name" element + And I should see an "#EmployeesSearch_searchbox" element + Then I click on the ".toolbar__back-button" element + And I should see "Walmart" in the "#Form_EditForm" element + But I should not see "ExxonMobil" in the ".col-Name" element + And I should not see "Vitol" in the ".col-Name" element + And I should not see "Safeway" in the ".col-Name" element + And I should not see "SuperValue" in the ".col-Name" element + And I should see an "#SilverStripe-FrameworkTest-Model-CompanySearch_searchbox" element + When I move backward one page + Then I click "Employees" in the ".ui-tabs-nav" element + Then I should see "Alen" + But I should not see "Bill" in the ".col-Name" element + And I should not see "Ford" in the ".col-Name" element + And I should see an "#EmployeesSearch_searchbox" element + When I move forward one page + And I should see "Walmart" in the "#Form_EditForm" element + But I should not see "ExxonMobil" in the ".col-Name" element + And I should not see "Vitol" in the ".col-Name" element + And I should not see "Safeway" in the ".col-Name" element + And I should not see "SuperValue" in the ".col-Name" element + And I should see an "#SilverStripe-FrameworkTest-Model-CompanySearch_searchbox" element diff --git a/tests/behat/features/gridfield-search.feature b/tests/behat/features/gridfield-search.feature index f7d02473d..5ea942eca 100644 --- a/tests/behat/features/gridfield-search.feature +++ b/tests/behat/features/gridfield-search.feature @@ -5,11 +5,8 @@ Feature: Search in GridField Background: Given the "Company" "Walmart" with "Category"="Retail" - And the "Employee" "Alen" with "Company"="1" - And the "Employee" "Bill" with "Company"="1" - And the "Employee" "Ford" with "Company"="1" And the "Company" "ExxonMobil" with "Category"="Oil" - And the "Company" "Vitol" with "Category"="Other" + And the "Company" "Vitol" with "Category"="Other" And I am logged in with "ADMIN" permissions And I go to "/admin/test" @@ -25,51 +22,3 @@ Feature: Search in GridField And I click "Walmart" in the "#Form_EditForm" element Then I should see "Walmart" And I should see "Walmart" in the ".breadcrumbs-wrapper" element - - Scenario: I can navigate back and forward through the GridField - When I am on "/admin/pages" - Then I go to "/admin/test" - When I press the "Open search and filter" button - And I press the "Advanced" button - And I fill in "Search__Category" with "Retail" - And I press the "Enter" key in the "Search__Category" field - Then I should see "Walmart" in the "#Form_EditForm" element - But I should not see "ExxonMobil" in the ".col-Name" element - And I should not see "Vitol" in the ".col-Name" element - When I move backward one page - And I should see "Pages" - When I move forward one page - Then I should see "Walmart" in the "#Form_EditForm" element - But I should not see "ExxonMobil" in the ".col-Name" element - And I should not see "Vitol" in the ".col-Name" element - When I click "Walmart" in the "#Form_EditForm" element - Then I should see "Walmart" - Then I click "Employees" in the ".ui-tabs-nav" element - And I press the "Open search and filter" button - And I press the "Advanced" button - And I fill in "Search__Name" with "Alen" - And I press the "Enter" key in the "Search__Category" field - Then I should see "Alen" in the "#Form_ItemEditForm_Employees" element - And I click "Alen" in the "#Form_ItemEditForm_Employees" element - And I click "Walmart" in the ".breadcrumbs-wrapper" element - And I click "Employees" in the ".ui-tabs-nav" element - Then I should see "Alen" in the "#Form_ItemEditForm_Employees" element - But I should not see "Bill" in the ".col-Name" element - And I should not see "Ford" in the ".col-Name" element - And I should see an "#EmployeesSearch_searchbox" element - Then I click on the ".toolbar__back-button" element - And I should see "Walmart" in the "#Form_EditForm" element - But I should not see "ExxonMobil" in the ".col-Name" element - And I should not see "Vitol" in the ".col-Name" element - And I should see an "#SilverStripe-FrameworkTest-Model-CompanySearch_searchbox" element - When I move backward one page - Then I click "Employees" in the ".ui-tabs-nav" element - Then I should see "Alen" - But I should not see "Bill" in the ".col-Name" element - And I should not see "Ford" in the ".col-Name" element - And I should see an "#EmployeesSearch_searchbox" element - When I move forward one page - And I should see "Walmart" in the "#Form_EditForm" element - But I should not see "ExxonMobil" in the ".col-Name" element - And I should not see "Vitol" in the ".col-Name" element - And I should see an "#SilverStripe-FrameworkTest-Model-CompanySearch_searchbox" element diff --git a/tests/php/CMSMenuItemTest.php b/tests/php/CMSMenuItemTest.php index 33e4352df..f7624929e 100644 --- a/tests/php/CMSMenuItemTest.php +++ b/tests/php/CMSMenuItemTest.php @@ -11,7 +11,7 @@ class CMSMenuItemTest extends SapphireTest public function testAttributes() { $menuItem = new CMSMenuItem('Foo', 'foo'); - $exampleAttributes = array('title' => 'foo bar', 'disabled' => true, 'data-foo' => '<something>'); + $exampleAttributes = ['title' => 'foo bar', 'disabled' => true, 'data-foo' => '<something>']; $this->assertEquals( 'title="foo bar" disabled="disabled" data-foo="<something>"', @@ -19,7 +19,7 @@ public function testAttributes() 'Attributes appear correctly when passed as an argument' ); - $emptyAttributes = array('empty' => ''); + $emptyAttributes = ['empty' => '']; $this->assertEquals( '', $menuItem->getAttributesHTML($emptyAttributes), diff --git a/tests/php/CMSMenuTest.php b/tests/php/CMSMenuTest.php index ba7ec0fd1..c74547ddc 100644 --- a/tests/php/CMSMenuTest.php +++ b/tests/php/CMSMenuTest.php @@ -79,9 +79,9 @@ public function testLinkWithExternalAttributes() { CMSMenu::clear_menu(); - CMSMenu::add_link('LinkCode', 'link title', 'http://www.example.com', -2, array( + CMSMenu::add_link('LinkCode', 'link title', 'http://www.example.com', -2, [ 'target' => '_blank' - )); + ]); $menuItems = CMSMenu::get_menu_items(); /** @var CMSMenuItem $menuItem */ diff --git a/tests/php/CMSProfileControllerTest.php b/tests/php/CMSProfileControllerTest.php index be2a128db..a38e88c7b 100644 --- a/tests/php/CMSProfileControllerTest.php +++ b/tests/php/CMSProfileControllerTest.php @@ -20,7 +20,7 @@ public function testMemberCantEditAnother() $anotherMember = $this->objFromFixture(Member::class, 'user2'); $this->logInAs($member); - $response = $this->post('admin/myprofile/EditForm', array( + $response = $this->post('admin/myprofile/EditForm', [ 'action_save' => 1, 'ID' => $anotherMember->ID, 'FirstName' => 'JoeEdited', @@ -29,7 +29,7 @@ public function testMemberCantEditAnother() 'Locale' => $member->Locale, 'Password[_Password]' => 'password', 'Password[_ConfirmPassword]' => 'password', - )); + ]); $anotherMember = $this->objFromFixture(Member::class, 'user2'); @@ -41,7 +41,7 @@ public function testMemberEditsOwnProfile() $member = $this->objFromFixture(Member::class, 'user3'); $this->logInAs($member); - $response = $this->post('admin/myprofile/EditForm', array( + $response = $this->post('admin/myprofile/EditForm', [ 'action_save' => 1, 'ID' => $member->ID, 'FirstName' => 'JoeEdited', @@ -50,7 +50,7 @@ public function testMemberEditsOwnProfile() 'Locale' => $member->Locale, 'Password[_Password]' => 'password', 'Password[_ConfirmPassword]' => 'password', - )); + ]); $member = $this->objFromFixture(Member::class, 'user3'); @@ -67,7 +67,7 @@ public function testExtendedPermissionsStopEditingOwnProfile() $member = $this->objFromFixture(Member::class, 'user1'); $this->logInAs($member); - $response = $this->post('admin/myprofile/EditForm', array( + $response = $this->post('admin/myprofile/EditForm', [ 'action_save' => 1, 'ID' => $member->ID, 'FirstName' => 'JoeEdited', @@ -76,7 +76,7 @@ public function testExtendedPermissionsStopEditingOwnProfile() 'Locale' => $member->Locale, 'Password[_Password]' => 'password', 'Password[_ConfirmPassword]' => 'password', - )); + ]); $member = $this->objFromFixture(Member::class, 'user1'); diff --git a/tests/php/LeftAndMainTest.php b/tests/php/LeftAndMainTest.php index 18e45c8ca..2929ed053 100644 --- a/tests/php/LeftAndMainTest.php +++ b/tests/php/LeftAndMainTest.php @@ -32,19 +32,19 @@ protected function setUp(): void $assetsDir = File::join_paths($base->getRelativePath(), 'tests/php/assets'); LeftAndMain::config() - ->update('extra_requirements_css', array( + ->update('extra_requirements_css', [ $assetsDir.'/LeftAndMainTest.css', $assetsDir. '/LeftAndMainTestWithOptions.css' => [ 'media' => 'print', 'crossorigin' => 'anonymous' ], - )) - ->update('extra_requirements_javascript', array( + ]) + ->update('extra_requirements_javascript', [ $assetsDir. '/LeftAndMainTest.js', $assetsDir. '/LeftAndMainTestWithOptions.js' => [ 'crossorigin' => 'anonymous' ], - )); + ]); Requirements::set_combined_files_enabled(false); } @@ -133,7 +133,7 @@ public function testCanView() $menuItems = LeftAndMain::singleton()->MainMenu(false); $this->assertEquals( $menuItems->column('Code'), - array(), + [], 'Without valid login, members cant access any menu entries' ); @@ -145,10 +145,10 @@ public function testCanView() sort($menuItems); $this->assertEquals( - array( + [ 'SilverStripe-Admin-CMSProfileController', 'SilverStripe-Admin-SecurityAdmin' - ), + ], $menuItems, 'Groups with limited access can only access the interfaces they have permissions for' ); diff --git a/tests/php/ModelAdminTest.php b/tests/php/ModelAdminTest.php index eef7cab90..c475f4c4e 100644 --- a/tests/php/ModelAdminTest.php +++ b/tests/php/ModelAdminTest.php @@ -90,10 +90,10 @@ public function testExportFieldsOverloadedMethod() $request->setSession(new Session([])); $admin->setRequest($request); $admin->doInit(); - $this->assertEquals($admin->getExportFields(), array( + $this->assertEquals($admin->getExportFields(), [ 'Name' => 'Name', 'Position' => 'Position' - )); + ]); } public function testGetGridField() diff --git a/tests/php/ModelAdminTest/Contact.php b/tests/php/ModelAdminTest/Contact.php index 510c59aa9..4b8be9777 100644 --- a/tests/php/ModelAdminTest/Contact.php +++ b/tests/php/ModelAdminTest/Contact.php @@ -8,12 +8,12 @@ class Contact extends DataObject implements TestOnly { private static $table_name = 'ModelAdminTest_Contact'; - private static $db = array( + private static $db = [ 'Name' => 'Varchar', 'Phone' => 'Varchar', - ); - private static $summary_fields = array( + ]; + private static $summary_fields = [ 'Name' => 'Name', 'Phone' => 'Phone' - ); + ]; } diff --git a/tests/php/ModelAdminTest/ContactAdmin.php b/tests/php/ModelAdminTest/ContactAdmin.php index 68827089d..1c145ee6a 100644 --- a/tests/php/ModelAdminTest/ContactAdmin.php +++ b/tests/php/ModelAdminTest/ContactAdmin.php @@ -10,9 +10,9 @@ class ContactAdmin extends ModelAdmin implements TestOnly { private static $url_segment = 'contactadmin'; - private static $managed_models = array( + private static $managed_models = [ Contact::class, - ); + ]; public function Link($action = null) { diff --git a/tests/php/ModelAdminTest/Player.php b/tests/php/ModelAdminTest/Player.php index e3950c32f..f49f505a5 100644 --- a/tests/php/ModelAdminTest/Player.php +++ b/tests/php/ModelAdminTest/Player.php @@ -8,11 +8,11 @@ class Player extends DataObject implements TestOnly { private static $table_name = 'ModelAdminTest_Player'; - private static $db = array( + private static $db = [ 'Name' => 'Varchar', 'Position' => 'Varchar', - ); - private static $has_one = array( + ]; + private static $has_one = [ 'Contact' => Contact::class - ); + ]; } diff --git a/tests/php/ModelAdminTest/PlayerAdmin.php b/tests/php/ModelAdminTest/PlayerAdmin.php index 7259e3694..7b7561dd6 100644 --- a/tests/php/ModelAdminTest/PlayerAdmin.php +++ b/tests/php/ModelAdminTest/PlayerAdmin.php @@ -10,16 +10,16 @@ class PlayerAdmin extends ModelAdmin implements TestOnly { private static $url_segment = 'playeradmin'; - private static $managed_models = array( + private static $managed_models = [ Player::class - ); + ]; public function getExportFields() { - return array( + return [ 'Name' => 'Name', 'Position' => 'Position' - ); + ]; } public function Link($action = null) diff --git a/tests/php/SecurityAdminTest.php b/tests/php/SecurityAdminTest.php index d2a9f0ae7..586cbedbf 100644 --- a/tests/php/SecurityAdminTest.php +++ b/tests/php/SecurityAdminTest.php @@ -54,7 +54,7 @@ public function testPermissionFieldRespectsHiddenPermissions() $group = $this->objFromFixture(Group::class, 'admin'); - Config::modify()->merge(Permission::class, 'hidden_permissions', array('CMS_ACCESS_ReportAdmin')); + Config::modify()->merge(Permission::class, 'hidden_permissions', ['CMS_ACCESS_ReportAdmin']); $response = $this->get(sprintf('admin/security/EditForm/field/Groups/item/%d/edit', $group->ID)); $this->assertStringContainsString( diff --git a/themes/cms-forms/templates/SilverStripe/Forms/SelectionGroup.ss b/themes/cms-forms/templates/SilverStripe/Forms/SelectionGroup.ss index ac0b85b33..203a65f61 100644 --- a/themes/cms-forms/templates/SilverStripe/Forms/SelectionGroup.ss +++ b/themes/cms-forms/templates/SilverStripe/Forms/SelectionGroup.ss @@ -23,7 +23,7 @@ <% if $FieldList %> <div class="selection-group selection-group__item__fieldlist" id="$ID"> <% loop $FieldList %> - $Fieldholder + $FieldHolder <% end_loop %> </div> <% end_if %>